Difference between revisions of "Component: Magnetometer (Inputs: Sensors)"
(XML import) |
(XML import) |
||
(One intermediate revision by the same user not shown) | |||
Line 7: | Line 7: | ||
|- | |- | ||
| width="20%" style="color: gray;" | Version | | width="20%" style="color: gray;" | Version | ||
− | | 1. | + | | 1.6 (Release) |
|- | |- | ||
| width="20%" style="color: gray;" | Category | | width="20%" style="color: gray;" | Category | ||
Line 15: | Line 15: | ||
− | ==[[File:Component Icon | + | ==[[File:Component Icon db2c91d9_4fd5_42b8_98f4_76dfb160dece.png|Image]] Magnetometer component== |
− | + | LSM303D Combined 6-Axis Accelerometer and Magnetometer sensors | |
Useful for working out data such as Pitch and Yaw. | Useful for working out data such as Pitch and Yaw. | ||
==Examples== | ==Examples== | ||
− | + | Sample program using the EBM015 - Magnetometer sensor. | |
+ | Reads either the accelerometer or compass data and displays on the LCD. | ||
+ | {{Fcfile|EBM015 - Test Program.fcfx|EBM015 Example}} | ||
==Downloadable macro reference== | ==Downloadable macro reference== | ||
+ | |||
+ | ===<span style="font-weight: normal;"><u><tt>Read_Register</tt></u></span>=== | ||
+ | Reads a value from a register on the accelerometer. | ||
+ | |||
+ | '''Parameters''' | ||
+ | |||
+ | :[[Variable Types|BYTE]] ''Reg'' | ||
+ | |||
+ | |||
+ | '''Return value''' | ||
+ | |||
+ | :[[Variable Types|BYTE]] | ||
+ | |||
===<span style="font-weight: normal;"><u><tt>SimReset1G</tt></u></span>=== | ===<span style="font-weight: normal;"><u><tt>SimReset1G</tt></u></span>=== | ||
Line 48: | Line 63: | ||
:''This macro has no parameters'' | :''This macro has no parameters'' | ||
+ | |||
+ | |||
+ | '''Return value''' | ||
+ | |||
+ | :[[Variable Types|BYTE]] | ||
+ | |||
+ | |||
+ | ===<span style="font-weight: normal;"><u><tt>Write_Register</tt></u></span>=== | ||
+ | Writes a data value to a specific register on the accelerometer | ||
+ | |||
+ | '''Parameters''' | ||
+ | |||
+ | :[[Variable Types|BYTE]] ''Reg'' | ||
+ | |||
+ | :[[Variable Types|BYTE]] ''Data'' | ||
Line 123: | Line 153: | ||
:''This call does not return a value'' | :''This call does not return a value'' | ||
+ | |||
+ | |||
+ | ===<span style="font-weight: normal;"><u><tt>Read_Bearing</tt></u></span>=== | ||
+ | Reads the current sensor compass bearing based on degrees CW from magnetic north. | ||
+ | |||
+ | Returns 0-359 where 0 = North, 90 = East, 180 = South, 270 = West | ||
+ | |||
+ | Requires the ArcTan floating point function to be available to work correctly. | ||
+ | |||
+ | Supported on AVR, 16-bit | ||
+ | |||
+ | '''Parameters''' | ||
+ | |||
+ | :[[Variable Types|BYTE]] ''NumSamples'' | ||
+ | ::The number of readings to base the bearing on | ||
+ | |||
+ | |||
+ | '''Return value''' | ||
+ | |||
+ | :[[Variable Types|UINT]] | ||
Line 150: | Line 200: | ||
This property is of type ''Signed integer'' and can be referenced with the variable name ''bit_depth''. | This property is of type ''Signed integer'' and can be referenced with the variable name ''bit_depth''. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
''<span style="color:red;">No additional information</span>'' | ''<span style="color:red;">No additional information</span>'' | ||
Line 203: | Line 245: | ||
− | <span style="font-weight: normal;"><u> | + | <span style="font-weight: normal;"><u>Stop Delay</u></span> |
+ | |||
+ | This property is of type ''True or false'' and can be referenced with the variable name ''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. | ||
<span style="font-weight: normal;"><u>SDA Pin</u></span> | <span style="font-weight: normal;"><u>SDA Pin</u></span> |
Latest revision as of 17:59, 18 March 2016
Author | Matrix TSL |
Version | 1.6 (Release) |
Category | Inputs: Sensors |
Contents
Magnetometer component
LSM303D Combined 6-Axis Accelerometer and Magnetometer sensors Useful for working out data such as Pitch and Yaw.
Examples
Sample program using the EBM015 - Magnetometer sensor.
Reads either the accelerometer or compass data and displays on the LCD. EBM015 Example
Downloadable macro reference
Read_Register
Reads a value from a register on the accelerometer.
Parameters
- BYTE Reg
Return value
SimReset1G
No additional information
Parameters
- This macro has no parameters
Return value
- This call does not return a value
UpdateCompassData
Reads from the compass and updates the local XYZ variables.
Returns 1 for new data and 0 for no new data
Parameters
- This macro has no parameters
Return value
Write_Register
Writes a data value to a specific register on the accelerometer
Parameters
- BYTE Reg
- BYTE Data
Return value
SimSetAccelerometer
Allows the XYZ slider values to be set via the simulation
Parameters
- INT X
- INT Y
- INT Z
Return value
- This call does not return a value
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
Parameters
- BYTE Axis
Return value
UpdateAccelerometerData
Reads from the accelerometer and updates the local XYZ variables.
Returns 1 for new data and 0 for no new data
Parameters
- This macro has no parameters
Return value
SimSetCompass
Allows the XYZ slider values to be set via the simulation
Parameters
- INT X
- INT Y
- INT Z
Return value
- This call does not return a value
Read_Bearing
Reads the current sensor compass bearing based on degrees CW from magnetic north.
Returns 0-359 where 0 = North, 90 = East, 180 = South, 270 = West
Requires the ArcTan floating point function to be available to work correctly.
Supported on AVR, 16-bit
Parameters
- BYTE NumSamples
- The number of readings to base the bearing on
Return value
Initialise
Sets up up the communication bus and initialises the accelerometer module.
Returns 0 for success and > 0 for fail.
Parameters
- This macro has no parameters
Return value
Simulation macro reference
This component does not contain any simulation macros
Property reference
Bit Depth
This property is of type Signed integer and can be referenced with the variable name bit_depth.
No additional information
Accel Data Rate
This property is of type Fixed list of ints and can be referenced with the variable name accel_data_rate.
No additional information
Accel Scale
This property is of type Fixed list of ints and can be referenced with the variable name accel_scale.
No additional information
Compass Data Rate
This property is of type Fixed list of ints and can be referenced with the variable name compass_data_rate.
No additional information
Compass Scale
This property is of type Fixed list of ints and can be referenced with the variable name compass_scale.
No additional information
I2C Channel
This property is of type Fixed list of ints and can be referenced with the variable name channel.
No additional information
Stop Delay
This property is of type True or false and can be referenced with the variable name 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 Pin
This property is of type Single digital pin and can be referenced with the variable name sda_pin.
No additional information
SCL Pin
This property is of type Single digital pin and can be referenced with the variable name scl_pin.
No additional information