Difference between revisions of "Component: Colour Sensor (Grove 101020341) (101020341) (Light)"

From Flowcode Help
Jump to navigationJump to search
(Created page with "{| style="width:50%" |- | width="20%" style="color:gray;" | Author | Matrix TSL |- | width="20%" style="color:gray;" | Version | 1.0 |- | width="20%" style="color:gray...")
 
 
(10 intermediate revisions by the same user not shown)
Line 15: Line 15:
 
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.
 
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.
  
==Component Pack==
+
==Component Source Code==
  
SENSORS
+
Please click here to download the component source project: [https://www.flowcode.co.uk/wiki/componentsource/FC_Comp_Source_I2C_Colour_Sensor.fcfx FC_Comp_Source_I2C_Colour_Sensor.fcfx]
 +
 
 +
Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_I2C_Colour_Sensor.fcfx FC_Comp_Source_I2C_Colour_Sensor.fcfx]
  
 
==Detailed description==
 
==Detailed description==
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
  
 
''No detailed description exists yet for this component''
 
''No detailed description exists yet for this component''
  
 
==Examples==
 
==Examples==
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
  
  
Line 29: Line 59:
  
  
==Downloadable macro reference==
 
  
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
==Macro reference==
 +
 +
===CalculateLux===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ControlInterrupt'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CalculateLux'''
 
|-
 
|-
| colspan="2" | Enables or Disables the Interrupt pin to fire when the light levels are inside the interrupt limits. 
+
| colspan="2" | Uses the RGB values stored in RAM from the last Sample to calculate the luminance in lux. 
 
|-
 
|-
 
|-
 
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
+
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | Enable
 
|-
 
| colspan="2" | Range: 0 to 1 - 0=Interrupt Off / 1=Interrupt On 
 
|-
 
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 
| width="90%" | LowLevel
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 
| width="90%" | HighLevel
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
|}
  
  
 +
===CalculateTemp===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetGain'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CalculateTemp'''
 
|-
 
|-
| colspan="2" | Controls the gain. 0x00 = 1X 0x01 = 4X 0x02 = 16X 0x03 = 60X 
+
| colspan="2" | Uses the RGB values stored in RAM from the last Sample to calculate the colour temperature in degrees Kelvin. 
 
|-
 
|-
 
|-
 
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
+
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | Setting
 
|-
 
| colspan="2" | Range: 0 to 3 
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
|}
  
  
 +
===ClearInterrupt===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
Line 90: Line 113:
  
  
 +
===ControlInterrupt===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CalculateTemp'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ControlInterrupt'''
 +
|-
 +
| colspan="2" | Enables or Disables the Interrupt pin to fire when the light levels are inside the interrupt limits. 
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Enable
 +
|-
 +
| colspan="2" | Range: 0 to 1 - 0=Interrupt Off / 1=Interrupt On 
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 +
| width="90%" | LowLevel
 +
|-
 +
| colspan="2" |  
 
|-
 
|-
| colspan="2" | Uses the RGB values stored in RAM from the last Sample to calculate the colour temperature in degrees Kelvin. 
+
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 +
| width="90%" | HighLevel
 
|-
 
|-
 +
| colspan="2" |  
 
|-
 
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT
+
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
|}
  
  
 +
===DisableSensor===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''EnableSensor'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''DisableSensor'''
 
|-
 
|-
| colspan="2" | Powers up the device ready for taking colour readings. 
+
| colspan="2" | Powers down the device to save power. 
 
|-
 
|-
 
|-
 
|-
Line 116: Line 156:
  
  
 +
===EnableSensor===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CalculateLux'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''EnableSensor'''
 
|-
 
|-
| colspan="2" | Uses the RGB values stored in RAM from the last Sample to calculate the luminance in lux. 
+
| colspan="2" | Powers up the device ready for taking colour readings. 
 
|-
 
|-
 
|-
 
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT
+
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
|}
  
  
 +
===Initialise===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SampleSensor'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
 
|-
 
|-
| colspan="2" | Reads the raw colour channels from the sensor and stores the readings into RAM to be collected by the ReadDataChannel macro. 
+
| colspan="2" | Initialise the sensor configuration as set by the component properties. Sets the default intigration time and gain as well as enable the sensor. 
 
|-
 
|-
 
|-
 
|-
Line 142: Line 184:
  
  
 +
===ReadDataChannel===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
Line 160: Line 203:
  
  
 +
===SampleSensor===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''DisableSensor'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SampleSensor'''
 
|-
 
|-
| colspan="2" | Powers down the device to save power. 
+
| colspan="2" | Reads the raw colour channels from the sensor and stores the readings into RAM to be collected by the ReadDataChannel macro. 
 
|-
 
|-
 
|-
 
|-
Line 173: Line 217:
  
  
 +
===SetGain===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetIntegrationTime'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetGain'''
 
|-
 
|-
| colspan="2" | Controls the integration time. 0 = 700mS / 1 = 154mS / 2 = 101mS / 3 = 50mS / 4 = 24mS / 5 = 2.4mS 
+
| colspan="2" | Controls the gain. 0x00 = 1X 0x01 = 4X 0x02 = 16X 0x03 = 60X 
 
|-
 
|-
 
|-
 
|-
Line 184: Line 229:
 
| width="90%" | Setting
 
| width="90%" | Setting
 
|-
 
|-
| colspan="2" | Range: 0 to 5 
+
| colspan="2" | Range: 0 to 3 
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
Line 191: Line 236:
  
  
 +
