Firmware-811 Function-122

From I-CubeX Wiki
Jump to: navigation, search

MAGNETIC3D (122, 7Ah)

The MAGNETIC3D function enables output of the Magnetic3D sensor data in both host and stand-alone mode. In host mode the sensor data is output in I2C DATA messages. In stand-alone mode the sensor data is output according to the stand-alone mode settings of the input number that equals the I2C port number. There are a number of methods to select using the function parameter FP:

Magnetic3D v1.0, v1.1, v1.2, v1.3

FP Data output in host mode Data output in stand-alone mode
"0" (see below) Magnetic Field Strength X-axis; a signed two’s complement 16-bit value sent as nibbles in four bytes (MSB .. LSB) Magnetic Field Strength X-axis; an unsigned 7-bit or 14-bit value sent as one or two bytes (LSB, MSB)
Magnetic Field Strength Z-axis; a signed two’s complement 16-bit value sent as nibbles in four bytes (MSB .. LSB) Magnetic Field Strength Z-axis; an unsigned 7-bit or 14-bit value sent as one or two bytes (LSB, MSB)
Magnetic Field Strength Y-axis; a signed two’s complement 16-bit value sent as nibbles in four bytes (MSB .. LSB) Magnetic Field Strength Y-axis; an unsigned 7-bit or 14-bit value sent as one or two bytes (LSB, MSB)
"2" (see below) Magnetic Field Strength Magnitude; a 32-bit float value sent as nibbles in 8 bytes (MSB .. LSB) Magnetic Field Strength Magnitude (scaled); an unsigned 7-bit or 14-bit value sent as one or two bytes (LSB, MSB)
Magnetic Field Strength Magnitude Angle relative to Z-axis; a 32-bit float value sent as nibbles in 8 bytes (MSB .. LSB) Magnetic Field Strength Magnitude Angle relative to Z-axis; an unsigned 7-bit or 14-bit value sent as one or two bytes (LSB, MSB)
Magnetic Field Strength Magnitude Angle relative to X-axis; a 32-bit float value sent as nibbles in 8 bytes (MSB .. LSB) Magnetic Field Strength Magnitude Angle relative to X-axis; an unsigned 7-bit or 14-bit value sent as one or two bytes (LSB, MSB)
default (see below) Magnetic Field Strength Magnitude; a 32-bit float value sent as nibbles in 8 bytes (MSB .. LSB) Magnetic Field Strength Magnitude (scaled); an unsigned 7-bit or 14-bit value sent as one or two bytes (LSB, MSB)

Methods "0" are those where FP is 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110 or 120.

Methods "2" are those where FP is 2, 12, 22, 32, 42, 52, 62, 72, 82, 92, 102, 112 or 122.

Default methods are those where FP is any value not listed in either of the other methods above.

In standalone mode, the default and "2" methods output a magnitude value that is scaled using FP. Keep in mind that when scaling the magnitude, the magnetic field strength range and hence the distance range within which the magnet is detected, also changes. If scaling too much or too little the output value may be clipped to either the maximum or the minimum magnetic field strength. To resolve this, change the magnet's position to bring it within the magnetic field strength range of the Magnetic3D.

Each 16-bit or 14-bit value represents a magnetic field strength that is scaled using a factor that can be set with a separate I2C WRITE command, see for more details the datasheet linked from Magnetic3D webpage. If using this scaling method in standalone mode, it would be in addition to the above scaling method using FP.


Example:

In order to enable the MAGNETIC3D function to get the magnetic field strength X-, Y- and Z-axis data from an Magnetic3D sensor with I2C device address 30 (default Magnetic3D I2C device address) connected to the 7th I2C port, the following message is sent:

240, 125, 0 {DEV}, 8 {FUNCTION}, 6 {port}, 30 {device address}, 122 {MAGNETIC3D function}, 0 {X-/Y-/Z-axis}, 247 (F0h, 7Dh, 00h, 08h, 06h, 1Eh, 7Ah, 00h, F7h)

In order to enable the Magnetic3D function to get the magnetic field strength magnitude data from an Magnetic3D sensor with I2C device address 30 (default Magnetic3D I2C device address) connected to the 7th I2C port, the following message is sent:

240, 125, 0 {DEV}, 8 {FUNCTION}, 6 {port}, 30 {device address}, 122 {MAGNETIC3D function}, 0 {X-/Y-/Z-axis}, 247 (F0h, 7Dh, 00h, 08h, 06h, 1Eh, 7Ah, 00h, F7h)

In host mode raw sensor data will be output immediately in I2C DATA messages. In stand-alone mode a suitable configuration has to be set using the EDIT CONFIG command before any MIDI messages will be output.

Other settings of the Magnetic3D sensor can be effectuated by using I2C commands such as I2C WRITE and I2C READ. See also the datasheet linked from the Magnetic3D webpage.