MSHEP0003

User Manual
CompassPoint V2Xe
Electronic 2-Axis Compass Module
Table of Contents
1 COPYRIGHT & WARRANTY INFORMATION ................................................. 1
2 INTRODUCTION ......................................................................................... 2
3 SPECIFICATIONS ......................................................................................... 3
3.1
Performance Specifications .................................................................. 3
3.2
Package Information ............................................................................. 4
4 SET-UP ....................................................................................................... 5
4.1
Electrical Connections ........................................................................... 5
4.2
Mechanical Installation ......................................................................... 6
4.2.1
Mounting Orientation .................................................................. 6
4.2.2
Locate away from changing magnetic fields ............................... 6
4.2.3
Location-verification testing ........................................................ 6
4.3
SPI Hardware Protocol .......................................................................... 6
5 OPERATION WITH V2XE PROTOCOL ........................................................... 8
5.1
Datagram Structure .............................................................................. 8
5.2
Parameter Formats ............................................................................... 9
5.3
Commands & Communication Frames ............................................... 11
5.4
Module Set-Up .................................................................................... 11
5.5
Calibration ........................................................................................... 14
5.6
Making Measurements ....................................................................... 16
List of Tables
Table 3-1:
Table 3-2:
Table 4-1:
Table 5-1:
Table 5-2:
Table 5-3:
Table 5-4:
Absolute Maximum Ratings
Module Characteristics
Pin Descriptions
V2Xe Command Set
Configuration Identifiers
ASIC Period Values
Component Identifiers
3
3
5
11
12
13
17
List of Figures
Figure 3-1: Mechanical Drawing
Figure 4-1: Transfer from Host to V2Xe
Figure 4-2: Transfer from V2Xe to Host
PNI Sensor Corporation
V2Xe User Manual – May 2012
4
7
7
DOC#1017814 r01
Page i
1
Copyright & Warranty Information
© Copyright PNI Sensor Corporation 2012
All Rights Reserved. Reproduction, adaptation, or translation without prior written permission is prohibited, except
as allowed under copyright laws.
Revised May 2012. For most recent version visit our website at www.pnicorp.com
PNI Sensor Corporation
133 Aviation Blvd, Suite 101
Santa Rosa, CA 95403, USA
Tel: (707) 566-2260
Fax: (707) 566-2261
Warranty and Limitation of Liability. PNI Sensor Corporation ("PNI") manufactures its V2Xe products
(“Products”) from parts and components that are new or equivalent to new in performance. PNI warrants that each
Product to be delivered hereunder, if properly used, will, for one year following the date of shipment unless a
different warranty time period for such Product is specified: (i) in PNI’s Price List in effect at time of order
acceptance; or (ii) on PNI’s web site (www.pnicorp.com) at time of order acceptance, be free from defects in
material and workmanship and will operate in accordance with PNI’s published specifications and documentation
for the Product in effect at time of order. PNI will make no changes to the specifications or manufacturing processes
that affect form, fit, or function of the Product without written notice to the OEM, however, PNI may at any time,
without such notice, make minor changes to specifications or manufacturing processes that do not affect the form,
fit, or function of the Product. This warranty will be void if the Products’ serial number, or other identification
marks have been defaced, damaged, or removed. This warranty does not cover wear and tear due to normal use, or
damage to the Product as the result of improper usage, neglect of care, alteration, accident, or unauthorized repair.
THE ABOVE WARRANTY IS IN LIEU OF ANY OTHER WARRANTY, WHETHER EXPRESS, IMPLIED, OR
STATUTORY, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY OF MERCHANTABILITY,
FITNESS FOR ANY PARTICULAR PURPOSE, OR ANY WARRANTY OTHERWISE ARISING OUT OF ANY
PROPOSAL, SPECIFICATION, OR SAMPLE. PNI NEITHER ASSUMES NOR AUTHORIZES ANY PERSON
TO ASSUME FOR IT ANY OTHER LIABILITY.
If any Product furnished hereunder fails to conform to the above warranty, OEM’s sole and exclusive remedy and
PNI’s sole and exclusive liability will be, at PNI’s option, to repair, replace, or credit OEM’s account with an
amount equal to the price paid for any such Product which fails during the applicable warranty period provided that
(i) OEM promptly notifies PNI in writing that such Product is defective and furnishes an explanation of the
deficiency; (ii) such Product is returned to PNI’s service facility at OEM’s risk and expense; and (iii) PNI is satisfied
that claimed deficiencies exist and were not caused by accident, misuse, neglect, alteration, repair, improper
installation, or improper testing. If a Product is defective, transportation charges for the return of the Product to
OEM within the United States and Canada will be paid by PNI. For all other locations, the warranty excludes all
costs of shipping, customs clearance, and other related charges. PNI will have a reasonable time to make repairs or
to replace the Product or to credit OEM’s account. PNI warrants any such repaired or replacement Product to be
free from defects in material and workmanship on the same terms as the Product originally purchased.
Except for the breach of warranty remedies set forth herein, or for personal injury, PNI shall have no liability for any
indirect or speculative damages (including, but not limited to, consequential, incidental, punitive and special
damages) relating to the use of or inability to use this Product, whether arising out of contract, negligence, tort, or
under any warranty theory, or for infringement of any other party’s intellectual property rights, irrespective of
whether PNI had advance notice of the possibility of any such damages, including, but not limited to, loss of use,
revenue or profit. In no event shall PNI’s total liability for all claims regarding a Product exceed the price paid for
the Product. PNI neither assumes nor authorizes any person to assume for it any other liabilities.
Some states and provinces do not allow limitations on how long an implied warranty lasts or the exclusion or
limitation of incidental or consequential damages, so the above limitations or exclusions may not apply to you. This
warranty gives you specific legal rights and you may have other rights that vary by state or province.
PNI Sensor Corporation
V2Xe User Manual – May 2012
DOC#1017814 r01
Page 1
2
Introduction
Thank you for purchasing PNI Sensor Corporation’s CompassPoint V2Xe (pn 11862). This
RoHS-compliant, low-power-consumption, 2-axis compass module, provides all-digital compass
heading outputs accurate to 1°. The V2Xe provides low power consumption, a small footprint,
large signal noise immunity under all conditions, and a large magnetic field dynamic range. And
measurement data is very stable over temperature and inherently free from offset drift.
The CompassPoint V2Xe allows designers to bypass the time and expense required to build a 2axis digital compass from scratch. Features include:
an onboard microprocessor for true plug-and-play compassing and magnetic field
sensing,
a SPI interface,
3 V operation,
software configurable resolution and field measurement range,
the ability to calibrate the device to account for local magnetic fields, and
non-volatile memory that retains calibration data after being powered down.
These advantages make the CompassPoint V2Xe the choice for compassing applications that
require a high degree of azimuth accuracy, low power consumption, and/or a small package size.
The V2Xe has proven itself in a variety of applications, including
seismic monitoring,
range finding and binocular systems,
wind direction sensing, and
robotic navigation.
V2Xe User Manual – May 2012
Page 2
3
Specifications
3.1
Performance Specifications
Table 3-1: Absolute Maximum Ratings
Parameter
Minimum
Maximum
Units
-0.3
4.1
VDC
Input Pin Voltage (VIN)
VDD – 0.3
VDD + 0.3
VDC
Input Pin Current (IIN)
-2.0
+2.0
mA
Storage Temperature
-40
+85
C
DC Supply Voltage (VDD)
CAUTION:
Stresses beyond those listed above may cause permanent damage to the device. These are stress
ratings only. Assuming operation with the 3D MagIC ASIC per the guidelines in this manual,
these maximum ratings will not be violated.
Table 3-2: Module Characteristics1
Parameter
Minimum
Maximum
Supply Voltage (VDD)
Idle Current
3.0 VDC
2
0.2 mA
Continuous Current
3
2.0 mA
SCLK frequency
3.6864 MHz
Low-level input
GND
GND + 0.6 VDC
High-level input
0.8 x VDD
VDD
Low-level output
GND
GND + 0.25 VDC
High-level output
VDD – 0.25 VDC
VDD
Operating Temperature
-20 ºC
70 ºC
Storage Temperature
-40 ºC
85 ºC
Weight
3 gm
Field Measurement Range
4
-1100 µT
+1100 µT
5
Magnetometer
Mode
Characteristics
Gain
32 counts/µT
Resolution
6
Linearity
1/gain
1%
Sensor Frequency
Compass Mode
Characteristics
Typical
7
Accuracy
Resolution
PNI Sensor Corporation
V2Xe User Manual – May 2012
0.6%
175 kHz
2° rms
1° rms
0.01°
DOC#1017814 r01
Page 3
Footnotes:
1. Characteristics are subject to change. Values assume supply voltage of 3 VDC.
2. Measurement taken with no sensor activity
3. Measurement taken during continuous polling of sensors
4. Field measurement range is defined a the monotonic region of the output characteristic curve
5. Gain is defined as the change in the number of counts from the ASIC when the period select is set
to 2048, per change in the magnetic field in µT. For situations requiring higher gain and less field
measurement range, the gain and resolution can be increased by a factor of 2 by setting the ASIC
period select to 4096. When setting higher selects, be aware that the ASIC counter can overflow if
the field is strong enough to drive the count beyond a signed 16-bit integer. Period select set to 2048
is the highest setting where it is impossible to overflow the counter.
6. Resolution is 1/gain to the noise limit.
7. Requires that a field calibration be performed. In practical compass applications, a calibration is
normally performed when the compass module is in the host system.
3.2
Package Information
Dimensions in mm
The default orientation is for the silk-screened arrow to point in the “forward” direction.
Figure 3-1: Mechanical Drawing
V2Xe User Manual – May 2012
Page 4
4
Set-Up
4.1
Electrical Connections
The V2Xe incorporates two 7-pin SIP connectors. The pin-out is given below in Table 4-1,
where pin #1 and pin #14 are defined in the mechanical drawing (Figure 3-1).
Table 4-1: Pin Descriptions
Pin #
Pin Name Description
1
SCLK
Serial Clock input for SPI port
2
MISO
Master In, Slave Out for the Module SPI port
3
MOSI
Master Out, Slave In for the Module SPI port
4
SSN
Slave Select for the V2Xe’s SPI port. SSN must remain low until the
command response is clocked out.
5
GIO4
Reserved I/O. Do not connect.
6
SYNC
The SYNC line is not needed except in cases where the V2Xe gets out of
synchronization with the host. Synchronization issues primarily occur
during power-up when I/O and hardware are initialized. This may cause
glitches in the clock line, which can be interpreted by the V2Xe as clock
cycles. A rising edge on the V2Xe SYNC line resets the V2Xe’s SPI and
communication buffers. The SYNC line is asynchronous with respect to
the SPI, so proper care in its implementation is mandatory. Contact PNI if
you are experiencing synchronization issues.
7
GND
Ground
8
GIO0
Reserved I/O. Do not connect.
9
GIO1
Reserved I/O. Do not connect.
10
GIO2
Reserved I/O. Do not connect.
11
GIO3
Reserved I/O. Do not connect.
12
VDD
13
---
14
GND
3V regulated supply voltage
Not connected
Ground
After making the electrical connections, it is a good idea to perform some simple tests to
ensure the V2Xe is working as expected. See Section 5 for how to operate the V2Xe using
the V2Xe binary protocol.
PNI Sensor Corporation
V2Xe User Manual – May 2012
DOC#1017814 r01
Page 5
4.2
4.2.1
Mechanical Installation
Mounting Orientation
The V2Xe should be mounted horizontally and as level as possible. The arrow on the top
of the board should point in the direction of travel or line of sight.
4.2.2
Locate away from changing magnetic fields
It is not possible to calibrate for changing magnetic anomalies. Thus, for greatest
accuracy, keep the V2Xe away from sources of local magnetic distortion that will change
with time; such as electrical equipment that will be turned on and off, or ferrous bodies
that will move. Make sure the V2Xe is not mounted close to cargo or payload areas that
may be loaded with large sources of local magnetic fields.
4.2.3
Location-verification testing
Location-verification testing should be performed at an early stage of development to
understand and accommodate the magnetic distortion contributors in a host system.
Place the compass in a fixed position, then move or energize suspect components while
observing the output to determine when they are an influence.
4.3
SPI Hardware Protocol
The V2Xe is a slave SPI device. The host must supply the required eight clock pulses to
transfer a byte to and from the V2Xe. In addition a “Slave Select” (SSN) line must be held
low prior to any transmission.
The V2Xe assumes the clock polarity to be zero (CPOL=0) which means the clock idles low.
The clocking phase is shown in the diagram below, where CHPA = 0.
The V2Xe samples the “Master-Out-Slave-In” (MOSI) line during the rising edge of the
clock and on the falling edge of the clock, the “Master-In-Slave-Out” (MISO) will have the
next valid bit value.
The V2Xe communicates in half duplex mode. When the V2Xe is in receive mode (waiting
for valid bytes), it will transmit a zero-byte (0x00) while receiving bytes. During
transmission (response frames), the V2Xe will ignore the MOSI line but it is recommended
that the host transmit zero-bytes while receiving.
V2Xe User Manual – May 2012
Page 6
SSN
*Tri-state when SSN is HIGH.
Figure 4-1: Transfer from Host to V2Xe
SSN
*Transmit zero-byte (recommended)
**Tri-state when SSN is HIGH.
Figure 4-2: Transfer from V2Xe to Host
The nature of the SPI interface is such that the host receives the bytes synchronously while
sending bytes. Therefore the V2Xe will send a byte containing 0x00 for every byte received.
The V2Xe itself will ignore any bytes received while it is sending a response. When the host
keeps clocking the SPI interface after the V2Xe has completed sending a response, the V2Xe
will keep sending 0x00 for each byte clocked out. In effect, the connection is made to act
like a half duplex connection. The host sends a request and the V2Xe responds (if
applicable).
The V2Xe has a built-in transmit response timeout. If the host sends a query command to the
V2Xe, the host needs to clock in the response within 0.5 seconds. The V2Xe will flush the
response after the 0.5 second timeout to accommodate new commands.
PNI Sensor Corporation
V2Xe User Manual – May 2012
DOC#1017814 r01
Page 7
5
Operation with V2Xe Protocol
The following section describes the data structure and the commands used to communicate with
the V2Xe over its SPI interface.
5.1
Datagram Structure
The datagram structure for a basic message is given below:
Sync Flag
0xAA
Frame Type
0xXX
Terminator
0x00
Byte 1
Byte 2
Byte 3
Example: the command for kStartCal would be as specified below.
Sync Flag
0xAA
Frame Type
0x0A
Terminator
0x00
Byte 1
Byte 2
(kStartCal)
Byte 3
The datagram for a message with data is given below. This is a variable length message
depending on the number of parameters.
Sync Flag
0xAA
Frame Type
0xXX
Optional Data Field
0xXX, 0xXX,…
Terminator
0x00
Byte 1
Byte 2
Byte 3
Byte 4
Example: the command for kSetDataComponents with parameters kHeading and
kMagnitude is specified below.
Sync Flag
0xAA
Frame Type
0x03
Param Count
0x02
Param 1
0x05
Param 2
0x06
Terminator
0x00
Byte 1
Byte 2
(kSetData
Components)
Byte 3
Byte 4
(kHeading)
Byte 5
(kMagnitude)
Byte 6
V2Xe User Manual – May 2012
Page 8
5.2
Parameter Formats
Note: Floating-point based parameters conform to ANSI/IEEE Std 754-1985. Please refer to the
Standard for more information. PNI also recommends the user refer to the compiler’s instructions to
understand how the compiler implements floating-point format.
32 Bit Floating Point (Float32)
Shown below is the 32 bit float format in big Endian. In little Endian format, the 4
bytes are in reverse order (LSB first).
3130
S
23 22
0
Exponent
Mantissa
The value (v) is determined as, if and only if 0 < Exponent < 255): v = (-1)S *
2(Exponent-127) * 1.Mantissa. Zero is represented by 4 bytes of zeros.
Signed 32 Bit Integer (SInt32)
SInt32-based parameters are signed 32 bit numbers (2’s compliment).
represents the sign of the value (0=positive, 1=negative)
31
24 23
16 15
8 7
msb
Bit 31
0
lsb
Big Endian
7
0 15
8 23
16 31
lsb
24
msb
Little Endian
Signed 16 Bit Integer (SInt16)
SInt16-based parameters are signed 16 bit numbers (2’s compliment).
represents the sign of the value (0=positive, 1=negative)
15
8 7
msb
0
lsb
Big Endian
PNI Sensor Corporation
V2Xe User Manual – May 2012
7
0 15
lsb
Bit 15
8
msb
Little Endian
DOC#1017814 r01
Page 9
Signed 8 Bit Integer (SInt8)
UInt8-based parameters are unsigned 8-bit numbers. Bit 7 represents the sign of the
value (0=positive, 1=negative)
7
0
byte
Unsigned 32 Bit Integer (UInt32)
UInt32-based parameters are unsigned 32 bit numbers.
31
24 23
16 15
8 7
msb
0
lsb
Big Endian
7
0 15
8 23
16 31
lsb
24
msb
Little Endian
Unsigned 16 Bit Integer (UInt16)
UInt16-based parameters are unsigned 16 bit numbers.
15
8 7
msb
0
lsb
7
0 15
lsb
Big Endian
8
msb
Little Endian
Unsigned 8 Bit Integer (UInt8)
UInt8-based parameters are unsigned 8-bit numbers.
7
0
byte
Boolean
Boolean is a 1-byte parameter that MUST have the value 0 (FALSE) or 1 (TRUE).
7
0
byte
V2Xe User Manual – May 2012
Page 10
FourCharCode
FourCharCode is a four-byte parameter.
7
0 7
ASCII Char 1
5.3
07
ASCII Char 2
07
ASCII Char 3
0
ASCII Char 4
Commands & Communication Frames
Table 5-1: V2Xe Command Set
Frame
ID
Command
Description
Set Up
0x01
kGetModInfo
Queries the device’s type and firmware revision.
0x02
kGetModInfoResp
Response to kGetModInfo
0x06
kSetConfig
Sets internal configurations in V2Xe
0x07
kGetConfig
Queries V2Xe for the current internal configuration
0x08
kGetConfigResp
Response to kGetConfig
0x09
kSave
Saves the current internal configuration and any new
user calibration coefficients to non-volatile memory.
Calibration
0x0A
kStartCal
Commands the V2Xe to start user calibration
0x0B
kStopCal
Commands the V2Xe to stop user calibration
0x0C
kGetCalData
Queries for the calibration coefficients
0x0D
kGetCalDataResp
Provides the calibration coefficients
0x0E
kSetCalData
Allows the user to write the calibration coefficients.
0x03
kSetDataComponents
Sets the data components to be output.
0x04
kGetData
Queries the V2Xe for data
0x05
kGetDataResp
Response to kGetData
Operation
5.4
Module Set-Up
kGetModInfo (frame ID 0x01)
This frame queries the device's type and firmware revision number. The frame has no
payload.
PNI Sensor Corporation
V2Xe User Manual – May 2012
DOC#1017814 r01
Page 11
kGetModInfoResp (frame ID 0x02)
The response to kGetModInfo is given below. The payload contains the device type
identifier followed by the firmware revision number.
Payload
Type
Revision
FourCharCode
FourCharCode
kSetConfig (frame ID 0x06)
This frame sets internal configurations in the V2Xe. The first byte of the payload is
the configuration ID followed by a format-specific value. These configurations can
only be set one at time. To save these in non-volatile memory, the kSave command
must be issued.
Payload
Config ID
Value
UInt8
ID Specific
Example: To configure the declination, the payload would look like:
Payload
0x01
10.0
Declination ID
Declination
Degrees (Float32)
Table 5-2: Configuration Identifiers
Parameter
Config. ID
Format
Values / Range
Default
kDeclination
0x01
Float32
-180˚ to +180˚
0
kTrueNorth
0x02
Boolean
True or False
False
kCalSampleFreq
0x03
UInt8
1 to 8 (Hz)
8
kSampleFreq
0x04
UInt8
0 to 8 (Hz)
0
kPeriod
0x05
UInt8
1 to 8
5
kBigEndian
0x06
Boolean
True or False
True
kDampingSize
0x07
UInt8
1 to 8
1
Configuration parameters and settings for kSetConfig:
V2Xe User Manual – May 2012
Page 12
kDeclination (Config. ID 0x01)
This sets the declination angle to determine True North heading. Positive
declination is easterly declination and negative is westerly declination. This is not
applied unless kTrueNorth is set to TRUE.
kTrueNorth (Config. ID 0x02)
Flag to set compass heading output to true north heading by adding the
declination angle to the magnetic north heading.
kCalSampleFreq (Config. ID 0x03)
This sets the sampling frequency during calibration.
kSampleFreq (Config. ID 0x04)
This sets the sampling frequency when damping is enabled. If this is greater than
0 Hz, then the last calculated heading is returned when a heading query command
is received from the host. If kSampleFreq is set to 0 Hz, then X and Y counts are
sampled and the heading calculated after a query is received.
kPeriod (Config. ID 0x05)
This sets the period or number of sensor circuit oscillation cycles (cycle counts) to
be counted while simultaneously using the internal fixed reference clock to
measure the time to obtain this count, as defined in Table 5-3.
Table 5-3: ASIC Period Values
Period Select
Value
Cycle Counts
1
32
2
64
3
128
4
256
5
512 (default)
6
1024
7
2048
8
4096
(1/Period)
kBigEndian (Config. ID 0x06)
Sets the Endianness of packets. TRUE is Big Endian. FALSE is Little Endian.
kDampingSize (Config. ID 0x07)
kDampingSize indicates the number of heading samples to be averaged, and then
returned as the heading reading. When damping is enabled and a value (n = 1 to
8) for the damping range is selected, the V2Xe will perform a simple average of
PNI Sensor Corporation
V2Xe User Manual – May 2012
DOC#1017814 r01
Page 13
the “n” number elements. Damping is only applied to the heading data. This is
not a running average but instead an average of the most recent “n” number with
the oldest being dropped in each successive heading calculation.
kGetConfig (frame ID 0x07)
This frame queries the TCM for the current internal configuration value. The payload
contains the configuration ID requested.
Payload
Config ID
UInt8
kGetConfigResp (frame ID 0x08)
The response to kGetConfig is given below. The payload contains the configuration
ID and value.
Payload
Config ID
Value
UInt8
ID Specific
Example: The payload for a request to get the declination angle would look like:
Payload
0x01
10.0
Declination ID
Declination
Degrees (Float32)
kSave (frame ID 0x09)
This frame commands the V2Xe to save internal configurations and user calibration
to non-volatile memory. Internal configurations and user calibration are restored on
power up. The frame has no payload. This is the ONLY command that causes the
device to save information to non-volatile memory.
5.5 Calibration
Sources of magnetic distortion permanently positioned near the V2Xe in the user’s system
will distort Earth’s magnetic field and should be compensated for with a user calibration.
Examples of such sources include ferrous metals and alloys (ex. iron, nickel, steel, etc.),
batteries, audio speakers, current-carrying wires, and electric motors. It is expected the
sources of magnetic distortion remain fixed relative to the V2Xe’s position within the host
system.
V2Xe User Manual – May 2012
Page 14
By performing a calibration, the V2Xe identifies local sources of distortion and negates their
effects from the overall reading to provide an accurate heading. For more on magnetic
distortion and calibration, see PNI’s white paper “Local Magnetic Distortion Effects on 3Axis Compassing” at PNI’s website (http://www.pnicorp.com/technology/papers).
Follow the steps below to perform a calibration:
Mount the V2Xe in the host system in its operating position and as level as possible.
Set the period select value (kPeriod) to 4 or higher using kSetConfig.
Send the kStartCal command.
Rotate the unit through two 360º circles while maintaining a level position. The
rotations should be no faster than 30 seconds each.
Send the kStopCal command.
Send the kSaveConfig command to save the calibration data to the V2Xe.
When the V2Xe modules is not calibrated, or the calibration did not allow for valid samples,
the reported heading will be -1.00 degree.
kStartCal (frame ID 0x0A)
This frame commands the module to start a user field calibration. The calibration
sampling frequency is set with the kCalSampleFreq identifier in the kSetConfig
command. To query raw X & Y counts during calibration, make sure to send
kSetDataComponents with XRaw & YRaw as requested data components prior to
calibration and then send kGetData at a proper interval to get calibration output. This
command has no parameters.
kStopCal (frame ID 0x0B)
This command stops the V2Xe calibration process, and the calibration coefficients are
calculated. However, the calibration data is not saved until the V2Xe receives the
kSaveConfig command. This command has no parameters.
kGetCalData (frame ID 0x0C)
This command queries the V2Xe for its calibration data. The V2Xe will respond with
the frame kCalDataResp. The command has no parameters.
kCalDataResp (frame ID 0x0D)
kCalDataResp is the response to kGetCalData. It contains the calibration data. The
structure looks like:
Payload
Byte Count
X Offset
X Offset
X Gain
Y Gain
Phi
Cal Magnitude
UInt8
SInt32
SInt32
SInt32
SInt32
Float32
Float32
PNI Sensor Corporation
V2Xe User Manual – May 2012
DOC#1017814 r01
Page 15
kSetCalData (frame ID 0x0E)
This frame writes calibration data into the V2Xe using the same frame structure as
kCalDataResp. This is an optional command and is not used for most applications.
However, it allows the user to store multiple sets of calibration coefficients on the
host system, and write them into the V2Xe when appropriate. For example, if the
host system has a motor that sometimes is off and sometimes on, then one set of
calibration coefficients can be generated and stored in the host system for when the
motor is on, and a second set for when the motor is off. The first set of calibration
coefficients would be written to the V2Xe whenever taking a reading with the motor
on, and the second set whenever the motor is off.
5.6
Making Measurements
To make a measurement, it is first necessary to establish what data is to be output by sending
the kSetDataComponents frame. The kGetData command is sent to initiate a measurement,
and the response will be the kGetDataResp frame which will contain the measured data, as
established by kSetDataComponents.
kSetDataComponents (frame ID 0x03)
This frame defines what data is output when kGetData is sent. Table 5-4 summarizes
the various data components and more detail follows this table. The first byte of the
payload indicates the number of data components followed by the data component
IDs.
Payload
ID Count
ID 1
ID 2
ID 3
UInt8
UInt8
UInt8
UInt8
……….
Example: To query for heading and magnitude, the payload should contain:
Payload
0x02
0x05
0x06
ID Count
Heading ID
Magnitude ID
Note that the sequence of the data components defined by kSetDataComponents will
match the output sequence of kGetDataResp.
V2Xe User Manual – May 2012
Page 16
Table 5-4: Component Identifiers
Component
Component ID
Format
Units
kXRaw
0x01
SInt32
counts
kYRaw
0x02
Sint32
counts
kXCal
0x03
Float32
scaled to 1.0
kYCal
0x04
Float32
scaled to 1.0
kHeading
0x05
Float32
degrees
kMagnitude
0x06
Float32
scaled to 1.0
kTemperature
0x07
Float32
°C
kDistortion
0x08
Boolean
True or False
kCalStatus
0x09
Boolean
True or False
Component types are listed below. All are read-only values.
kXRaw & kYRaw (Component IDs 1d & 2d)
These values are the raw sensor counts as read from the ASIC registers.
kXCal & kYCal (Component IDs 3d & 4d)
These are the X and Y components of the magnetic vector after the calibration
coefficients have been applied to the raw values. Their values are used to
calculate the heading.
kHeading (Component ID 5d)
Provides compass heading calculated from kXCal and kYCal, where the heading
range is 0.0˚ to +359.9. kHeading will equal -1.00 if kCalStatus is True.
kMagnitude (Component ID 0x06)
The value is calculated using the formula Magnitude = SQRT (XCal2 + YCal2).
Its value is compared to the calibration magnitude to determine distortion.
kTemperature (Component ID 0x07)
The V2Xe’s internal temperature sensor provides the temperature value, in °C.
kDistortion (Component ID 0x08)
This flag indicates if the magnitude of the vector used to calculate the heading is
below 50% or above 150% of the calibration magnitude.
kCalStatus (Component ID 0x09)
This flag indicates the user calibration status. True means it is not user calibrated
and this is the default value.
kGetData (frame ID 0x04)
This frame queries the V2Xe for data. The frame has no payload. The response is
kGetDataResp.
PNI Sensor Corporation
V2Xe User Manual – May 2012
DOC#1017814 r01
Page 17
After a request for data is sent, a time delay is required for processing and sampling.
The time delay required is relative to the period select value being used and is also
influenced by the strength of field being measured. With a period select value of 8
(/4096), a delay of approximately 50 msec is required. The delay proportionately
decreases with decreasing period select value.
The kGetData sequence should be:
Send kGetData.
Delay.
Push 1 byte out of V2Xe module.
Test the response byte for 0xAA (Sync Flag). If True, push data out. If False,
loop on delay.
kGetDataResp (frame ID 0x05)
The response to kGetData is kGetDataResp. The specific data fields that will be
output (ID 1, Value ID 1, etc.) should have been previously established by the
kSetDataComponents command frame. The sequence of the output data components
will match that set by kSetDataComponents.
Payload
ID Count
UInt8
ID 1
Value ID 1
ID 2
Value ID 2
ID 3
Value ID 3
UInt8
ID Specific
UInt8
ID Specific
UInt8
ID Specific
Example: If heading and magnitude are set to be output per the kSetDataComponents
command, the payload would look like:
Payload
0x02
0x05
359.9
0x06
0.50
ID Count
Heading ID
Heading Value
(Float32)
Magnitude
ID
Magnitude
Value (Float32)
V2Xe User Manual – May 2012
Page 18