Jump to content

Component: Accelerometer (EB068) (E-blocks 1): Difference between revisions

From Flowcode Help
XML import - Pre 8.0 release
 
No edit summary
Line 1: Line 1:
 
{| style="width:50%"
 
{| width="50%"
|-
|-
| width="20%" style="color: gray;" | Author
| width="20%" style="color:gray;" | Author
| Matrix TSL
| Matrix TSL
|-
|-
| width="20%" style="color: gray;" | Version
| width="20%" style="color:gray;" | Version
| 2.0 (Release)
| 2.0
|-
|-
| width="20%" style="color: gray;" | Category
| width="20%" style="color:gray;" | Category
| E-blocks 1
| E-blocks 1
|}
|}




==Accelerometer component==
LIS3LV02DQ Accelerometer sensor with options for I2C or SPI communications. Useful for approximating Pitch and Roll or for detecting acceleration. Also available in the form of the EB068 Accelerometer E-block.


==[[File:Component Icon b81925b1_7504_4d77_ac90_3a4fa700fcc4.png|Image]] Accelerometer (EB068) component==
==Component Source Code==
LIS3LV02DQ Accelerometer sensor with options for I2C or SPI communications.
Useful for approximating Pitch and Roll or for detecting acceleration.
Also available in the form of the EB068 Accelerometer E-block.


==Examples==
Please click here for the component source code: [https://www.flowcode.co.uk/wikicopy/componentsource/FC_Comp_Source_Accelerometer_EB068.fcfx FC_Comp_Source_Accelerometer_EB068.fcfx]
''<span style="color:red;">No additional examples</span>''


==Detailed description==


==Downloadable macro reference==
''No detailed description exists yet for this component''


===<span style="font-weight: normal;"><u><tt>CollectXYZData</tt></u></span>===
==Examples==
Collect the data from the local accelerometer buffers.


The Axis parameter specifies the Axis to be read.


0 / 'x' / 'X' - X axis
''<span style="color:red;">No additional examples</span>''


1 / 'y' / 'Y' - Y axis


2 / 'z' / 'Z' - Z axis
==Downloadable macro reference==


'''Parameters'''
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SimReset1G'''
|-
| colspan="2" | Resets the simulation to 0.0 on X and Y and 1.0 on Z as if the accelerometer was sitting completely horizontal.&nbsp;
|-
|-
| 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''
|}


:[[Variable Types|BYTE]] ''Axis''


{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Write_Register'''
|-
| colspan="2" | Writes a data value to a specific register on the accelerometer&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Reg
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Data
|-
| colspan="2" | &nbsp;
|-
| 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''
|}


'''Return value'''


:[[Variable Types|INT]]
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CollectXYZData'''
|-
| colspan="2" | Collect the data from the local accelerometer buffers. The Axis parameter specifies the Axis to be read. 0 / 'x' / 'X' - X axis 1 / 'y' / 'Y' - Y axis 2 / 'z' / 'Z' - Z axis&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Axis
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-s16-icon.png]] - INT
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}




===<span style="font-weight: normal;"><u><tt>UpdateXYZData</tt></u></span>===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
Reads from the accelerometer and updates the local XYZ variables.
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''UpdateXYZData'''
|-
| colspan="2" | Reads from the accelerometer and updates the local XYZ variables. Returns 1 for new data and 0 for no new data&nbsp;
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


Returns 1 for new data and 0 for no new data


