Table of Contents

Advertisement

Quick Links

TRAX2 AHRS & DIGITAL COMPASS
USER MANUAL
Release Date: August 11, 2021

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the TRAX2 AHRS and is the answer not in the manual?

Questions and answers

Summary of Contents for PNI TRAX2 AHRS

  • Page 1 TRAX2 AHRS & DIGITAL COMPASS USER MANUAL Release Date: August 11, 2021...
  • Page 2: Table Of Contents

    Calibration Results ..............29 Test Tab ....................30 Log Data Tab ..................34 Graph Tab .................... 35 System Log Tab ................... 36 7 OPERATION WITH PNI BINARY PROTOCOL ..........37 Datagram Structure ................37 Parameter Formats ................38 PNI Sensor DOC#1032877...
  • Page 3 Switching Functional Mode ............60 7.7.2 FIR Filters ..................61 7.7.3 Power Down/Up ................ 63 Using Multiple Coefficient Sets ............64 Communication Protocol Example ............. 67 APPENDIX – SAMPLE CODE ................68 PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 3...
  • Page 4 Table 7-5: Merge Rate Identifiers ................. 49 Table 7-6: Component Identifiers ................. 52 Table 7-7: Recommended FIR Filter Tap Values ........... 62 Table 7-8: Multiple Coefficient Command List ............. 65 PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 4...
  • Page 5: Copyright & Warranty Information

    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...
  • Page 6: Introduction

    Introduction Thank you for purchasing PNI’s TRAX2 Attitude & Heading Reference System (AHRS) & Digital Compass module. The TRAX2 employs a proprietary Kalman filtering algorithm that intelligently fuses PNI's patented Reference Magnetic Sensors with a 3-axis gyroscope and 3- axis accelerometer. The result is an orientation device that provides accurate heading information under a wide variety of conditions, including its ability to overcome errors normally caused by erratic motion and/or changes in the local magnetic field.
  • Page 7: Specifications

    ≤65° of pitch, and after a Full-Range calibration has been performed. 3. Assumes heading status is “1”. See Section 0 or Section 7.5.3 for a discussion on heading status. PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 3...
  • Page 8: Table 3-2: Absolute Maximum Ratings

    2.3V min. and is guarenteed by design to be 1.87V min (2) Vin on UART Rx is rated at 4V MAX. Higher than 3.6V can cause excessive loading on source. PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021...
  • Page 9: Figure 3-1: Typical Current Drawing During Application Of External Power

    Parameter Value RS232 and TTL-compliant Communication Interface serial UART Communication Protocol PNI Binary Communication Rate 2400 to 921,600 baud ≈30 samples/sec Maximum Data Output Rate Footnote: 1. The TRAX2 can operate up to 921,600 baud, but native RS232 is limited to 115,200 baud.
  • Page 10: Table 3-6: Mechanical Characteristics

    Table 3-6: Mechanical Characteristics Parameter Value Dimensions (l x w x h) 3.5 x 4.3 x 0.84 cm Weight 7 gm Connector 6-pin Molex, part number 51021-0600 PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 6...
  • Page 11: Mechanical Drawings

    3.2 Mechanical Drawings Figure 3-2: TRAX2 PCA Mechanical Drawing Figure 3-3: Molex-to-Pigtail Cable Drawing, pn 14476 CABLE USB TO TTL (FTDI TTL-232R-3V3-WE) Figure 3-4: Molex-to-USB Cable Drawing, pn 14467 PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 7...
  • Page 12: Set-Up

    After making the electrical connections, it is a good idea to perform some simple tests to ensure the TRAX2 is working as expected. See Section 6 for how to operate the TRAX2 with TRAX Studio or Section 7 for how to operate the TRAX2 using PNI’s binary protocol. PNI Sensor...
  • Page 13: Installation Location

    Ensure any stand-offs or screws used to mount the TRAX2 are non-magnetic. Refer to Section 3.2 for dimensions, hole locations, and the reference frame orientation. PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021...
  • Page 14: Pitch And Roll Convention

    The orientation should be programmed in the TRAX2 using the Configuration Tab in TRAX Studio or using the kSetConfig command and the kMountingRef setting in the PNI Protocol, as described in Section 7.4.2. The default orientation is “STD 0°”. PNI Sensor...
  • Page 15: Figure 4-2: Trax2 Enclosed Mounting Orientations

    Figure 4-2: TRAX2 Enclosed Mounting Orientations PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 11...
  • Page 16: User Calibration

    User Calibration The magnetic sensor in the TRAX2 is calibrated at PNI’s factory in a magnetically controlled environment. However, sources of magnetic distortion positioned near the TRAX2 in the user’s system will distort Earth’s magnetic field and should be compensated for in the host system with a user calibration.
  • Page 17 Other Considerations Unlike a digital magnetic compass, such as PNI’s TCM module, the TRAX2 has an AHRS mode that incorporates a gyroscope and as such it can compensate for transient changes in the local magnetic field. However, the TRAX2 will work best if it is kept away from dynamic magnetic fields.
  • Page 18: Table 5-1: Magnetic Calibration Mode Summary

    “Minimum Recommended” value, or greater. Calibration may be performed using TRAX Studio or using the PNI binary protocol, and up to 8 sets of magnetic calibration coefficients may be saved. The recommended calibration patterns described in the following sub-sections provide a good distribution of sample points.
  • Page 19: Full-Range Calibration

    Endianness, north reference, etc. Section 6.5 outlines how to perform a calibration using TRAX2 Studio, while Section 7.6.2 provides a step-by-step example of how to perform a calibration using the PNI protocol. Full-Range Calibration 5.1.1 A Full-Range Calibration is appropriate when the system with the TRAX2 installed can be pitched ±30°...
  • Page 20: Figure 5-1: 12 Point Full-Range Calibration (Realistic View)

    • It is not necessary for the unit to be pointing North to start; however, it may provide better results, especially in high latitudes. PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021...
  • Page 21: Limited-Tilt Calibration

    It provides both hard-iron and soft-iron distortion correction. The recommended 12-point calibration pattern given below is a series of 3 circles of evenly spaced points, with as much tilt variation as expected during use. PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021...
  • Page 22: Table 5-4: 12 Point Limited-Tilt Calibration Pattern

    0° 300° > +5° 0° Second Circle 0° < -5° 0° 60° < -5° 0° 120° < -5° 0° 180° < -5° 0° 240° < -5° 0° < -5° 0° PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 18...
  • Page 23: Hard-Iron-Only Calibration

    The TRAX2 uses a MEMS accelerometer to measure attitude. This data is output as pitch and roll data. The accelerometer data is critical for establishing an accurate heading reading when the TRAX2 is tilted, as discussed in the PNI white paper “Tilt-Induced Heading Error Compass”,...
  • Page 24 PNI for recalibration. PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 20...
  • Page 25: Operation With Trax Studio

    TRAX and TRAX2. Among other features, the program can log and save the outputs from the TRAX2 to a file for off-line evaluation. Anything that can be done using TRAX Studio also can be done using PNI’s binary protocol, as discussed in Section 7.
  • Page 26: Trax Studio Footer And Saving/Applying Settings

    TRAX Studio tabs, then either <Apply> or <Save> must be selected for the change to take effect. Save Clicking the <Save> button will save any changes made in TRAX Studio to the TRAX2’s onboard non-volatile and volatile memory. PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 22...
  • Page 27: Configuration Tab

    For any changes to take effect, the <Save> button must be selected. Clicking on the <Default> button will load the factory default values, although these must be saved to take effect. Clicking the <Retrieve> button will show the current settings of the device. PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021...
  • Page 28: General Settings

    Note that selecting a larger number of taps can significantly slow the time for the initial sample reading and, if “Flush Filters” is selected, the rate at which data is output. The default setting is 32. PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021...
  • Page 29: Acquisition Settings

    Studio requests new data as soon as the previous request is fulfilled. Note that the inverse of the Polling Delay is greater than the sample rate, since the Polling Delay does not include the actual measurement acquisition time. The default is 0. PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021...
  • Page 30: Calibration And The Calibration Tab

    <45°. (i.e. full range calibration is not possible.) Accelerometer – The user should select this when accelerometer calibration will be performed. Accelerometer calibration is recommended every 6 to 12 months to PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021...
  • Page 31 (8) sets of accelerometer calibration coefficients. This feature is useful if the compass will be placed in multiple locations that have different local magnetic field properties. The default is index number 0 and initially this is populated at PNI with factory-generated coefficients for the device itself. The other sets initially are unpopulated.
  • Page 32: Performing A Calibration

    Regardless of whether “Automatic Sampling” is selected, two criteria must be met for a calibration sample to be taken. First, the TRAX2 must be held steady enough to meet PNI-defined stability criteria. Second, the TRAX2’s orientation must have changed enough to meet PNI-defined orientation change criteria.
  • Page 33: Calibration Results

    Full-Range Calibration and Hard-Iron-Only Calibration, this should be ≥45°. For 2D Calibration, this ideally would be ~2°. For Limited-Tilt Calibration the value should be as large as possible given the user’s constraints. PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021...
  • Page 34: Test Tab

    Clicking the Mag Factory Reset and/or Accel Factory Reset will reset the calibration coefficients currently indexed to those established at PNI. For example, if “Mag Coefficient Set 1” is selected as the current set, “Mag Factory Reset” will reset it to factory coefficients.
  • Page 35 The “Output Format” and “North Reference” fields mimic the settings on the Configuration Tab. To change these, return to the Configuration Tab, make the change, then <Apply> or <Save> the change. PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 31...
  • Page 36 Three options are available, Standard, Tight and autoMerge. Standard (Loose) is the default. Please see section 7.4.2 for details. If Gyro Stabilized Compass Configuration is enabled, Settings related to Truth Method is ignored. PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 32...
  • Page 37 • KMergRate = 10 (default value) • KMagRate = 10 (default value) Robot • Magnetic Distortion Rejection AHRS Configuration • kSetMagTruthMethod = Standard (“1”) • KMergRate = 1 • KMagRate = 1 PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 33...
  • Page 38: Log Data Tab

    AHRS mode in which heading is determined by the addition of gyroscope propagated heading. Log Data Tab TRAX Studio can capture measurement data and then export it to a text file. PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 34...
  • Page 39: Graph Tab

    The “User” data and plot (red) provides data after applying the user calibration coefficients. In AHRS Mode the data and plots are identical, while in Compass Mode there is an offset which represents PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021...
  • Page 40: System Log Tab

    The System Log tab shows all communication between TRAX Studio and TRAX2. Closing TRAX Studio will erase the system log. Select the <Export> button, at the bottom right of the screen, to save the system log to a text file. PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021...
  • Page 41: Operation With Pni Binary Protocol

    Operation with PNI Binary Protocol The TRAX2 utilizes a binary communication protocol, where the communication parameters should be configured as follows: Table 7-1: Port Configuration Parameter Value Number of Data Bits Start Bits Stop Bits Parity none 7.1 Datagram Structure...
  • Page 42: Parameter Formats

    Note that for this converter, little Endian values must be manually converted to big Endian. Please refer to the Standard for more information. PNI also recommends referencing the user’s compiler instructions to understand how the compiler implements floating-point.
  • Page 43: Signed Integer

    0=positive and 1=negative. Big Endian Signed 8-Bit Integer (SInt8) UInt8-based parameters are unsigned 8-bit numbers. Bit 7 represents the sign of the value, where 0=positive and 1=negative. byte PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 39...
  • Page 44: Unsigned Integer

    UInt16-based parameters are unsigned 16-bit numbers. Unsigned 8-Bit Integer (UInt8) UInt8-based parameters are unsigned 8-bit numbers. Boolean 7.2.5 Boolean is a 1-byte parameter that MUST have the value 0=FALSE or 1=TRUE. byte PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 40...
  • Page 45: Commands Overview

    Queries for the sensor acquisition parameters 0x1A kSetAcqParamsDone Response to kSetAcqParams 0x1B kGetAcqParamsResp Response to kGetAcqParams 0x1C kPowerDownDone Response to kPowerDown Resets magnetometer calibration coefficients to 0x1D kFactoryMagCoeff original factory-established values PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 41...
  • Page 46: Set-Up Commands

    This frame queries the device's type and firmware revision number. The frame has no payload. kGetModInfoResp (frame ID 2 , 0X02) The response to kGetModInfo is given below. The payload contains the device type identifier followed by the firmware revision number. PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 42...
  • Page 47: Module 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 PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 43...
  • Page 48: Table 7-3: Configuration Identifiers

    12 – 38400 13 – 57600 14 - 115200 kMilOut Boolean True or False False kHPRDuringCal Boolean True or False True kMagCoeffSet UInt32 0 - 7 kAccelCoeffSet UInt32 0 - 7 PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 44...
  • Page 49: Table 7-4: Sample Points

    Calibration Mode Allowable Minimum Range Recommended Full-Range 10 to 18 Limited-Tilt 10 to 18 2D Calibration 10 to 18 Hard-Iron-Only 4 to 18 Accelerometer-Only 12 to 18 Mag-and-Accel 12 to 18 PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 45...
  • Page 50 This frame is the response to kSetConfig frame. The frame has no payload. kGetConfig (frame ID 7 , 0X07) This frame queries the TRAX2 for the current internal configuration value. The payload contains the configuration ID requested. PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 46...
  • Page 51 The “Distortion Mode” is Off by default. The payload is defined below. Payload DistortionMode Payload Value: “0”: Off DistortionMode “1”: On UInt8 PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 47...
  • Page 52 The time constant is square proportional to the time it takes the system to settle, the settle time is proportional to the TC value of the power of 2. ������������ �������� ∝ (����) PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021...
  • Page 53: Table 7-5: Merge Rate Identifiers

    It is recommended to set this to the same value as kMergeRate. kGetMergeRate (frame ID 129 , 0X81) This frame queries the setting of the Mag Truth Method. It has no payload. PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 49...
  • Page 54: Saving Settings

    This frame re-aligns the TRAX2 9-axis heading to the 6-axis (mag and accel) heading and establishes the criteria for the reference magnetic field. The frame should be sent when the user is confident the local magnetic field is not distorted. It has no payload. PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021...
  • Page 55: Data Acquisition Parameters

    32 new samples must be taken before a reading will be output. The length of the delay before outputting data is directly correlated to the number of FIR taps. PNIReserved: These 4 bytes serve no function. PNI recommends populating the bytes with 0. SampleDelay: The SampleDelay is relevant when the Continuous Acquisition Mode is selected.
  • Page 56: Data Components

    0x18 Float32 degrees kRoll 0x19 Float32 degrees kHeadingStatus 0x4F UInt8 value kQuaternion 0x4D 4x Float32 quaternion ˚ Celsius kTemperature 0x07 Float32 0x08 True or False kDistortion Boolean (Default) PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 52...
  • Page 57 & kAccelZ (Component IDs 21 , 22 , 23 These values represent the accelerometer sensor data for the x, y, and z axis, respectively. The values are normalized to g (Earth’s gravitational force). PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 53...
  • Page 58: Making A Measurement

    If heading and heading status are set to be output per the Example: kSetDataComponents command, the payload would look like: Payload 359.9 Heading ID Count Heading ID Heading Heading (Float32) Status ID Status (UInt8) PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 54...
  • Page 59: Continuous Data Output After Power Cycle

    Send the following two commands, Trax2 will stop outputting data after next power cycle. kStopContinuousMode (frame ID 22 This frame commands the TRAX2 to stop data output when in Continuous Acquisition Mode. The frame has no payload. PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 55...
  • Page 60: Calibration Commands

    10° of tilt, but accuracy will not be as good. Hard-Iron-Only Calibration Recalibrates the hard-iron offset for a prior calibration. If the local field hard-iron distortion has changed, this calibration can bring the TRAX2 back into specification. PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 56...
  • Page 61 TRAX2 is ready to take samples. Payload 1 to 18 indicates each point sampled successfully. Payload SampleCount# UInt32 kStopCal (frame ID 11 This command aborts the calibration process. The prior calibration results are retained. PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 57...
  • Page 62: Performing A User Calibration

    The calibration score is automatically sent upon taking the final calibration point. The payload is defined below, and the various payload components are discussed after this. Payload MagCalScore Bytes 5-8 AccelCalScore DistributionError TiltError TiltRange Float32 Float32 Float32 Float32 Float32 Float32 PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 58...
  • Page 63: Factory Calibration

    TRAX2 is close to a source of local magnetic distortion that is not fixed with respect to the device. Bytes 5-8: Reserved for PNI use. AccelCalScore: Represents the over-riding indicator of the quality of the accelerometer calibration.
  • Page 64: Compass Mode Commands

    In this case the TRAX2 operates very similarly to PNI’s TCM electronic compass. There are a couple of reasons it may be desirable to place the TRAX2 in Compass Mode. As previously mentioned, it is necessary to place the TRAX2 in Compass Mode to perform a calibration.
  • Page 65: Fir Filters

    FIR taps to use, which can be 0 (no filtering), 4, 8, 16, or 32. This is followed by the tap values (0 to 32 total Values can be in the payload), with each Value being a Float64, and suggested values given in Table 7-7. PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021...
  • Page 66: Table 7-7: Recommended Fir Filter Tap Values

    01.1484431942626e-1 03.8014333463472e-2 09.5354386848804e-2 04.5402682509802e-2 07.1024151197772e-2 05.2436112653103e-2 04.6451949792704e-2 05.8693165018301e-2 02.5971390034516e-2 06.3781858267530e-2 01.2710056429342e-2 06.7373451424187e-2 07.9724971069144e-3 06.9231186101853e-2 06.9231186101853e-2 06.7373451424187e-2 06.3781858267530e-2 05.8693165018301e-2 05.2436112653103e-2 04.5402682509802e-2 03.8014333463472e-2 03.0686505921968e-2 02.3794805168613e-2 01.7646051430536e-2 01.2456836057785e-2 08.3414139286254e-3 05.3097803863757e-3 03.2757326624196e-3 02.0737124095482e-3 01.4823725958818e-3 PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 62...
  • Page 67: Power Down/Up

    This frame confirms the TRAX2 received a command to power up. (The TRAX2 will power up when it receives any signal on the native UART Rx line.) The frame has no payload. PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021...
  • Page 68: Using Multiple Coefficient Sets

    The ability to store and access multiple calibration coefficients sets the TRAX2 apart from our Prime or legacy TCM. This section will detail the command list and provide two examples for utilizing this functionality. PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021...
  • Page 69: Table 7-8: Multiple Coefficient Command List

    (frame ID) (config ID) (UInt32) 0x07 0x13 0x00 0x06 0x07 0x00 0x0A 0x08 0x13 kAccelCoeffCopySet 0x13 0x09 0x65 0x00 0x00 0x00 0x?? value which is CRC1 CRC2 currently used in TRAX2 PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 65...
  • Page 70 Send kSave command to save the kCoeffCopySet to flash so that it will be still available after power cycle. The kSave command is as following. 0x00 0x05 0x09 0x6E 0xDC PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 66...
  • Page 71: Communication Protocol Example

    00 17 05 04 05 43 b3 df 5e 18 be 88 ed bd 19 3d b5 15 53 4f 03 91 6. Repeat steps 4 and 5 whenever data is desired. PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021...
  • Page 72: Appendix - Sample Code

    // 21 kStopContinuousMode, // 22 kPowerUp, // 23 kSetAcqParams, // 24 kGetAcqParams, // 25 kAcqParamsDone, // 26 kGetAcqParamsResp, // 27 kPowerDoneDown, // 28 kFactoryUserCal, // 29 kFactoryUserCalDone, // 30 PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 68...
  • Page 73 // 10 kMountedYUpPlus90 // 11 kMountedYUpPlus180 // 12 kMountedYUpPlus270 // 13 kMountedZDownPlus90 // 14 kMountedZDownPlus180 // 15 kMountedZDownPlus270 // 16 // Result IDs kErrNone = 0, // 0 kErrSave, // 1 PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 69...
  • Page 74 (unsigned char)(crc >> 8) | (crc << 8); ^= dataPtr[index++]; (unsigned char)(crc & 0xff) >> 4; (crc << 8) << 4; ((crc & 0xff) << 4) << 1; return crc; PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 70...
  • Page 75 SerPort serPort = NULL); void Init(UInt32 baud = 38400); void SendData(UInt8 frame, void dataPtr = NULL, UInt32 len = 0); void SetBaud(UInt32 baud); protected: CommHandler * mHandler; SerPort * mSerialPort; PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 71...
  • Page 76 UInt8 mOutData[kBufferSize], mInData[kBufferSize]; UInt16 mExpectedLen; UInt32 mOutLen, mOldInLen, mTime, mStep; UInt16 CRC(void * data, UInt32 len); void Control(); PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 72...
  • Page 77 & 0xFF; // store the frame ID mOutData[index++] = frameType; // copy the data to be sent while (len--) mOutData[index++] = *data++; // compute and add the crc = CRC(mOutData, index); PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 73...
  • Page 78 // Ticks is a timer function. 1 tick = 10msec. // wait up to 1/2s for the complete frame (mExpectedLen) to be // received mTime = Ticks() + 50; mStep++; PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 74...
  • Page 79 // expecting within 1/2sec of receiving the length bytes. Clear // everything in the input buffer since the data is unreliable mSerialPort->InClear(); mStep = 1; // Look for the next length bytes break; default: break; PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 75...
  • Page 80 * mComm; UInt32 mStep, mTime, mResponseTime; void HandleComm(UInt8 frameType, void dataPtr = NULL, UInt16 dataLen = 0); void SendComm(UInt8 frameType, void dataPtr = NULL, UInt16 dataLen = 0); void Control(); PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 76...
  • Page 81 // read the type and go to the first byte of the data // Only handling the 4 elements we are looking for case CommProtocol::kHeading: // Move(source, destination, size (bytes)). Move copies the PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 77...
  • Page 82 Message("Heading: %f, Pitch: %f, Roll: %f, Temperature: %f\r\n", heading, pitch, roll, temperature); mStep--; // send next data request break; default: // Message is a function that displays a formatted string PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 78...
  • Page 83 // Ticks is a timer function. 1 tick = 10msec. (Ticks() > mResponseTime) Message("No response from the module. Check connection and try again\r\n"); mStep = 0; break; default: PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 79...
  • Page 84 PNI Sensor DOC#1032877 TRAX2 User Manual Aug 2021 Page 80...

Table of Contents