===SetIntegrationTime===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetIntegrationTime'''
 +
|-
 +
| colspan="2" | Controls the integration time. 0 = 700mS / 1 = 154mS / 2 = 101mS / 3 = 50mS / 4 = 24mS / 5 = 2.4mS 
 +
|-
 
|-
 
|-
| colspan="2" | Initialise the sensor configuration as set by the component properties. Sets the default intigration time and gain as well as enable the sensor. 
+
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Setting
 
|-
 
|-
 +
| colspan="2" | Range: 0 to 5 
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
|}
 
 
  
  
Line 212: Line 261:
 
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-prop-icon.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-prop-icon.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties'''  
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties'''  
 +
|-
 +
|-
 +
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
 +
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Sensor Settings
 
|-
 
|-
 
|-
 
|-
Line 223: Line 276:
 
|-
 
|-
 
| colspan="2" | Length of time period used to sample the sensor frequency (longer is more accurate) 
 
| colspan="2" | Length of time period used to sample the sensor frequency (longer is more accurate) 
 +
|-
 +
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
 +
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | I2C Settings
 +
|-
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
Line 254: Line 311:
 
| colspan="2" | Pin used for SCL (clock signal) 
 
| colspan="2" | Pin used for SCL (clock signal) 
 
|-
 
|-
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
+
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="90%" | Scope Traces
+
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Simulation
|-
 
| colspan="2" | Selects if the scope traces are automatically generated or not 
 
|-
 
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
 
| width="90%" | Console Data
 
|-
 
| colspan="2" | Selects if the console data is automatically generated or not 
 
|-
 
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
| width="90%" | API
 
|-
 
| colspan="2" |  
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-conn-icon.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Connections'''
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-conn-icon.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Simulations'''
 
 
|-
 
|-
 
|-
 
|-

Latest revision as of 13:10, 7 February 2023

Author Matrix TSL
Version 1.0
Category Light


Colour Sensor (Grove 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.

Component Source Code

Please click here to download the component source project: FC_Comp_Source_I2C_Colour_Sensor.fcfx

Please click here to view the component source code (Beta): FC_Comp_Source_I2C_Colour_Sensor.fcfx

Detailed description

No detailed description exists yet for this component

Examples

No additional examples







Macro reference

CalculateLux

Fc9-comp-macro.png CalculateLux
Uses the RGB values stored in RAM from the last Sample to calculate the luminance in lux. 
Fc9-u16-icon.png - UINT Return


CalculateTemp

Fc9-comp-macro.png CalculateTemp
Uses the RGB values stored in RAM from the last Sample to calculate the colour temperature in degrees Kelvin. 
Fc9-u16-icon.png - UINT Return


ClearInterrupt

Fc9-comp-macro.png ClearInterrupt
Clears the interrupt flag allowing the device to interrupt again. 
Fc9-void-icon.png - VOID Return


ControlInterrupt

Fc9-comp-macro.png ControlInterrupt
Enables or Disables the Interrupt pin to fire when the light levels are inside the interrupt limits. 
Fc9-u8-icon.png - BYTE Enable
Range: 0 to 1 - 0=Interrupt Off / 1=Interrupt On 
Fc9-u16-icon.png - UINT LowLevel
 
Fc9-u16-icon.png - UINT HighLevel
 
Fc9-void-icon.png - VOID Return


DisableSensor

Fc9-comp-macro.png DisableSensor
Powers down the device to save power. 
Fc9-void-icon.png - VOID Return


EnableSensor

Fc9-comp-macro.png EnableSensor
Powers up the device ready for taking colour readings. 
Fc9-void-icon.png - VOID Return


Initialise

Fc9-comp-macro.png Initialise
Initialise the sensor configuration as set by the component properties. Sets the default intigration time and gain as well as enable the sensor. 
Fc9-void-icon.png - VOID Return


ReadDataChannel

Fc9-comp-macro.png 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. 
Fc9-u8-icon.png - BYTE ColourChannel
Range: 0 to 3 - 0=Red, 1=Green, 2=Blue, 3=Clear 
Fc9-u16-icon.png - UINT Return


SampleSensor

Fc9-comp-macro.png SampleSensor
Reads the raw colour channels from the sensor and stores the readings into RAM to be collected by the ReadDataChannel macro. 
Fc9-void-icon.png - VOID Return


SetGain

Fc9-comp-macro.png SetGain
Controls the gain. 0x00 = 1X 0x01 = 4X 0x02 = 16X 0x03 = 60X 
Fc9-u8-icon.png - BYTE Setting
Range: 0 to 3 
Fc9-void-icon.png - VOID Return


SetIntegrationTime

Fc9-comp-macro.png SetIntegrationTime
Controls the integration time. 0 = 700mS / 1 = 154mS / 2 = 101mS / 3 = 50mS / 4 = 24mS / 5 = 2.4mS 
Fc9-u8-icon.png - BYTE Setting
Range: 0 to 5 
Fc9-void-icon.png - VOID Return


Property reference

Fc9-prop-icon.png Properties
Fc9-conn-icon.png Sensor Settings
Fc9-type-16-icon.png Integration Time
Length of time period used to sample the sensor frequency (longer is more accurate) 
Fc9-type-16-icon.png Gain
Length of time period used to sample the sensor frequency (longer is more accurate) 
Fc9-conn-icon.png I2C Settings
Fc9-type-16-icon.png Channel
Channel selection 
Fc9-type-16-icon.png Baud Select
Baud rate option selector 
Fc9-type-14-icon.png Baud Rate
Baud rate to be used 
Fc9-type-7-icon.png Stop Delay
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.  
Fc9-type-5-icon.png SDA
Pin used for SDA (data signal) 
Fc9-type-5-icon.png SCL
Pin used for SCL (clock signal) 
Fc9-conn-icon.png Simulation
Fc9-type-16-icon.png Simulation Type
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.