Component: I2C Color Sensor (101020341) (Grove)

From Flowcode Help
Jump to navigationJump to search


Author Matrix TSL
Version 1.0 (Release)
Category Grove


Image I2C Color Sensor (101020341) component

Based on the color sensor TCS34725FN with digital output I2C. Based on the 8*2 array of filtered photodiodes and 16-bits analog-to-digital converters, you can gain the color chromaticity of ambient light or the color of objects. Of the 16 photodiodes, 4 have red filters, 4 have green filters, 4 have blue filters and 4 have no filter(clear). With the synchronization input pin, external pulsed light source can provides precise synchronous conversion control.

The I2C must be connected to the correct channel, also make sure that the SDA and SCL are connected to the right pins in flowcode. The colour sensor must be initialised before it can take any readings, and you need to make sure you have the ‘EnableSensor’ macro in before it can read any colours. There is also an option to disable the sensor again. After the sensor has been initialised and enabled, you can use the ‘SampleSensor’ macro to take readings for the RGB values and then there are two other component macros to use these values to calculate the luminance in lux, and the colour temperature in degrees kelvin.

Examples

No additional examples


Downloadable macro reference

ControlInterrupt

Enables or Disables the Interrupt pin to fire when the light levels are inside the interrupt limits.

Parameters

BYTE Enable
Range: 0 to 1 - 0=Interrupt Off / 1=Interrupt On
UINT LowLevel
UINT HighLevel


Return value

This call does not return a value


SetGain

Controls the gain.

0x00 = 1X

0x01 = 4X

0x02 = 16X

0x03 = 60X

Parameters

BYTE Setting
Range: 0 to 3


Return value

This call does not return a value


ClearInterrupt

Clears the interrupt flag allowing the device to interrupt again.

Parameters

This macro has no parameters


Return value

This call does not return a value


CalculateTemp

Uses the RGB values stored in RAM from the last Sample to calculate the colour temperature in degrees Kelvin.

Parameters

This macro has no parameters


Return value

UINT


EnableSensor

Powers up the device ready for taking colour readings.

Parameters

This macro has no parameters


Return value

This call does not return a value


CalculateLux

Uses the RGB values stored in RAM from the last Sample to calculate the luminance in lux.

Parameters

This macro has no parameters


Return value

UINT


SampleSensor

Reads the raw colour channels from the sensor and stores the readings into RAM

to be collected by the ReadDataChannel macro.

Parameters

This macro has no parameters


Return value

This call does not return a value


ReadDataChannel

Returns the value of the selected colour channel from the last sample.

The Red, Green and Blue channels have a colour filter to remove light of other colours.

The Clear channel has no filter allowing the ambient light level to be easily collected.

Parameters

BYTE ColourChannel
Range: 0 to 3 - 0=Red, 1=Green, 2=Blue, 3=Clear


Return value

UINT


SetIntegrationTime

Controls the integration time.

0 = 700mS / 1 = 154mS / 2 = 101mS / 3 = 50mS / 4 = 24mS / 5 = 2.4mS

Parameters

BYTE Setting
Range: 0 to 5


Return value

This call does not return a value


DisableSensor

Powers down the device to save power.

Parameters

This macro has no parameters


Return value

This call does not return a value


Initialise

Initialise the sensor configuration as set by the component properties.

Sets the default intigration time and gain as well as enable the sensor.

Parameters

This macro has no parameters


Return value

This call does not return a value


Simulation macro reference

This component does not contain any simulation macros


Property reference

Integration Time

This property is of type Fixed list of ints and can be referenced with the variable name IntgTime.

Length of time period used to sample the sensor frequency (longer is more accurate)

Gain

This property is of type Fixed list of ints and can be referenced with the variable name GAIN.

Length of time period used to sample the sensor frequency (longer is more accurate)

Channel

This property is of type Fixed list of ints and can be referenced with the variable name cal_i2c1::CHANNEL.

Channel selection

Baud Select

This property is of type Fixed list of ints and can be referenced with the variable name cal_i2c1::BAUD_LIST.

Baud rate option selector

Baud Rate

This property is of type Signed integer and can be referenced with the variable name cal_i2c1::BAUD.

Baud rate to be used

Stop Delay

This property is of type True or false and can be referenced with the variable name cal_i2c1::StopDel.

On older microcontroller devices there is a potential for the I2C hardware channel to lock up if there is not

a 10ms delay between an I2C stop event and the next I2C start event.


Most modern microcontrollers will not have a problem so this property can be disabled to speed up the

I2C communications.

SDA

This property is of type Single digital pin and can be referenced with the variable name cal_i2c1::SDA.

Pin used for SDA (data signal)

SCL

This property is of type Single digital pin and can be referenced with the variable name cal_i2c1::SCL.

Pin used for SCL (clock signal)

Simulation Type

This property is of type Fixed list of ints and can be referenced with the variable name SimType.

Selects the simulation type for the component.

Component GUI - Interacts with the panel to sense the colour of a object in close proximity to the sensor.

I2C Injector - Performs the I2C commands allowing you to connect an injector component or view and debug the I2C communications.

Scope Traces

This property is of type True or false and can be referenced with the variable name cal_i2c1::ScopeTraces.

Selects if the scope traces are automatically generated or not

Console Data

This property is of type True or false and can be referenced with the variable name cal_i2c1::ConsoleData.

Selects if the console data is automatically generated or not

Injector

This property is of type Fixed list of ints and can be referenced with the variable name cal_i2c1::Injector.

No additional information