'''Parameters'''
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SimSetXYZ'''
|-
| colspan="2" | Allows the XYZ slider values to be set via the simulation&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-s16-icon.png]] - INT
| width="90%" | X
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" | [[File:Fc9-s16-icon.png]] - INT
| width="90%" | Y
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" | [[File:Fc9-s16-icon.png]] - INT
| width="90%" | Z
|-
| colspan="2" | &nbsp;
|-
| 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''
|}


:''This macro has no parameters''


 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
'''Return value'''
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
:[[Variable Types|BYTE]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
 
|-
 
| colspan="2" | Sets up up the communication bus and initialises the accelerometer module. Returns 0 for success and > 0 for fail.&nbsp;
===<span style="font-weight: normal;"><u><tt>Initialise</tt></u></span>===
|-
Sets up up the communication bus and initialises the accelerometer module.  
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
Returns 0 for success and > 0 for fail.
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
'''Parameters'''
 
:''This macro has no parameters''
 
 
'''Return value'''
 
:[[Variable Types|BYTE]]
 
 
 
==Simulation macro reference==
 
===<span style="font-weight: normal;"><u><tt>SimReset1G</tt></u></span>===
Resets the simulation to 0.0 on X and Y and 1.0 on Z as if the accelerometer was
 
sitting completely horizontal.
 
'''Parameters'''
 
:''This macro has no parameters''
 
 
'''Return value'''
 
:''This call does not return a value''
 
 
===<span style="font-weight: normal;"><u><tt>SimSetXYZ</tt></u></span>===
Allows the XYZ slider values to be set via the simulation
 
'''Parameters'''
 
:[[Variable Types|INT]] ''X''
 
:[[Variable Types|INT]] ''Y''
 
:[[Variable Types|INT]] ''Z''
 
 
'''Return value'''
 
:''This call does not return a value''




Line 115: Line 142:


==Property reference==
==Property reference==
<span style="font-weight: normal;"><u>Bit Depth</u></span>


This property is of type ''Signed integer'' and can be referenced with the variable name ''bit_depth''.
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
The number of binary bits used to store the sensor's X,Y,Z readings.
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-prop-icon.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties'''  
<span style="font-weight: normal;"><u>Bus Type</u></span>
|-
 
|-
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''bus_type''.
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
 
| width="90%" | Bit Depth
The interface used to talk to the accelerometer.
|-
 
| colspan="2" | The number of binary bits used to store the sensor's X,Y,Z readings.&nbsp;
I2C - Two Wire Interface SDA / SCL
|-
 
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
SPI - Four Wire Interface MISO / MOSI / SCK / CS
| width="90%" | Bus Type
 
|-
<span style="font-weight: normal;"><u>Data Rate</u></span>
| colspan="2" | The interface used to talk to the accelerometer. I2C - Two Wire Interface SDA / SCL SPI - Four Wire Interface MISO / MOSI / SCK / CS&nbsp;
 
|-
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''data_rate''.
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
| width="90%" | Data Rate
Configures how often the sensor collects a new reading.
|-
 
| colspan="2" | Configures how often the sensor collects a new reading. More often = better instant reaction to new events Less often = more stable results&nbsp;
More often = better instant reaction to new events
|-
 
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
Less often = more stable results
| width="90%" | Scale
 
|-
<span style="font-weight: normal;"><u>Scale</u></span>
| colspan="2" | The accelerometer readings are scaled based on the maximum amount of G force the sensor can represent. 6G = Bigger gravitational force 2G = Higher resolution&nbsp;
 
|-
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''scale''.
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
| width="90%" | Int Option
The accelerometer readings are scaled based on the maximum amount of G force the sensor can represent.
|-
 
| colspan="2" | Sets if we use the interrupt pin to check if new data is available&nbsp;
6G = Bigger gravitational force
|-
 
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
2G = Higher resolution
| width="90%" | Power Option
 
|-
<span style="font-weight: normal;"><u>Int Option</u></span>
| colspan="2" | Sets if the sensor is always powered or powered via a microcontroller output pin.&nbsp;
 
|-
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''IntOpt''.
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
 
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Connections
Sets if we use the interrupt pin to check if new data is available
|-
 
|-
<span style="font-weight: normal;"><u>Power Option</u></span>
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
 
| width="90%" | Interrupt Pin
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''PowerOpt''.
|-
 
| colspan="2" | Interrupt pin from the sensor, checked when performing an update to see if the sensor has new data available. &nbsp;
Sets if the sensor is always powered or powered via a microcontroller output pin.
|-
 
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
<span style="font-weight: normal;"><u>Interrupt Pin</u></span>
| width="90%" | Power Pin
 
|-
This property is of type ''Single digital pin'' and can be referenced with the variable name ''int_pin''.
| colspan="2" | Power pin if the sensor is powered from an I/O pin.&nbsp;
 
|-
Interrupt pin from the sensor, checked when performing an update to see if the sensor has new data available.
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
 
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | SPI Connections
<span style="font-weight: normal;"><u>Power Pin</u></span>
|-
 
|-
This property is of type ''Single digital pin'' and can be referenced with the variable name ''pwr_pin''.
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
| width="90%" | Channel
Power pin if the sensor is powered from an I/O pin.
|-
 
| colspan="2" | SPI Channel selector&nbsp;
<span style="font-weight: normal;"><u>Channel</u></span>
|-
 
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_i2c::CHANNEL''.
| width="90%" | Prescale
 
|-
Channel selection
| colspan="2" | Prescale option selector&nbsp;
 
|-
<span style="font-weight: normal;"><u>Baud Select</u></span>
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
 
| width="90%" | MOSI
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_i2c::BAUD_LIST''.
|-
 
| colspan="2" | SPI Data Out Pin SDO - Also Known as Master Out Slave In (MOSI) when used in Master mode.&nbsp;
Baud rate option selector
|-
 
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
<span style="font-weight: normal;"><u>Baud Rate</u></span>
| width="90%" | MISO
 
|-
This property is of type ''Signed integer'' and can be referenced with the variable name ''cal_i2c::BAUD''.
| colspan="2" | SPI Data In Pin SDI - Also Known as Master In Slave Out (MISO) when used in Master mode.&nbsp;
 
|-
Baud rate to be used
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
 
| width="90%" | CLK
<span style="font-weight: normal;"><u>SDA</u></span>
|-
 
| colspan="2" | SPI Clock Pin CLK - The Clock signal is driven by the SPI master.&nbsp;
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_i2c::SDA''.
|-
 
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
Pin used for SDA (data signal)
| width="90%" | CS / SS
 
|-
<span style="font-weight: normal;"><u>SCL</u></span>
| colspan="2" | Chip Select / Slave Select Pin Master Mode: General purpose output pin used to select the remote SPI device. Slave Mode: Hardware chip select pin input used to select the SPI device. &nbsp;
 
|-
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_i2c::SCL''.
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
 
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Simulation
Pin used for SCL (clock signal)
|-
 
|-
<span style="font-weight: normal;"><u>Stop Delay</u></span>
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
 
| width="90%" | Simulation Coms
This property is of type ''True or false'' and can be referenced with the variable name ''cal_i2c::StopDel''.
|-
 
| colspan="2" | Yes: Accelerometer data will come from the simulation component sliders. No: Accelerometer data will come from the CAL component - I2C or SPI - Injector etc&nbsp;
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.
 
<span style="font-weight: normal;"><u>Channel</u></span>
 
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_spi::CHANNEL''.
 
SPI Channel selector
 
<span style="font-weight: normal;"><u>Prescale</u></span>
 
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_spi::PR_SCALE''.
 
Prescale option selector
 
<span style="font-weight: normal;"><u>MOSI</u></span>
 
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_spi::MOSI''.
 
SPI Data Out Pin SDO - Also Known as Master Out Slave In (MOSI) when used in Master mode.
 
<span style="font-weight: normal;"><u>MISO</u></span>
 
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_spi::MISO''.
 
SPI Data In Pin SDI - Also Known as Master In Slave Out (MISO) when used in Master mode.
 
<span style="font-weight: normal;"><u>CLK</u></span>
 
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_spi::CLK''.
 
SPI Clock Pin CLK - The Clock signal is driven by the SPI master.
 
<span style="font-weight: normal;"><u>CS / SS</u></span>
 
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_spi::SS''.
 
Chip Select / Slave Select Pin  
 
Master Mode: General purpose output pin used to select the remote SPI device.
 
Slave Mode: Hardware chip select pin input used to select the SPI device.
 
<span style="font-weight: normal;"><u>Simulation GUI</u></span>
 
This property is of type ''True or false'' and can be referenced with the variable name ''SimulationGUI''.
 
Yes: Accelerometer data will come from the simulation component sliders.
 
No: Accelerometer data will come from the CAL component - I2C or SPI - Injector etc
 
<span style="font-weight: normal;"><u>Scope Traces</u></span>
 
This property is of type ''True or false'' and can be referenced with the variable name ''cal_i2c::ScopeTraces''.
 
Selects if the scope traces are automatically generated or not
 
<span style="font-weight: normal;"><u>Console Data</u></span>
 
This property is of type ''True or false'' and can be referenced with the variable name ''cal_i2c::ConsoleData''.
 
Selects if the console data is automatically generated or not
 
<span style="font-weight: normal;"><u>Injector</u></span>
 
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_i2c::Injector''.
 
''<span style="color:red;">No additional information</span>''
 
 
 
<span style="font-weight: normal;"><u>Scope Traces</u></span>
 
This property is of type ''True or false'' and can be referenced with the variable name ''cal_spi::ScopeTraces''.
 
Selects if the scope traces are automatically generated or not
 
<span style="font-weight: normal;"><u>Console Data</u></span>
 
This property is of type ''True or false'' and can be referenced with the variable name ''cal_spi::ConsoleData''.
 
Selects if the console data is automatically generated or not
 
<span style="font-weight: normal;"><u>Injector</u></span>
 
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_spi::Injector''.
 
''<span style="color:red;">No additional information</span>''

Revision as of 14:39, 16 January 2023

Author Matrix TSL
Version 2.0
Category E-blocks 1


Accelerometer component

LIS3LV02DQ Accelerometer sensor with options for I2C or SPI communications. Useful for approximating Pitch and Roll or for detecting acceleration. Also available in the form of the EB068 Accelerometer E-block.

Component Source Code

Please click here for the component source code: FC_Comp_Source_Accelerometer_EB068.fcfx

Detailed description

No detailed description exists yet for this component

Examples

No additional examples


Downloadable macro reference

SimReset1G
Resets the simulation to 0.0 on X and Y and 1.0 on Z as if the accelerometer was sitting completely horizontal. 
- VOID Return


Write_Register
Writes a data value to a specific register on the accelerometer 
- BYTE Reg
 
- BYTE Data
 
- VOID Return


CollectXYZData
Collect the data from the local accelerometer buffers. The Axis parameter specifies the Axis to be read. 0 / 'x' / 'X' - X axis 1 / 'y' / 'Y' - Y axis 2 / 'z' / 'Z' - Z axis 
- BYTE Axis
 
- INT Return


UpdateXYZData
Reads from the accelerometer and updates the local XYZ variables. Returns 1 for new data and 0 for no new data 
- BYTE Return


SimSetXYZ
Allows the XYZ slider values to be set via the simulation 
- INT X
 
- INT Y
 
- INT Z
 
- VOID Return


Initialise
Sets up up the communication bus and initialises the accelerometer module. Returns 0 for success and > 0 for fail. 
- BYTE Return



Property reference

Properties
Bit Depth
The number of binary bits used to store the sensor's X,Y,Z readings. 
Bus Type
The interface used to talk to the accelerometer. I2C - Two Wire Interface SDA / SCL SPI - Four Wire Interface MISO / MOSI / SCK / CS 
Data Rate
Configures how often the sensor collects a new reading. More often = better instant reaction to new events Less often = more stable results 
Scale
The accelerometer readings are scaled based on the maximum amount of G force the sensor can represent. 6G = Bigger gravitational force 2G = Higher resolution 
Int Option
Sets if we use the interrupt pin to check if new data is available 
Power Option
Sets if the sensor is always powered or powered via a microcontroller output pin. 
Connections
Interrupt Pin
Interrupt pin from the sensor, checked when performing an update to see if the sensor has new data available.  
Power Pin
Power pin if the sensor is powered from an I/O pin. 
SPI Connections
Channel
SPI Channel selector 
Prescale
Prescale option selector 
MOSI
SPI Data Out Pin SDO - Also Known as Master Out Slave In (MOSI) when used in Master mode. 
MISO
SPI Data In Pin SDI - Also Known as Master In Slave Out (MISO) when used in Master mode. 
CLK
SPI Clock Pin CLK - The Clock signal is driven by the SPI master. 
CS / SS
Chip Select / Slave Select Pin Master Mode: General purpose output pin used to select the remote SPI device. Slave Mode: Hardware chip select pin input used to select the SPI device.  
Simulation
Simulation Coms
Yes: Accelerometer data will come from the simulation component sliders. No: Accelerometer data will come from the CAL component - I2C or SPI - Injector etc