REXGEN 2REXGEN 2 IMU GNSSREXGEN AirREXGEN ProDeveloper

REXGEN XML examples: GNSS, IMU, analogue and RTC data onto CAN

Updated

Load a ready-made configuration that puts the logger's GNSS position, IMU motion, analogue inputs or clock onto a CAN bus. Then adjust the channel, bit rate, identifiers and rates to suit.

Before you start

Each example is an XML file with a matching DBC file in the Rexgen_XML_Examples repository on GitHub. Every file validates against the schema. Use them to feed live position or motion to a CAN dashboard or instrument cluster. You can also use the logger as a GNSS or IMU module for another CAN data logger.

  • A model with the source. GNSS and IMU need REXGEN 2 IMU GNSS, REXGEN Air or REXGEN Pro. Analogue inputs need REXGEN 2, REXGEN 2 IMU GNSS, REXGEN Air or REXGEN Pro. The clock example runs on any of these.
  • REXDESK, to load the file. See REXGEN XML configuration: how it fits together.
  • A CAN tool that reads DBC files, to check the output on the bus.

Every example sends on CAN 0 at 500 kbit/s. The "with recording" version of each file adds a recorder. It records every output message and source to internal storage from power-on, in files of up to 100 MiB or one hour. It also streams the same data to REXDESK over USB.

Change the channel, bit rate, identifiers and rates

The same edits apply to every example. Open the file in a text editor, change the value and load it again.

CAN channel
PhysicalNumber in the CANINTERFACE: 0 for CAN 0, 1 for CAN 1, up to the channels your model has. See REXGEN XML reference: CAN interfaces and bit timing.
Bit rate
CANBusSpeed in the CANINTERFACE, in bit/s.
Identifier
MessageIdentStart and MessageIdentEnd in the CANMESSAGE, both set to the new identifier in decimal. Change the DBC file to match, or it no longer decodes the message.
Transmission period
Period in the CANMESSAGE, in milliseconds.
Sampling rate
SamplingRate in the GNSSINTERFACE, ACCELEROMETER, GYRO or INTERNAL_PARAMETER, or Rate in the ADC, in milliseconds.
IMU range
RangeHi and RangeLow in each ACCELEROMETER (g) and GYRO block, not SamplingRate.
Log file size and length
MaxLogSize (bytes) and MaxLogTime (seconds) in the SDINTERFACE of the "with recording" files.

This is the first GNSS message, 299 (12B hex), sent every 100 ms on the interface with UID 4:

<CANMESSAGE UID="20">
<MessageIdentStart>299</MessageIdentStart>
<MessageIdentEnd>299</MessageIdentEnd>
<Direction>OutputPeriodic</Direction>
<DLC>8</DLC>
<IsExtended>false</IsExtended>
<InterfaceUID>4</InterfaceUID>
<Period>100</Period>
<TriggeringMessageUniqueID>0</TriggeringMessageUniqueID>
<DefaultHex>0000000000000000</DefaultHex>
<CANFD_Option>NORMAL_CAN</CANFD_Option>
<InputMessageUID>0</InputMessageUID>
<Name/>
<isJ1939>false</isJ1939>
<J1939Source>0</J1939Source>
<J1939Destination>0</J1939Destination>
<Downsampling>0</Downsampling>
<Delay>0</Delay>
<NextOutputMessageID>0</NextOutputMessageID>
</CANMESSAGE>

GNSS position to CAN

This example runs on REXGEN 2 IMU GNSS, REXGEN Air and REXGEN Pro. The logger reads the receiver every 100 ms and sends five messages every 100 ms. All signals are little-endian (Intel).

GNSS to CAN: identifiers and signals
Identifier Bits 0 to 31 Bits 32 to 63
299 (12B hex) Altitude Speed over ground (bits 32 to 47)
300 (12C hex) Longitude Latitude
301 (12D hex) Date and time Ground distance
302 (12E hex) Course over ground Number of satellites
303 (12F hex) Fix quality Not used

A CANSIGNAL writes each GNSSMESSAGE value into its message. Altitude, for example, goes into a signed 32-bit field scaled by 0.01:

<CANSIGNAL UID="22">
<InputType>COMMON</InputType>
<InputUID>13</InputUID>
<MessageUID>20</MessageUID>
<StartBit>0</StartBit>
<BitCount>32</BitCount>
<Endian>INTEL</Endian>
<DefaultValue>0</DefaultValue>
<ParA>0.01</ParA>
<ParB>0</ParB>
<SignalType>SIGNED</SignalType>
<Name>Altitude</Name>
</CANSIGNAL>
GNSS2CAN_Only.xml, block by block REXGEN XML · GNSS TO CAN EXAMPLE GNSS2CAN_Only.xml, block by block GNSSINTERFACE the receiver GNSSMESSAGE one per value, by Type CANSIGNAL writes a value into a message CANMESSAGE OutputPeriodic, every 100 ms CANINTERFACE the CAN port InterfaceUID InputUID MessageUID InterfaceUID UID 8 read every 100 ms UID 4 CAN 0 500 kbit/s UID 13 ALTITUDE UID 22 bits 0 to 31 UID 14 SPEED_OVER_GROUND UID 25 bits 32 to 47 UID 20 ID 299, 12B hex UID 11 LONGITUDE UID 29 bits 0 to 31 UID 12 LATITUDE UID 32 bits 32 to 63 UID 27 ID 300, 12C hex UID 10 DATETIME UID 40 bits 0 to 31 UID 19 GROUND_DISTANCE UID 36 bits 32 to 63 UID 34 ID 301, 12D hex UID 15 COURSE_OVER_GROUND UID 43 bits 0 to 31 UID 17 NUMBER_SATELLITES UID 47 bits 32 to 63 UID 38 ID 302, 12E hex UID 16 QUALITY UID 51 bits 0 to 31 UID 45 ID 303, 12F hex With recording, GNSS2CAN_SD.xml adds SDMESSAGE one per CAN message and per GNSS value InputMessageUID names what it records SDINTERFACE 2 internal storage USBMESSAGE the same messages and values InputUID names what it streams USBINTERFACE 3 live data to REXDESK Each arrow is a link by UID, made by the field printed above its column of arrows. All signals are little-endian (INTEL). The file also defines GNSS_TIMESTAMP (UID 9) and GEOID_SEPARATION (UID 18), which are not sent on CAN. Dashed: the blocks the recording version adds; it also renumbers the CAN messages 20, 28, 36, 44 and 52.

The files are GNSS2CAN_Only.xml and ReXgen_IMU_Out_V3.dbc in the GNSS_to_CAN folder.

GNSS to CAN with recording

GNSS2CAN_SD.xml sends the same five messages and streams them over USB. It also records them with all eleven GNSS values in the file, including the GNSS timestamp and geoid separation, which are not sent on CAN. The files are in the GNSS_to_CAN_SD folder.

IMU motion to CAN

This example runs on REXGEN 2 IMU GNSS, REXGEN Air and REXGEN Pro. The logger samples each axis every 100 ms (10 Hz) and sends two messages every 100 ms. The accelerometer uses the ±16 g range and the gyroscope a ±500 range.

IMU to CAN: identifiers and signals
Identifier Bits 0 to 15 Bits 16 to 31 Bits 32 to 47 Factor
296 (128 hex) AccelX AccelY AccelZ 0.001
297 (129 hex) GyroX GyroY GyroZ 0.01

All six signals are signed, little-endian and 16 bits long. One ACCELEROMETER or GYRO block for each axis feeds one signal:

<ACCELEROMETER UID="8">
<PhysicalNumber>0</PhysicalNumber>
<Axis>X</Axis>
<SamplingRate>100</SamplingRate>
<RangeHi>16</RangeHi>
<RangeLow>-16</RangeLow>
</ACCELEROMETER>
<CANSIGNAL UID="16">
<InputType>COMMON</InputType>
<InputUID>8</InputUID>
<MessageUID>14</MessageUID>
<StartBit>0</StartBit>
<BitCount>16</BitCount>
<Endian>INTEL</Endian>
<DefaultValue>0</DefaultValue>
<ParA>0.001</ParA>
<ParB>0</ParB>
<SignalType>SIGNED</SignalType>
<Name>AccelX</Name>
</CANSIGNAL>

The accelerometer ranges on REXGEN 2 IMU GNSS are ±2, ±4, ±8 and ±16 g.

IMU2CAN.xml, block by block REXGEN XML · IMU TO CAN EXAMPLE IMU2CAN.xml, block by block ACCELEROMETER, GYRO one block per axis, every 100 ms CANSIGNAL writes a value into a message CANMESSAGE OutputPeriodic, every 100 ms CANINTERFACE the CAN port InputUID MessageUID InterfaceUID UID 4 CAN 0 500 kbit/s UID 8 ACCELEROMETER axis X UID 16 AccelX, bits 0 to 15 UID 9 ACCELEROMETER axis Y UID 17 AccelY, bits 16 to 31 UID 10 ACCELEROMETER axis Z UID 18 AccelZ, bits 32 to 47 UID 14 ID 296, 128 hex UID 11 GYRO axis X UID 19 GyroX, bits 0 to 15 UID 12 GYRO axis Y UID 20 GyroY, bits 16 to 31 UID 13 GYRO axis Z UID 21 GyroZ, bits 32 to 47 UID 15 ID 297, 129 hex With recording, IMU_out_SD.xml adds SDMESSAGE the two CAN messages and the six axes InputMessageUID names what it records SDINTERFACE 2 internal storage USBMESSAGE the same messages and axes InputUID names what it streams USBINTERFACE 3 live data to REXDESK Each arrow is a link by UID, made by the field printed above its column of arrows. All six signals are signed, little-endian (INTEL) and 16 bits long. Dashed: the blocks the recording version adds; it numbers the second message 25 instead of 15, so do not mix blocks from the two files.

The files are IMU2CAN.xml and ReXgen_IMU_Out_V3.dbc in the IMU_to_CAN folder.

IMU to CAN with recording

IMU_out_SD.xml sends the same two messages and streams them over USB. It also records them and the six axes. Its UIDs differ from IMU2CAN.xml, so do not mix blocks from the two files. The files are in the IMU_to_CAN_SD folder.

Analogue inputs to CAN

This example runs on REXGEN 2, REXGEN 2 IMU GNSS, REXGEN Air and REXGEN Pro. The logger reads analogue inputs 0 and 1 every 100 ms and sends them every 100 ms in message 298 (12A hex). Input 0 is in bits 0 to 15 and input 1 in bits 16 to 31. Both are signed, little-endian and scaled by 0.01. The DBC also defines two digital signals in bits 32 to 63 that this file does not fill.

The full file is the complete valid example in the overview guide. See REXGEN XML configuration: how it fits together.

ADC2CAN_Only.xml, block by block REXGEN XML · ANALOGUE TO CAN EXAMPLE ADC2CAN_Only.xml, block by block ADC one block per input, every 100 ms CANSIGNAL writes a value into a message CANMESSAGE OutputPeriodic, every 100 ms CANINTERFACE the CAN port InputUID MessageUID InterfaceUID UID 8 analogue input 0 UID 12 ADC_0, bits 0 to 15 UID 9 analogue input 1 UID 15 ADC_1, bits 16 to 31 UID 10 ID 298, 12A hex UID 4 CAN 0, 500 kbit/s With recording, ADC2CAN_SD.xml adds SDMESSAGE 17, 18, 19 record message 10 and ADC 8 and 9 SDINTERFACE 2 internal storage USBMESSAGE 13, 16, 20, 21 stream message 10 and ADC 8 and 9 USBINTERFACE 3 live data to REXDESK Each arrow is a link by UID, made by the field printed above its column of arrows. Both signals are signed, little-endian (INTEL) and scaled by 0.01. Dashed: the blocks the recording version adds; the other UIDs stay the same. Needs a model with analogue inputs: REXGEN 2, REXGEN 2 IMU GNSS, REXGEN Air or REXGEN Pro.

The files are ADC2CAN_Only.xml and ReXgen_IMU_Out_V3.dbc in the ADC_to_CAN folder.

Analogue inputs to CAN with recording

ADC2CAN_SD.xml adds a recorder for the message and both inputs, and streams them over USB. The files are in the ADC_to_CAN_SD folder.

Real-time clock to CAN

The logger reads its real-time clock once a second as an INTERNAL_PARAMETER. It sends the value every 1,000 ms in message 516 (204 hex) as a 32-bit unsigned value. This signal is big-endian (Motorola), so its start bit is 7, as in the DBC line 7|32@0+.

<INTERNAL_PARAMETER UID="1200">
<InputUID>0</InputUID>
<Parameter_Type>RTC</Parameter_Type>
<Value_Type>ULONG</Value_Type>
<SamplingRate>1000</SamplingRate>
</INTERNAL_PARAMETER>
<CANSIGNAL UID="44">
<InputType>COMMON</InputType>
<InputUID>1200</InputUID>
<MessageUID>42</MessageUID>
<StartBit>7</StartBit>
<BitCount>32</BitCount>
<Endian>MOTOROLA</Endian>
<DefaultValue>0</DefaultValue>
<ParA>1</ParA>
<ParB>0</ParB>
<SignalType>UNSIGNED</SignalType>
<Name>RTC</Name>
</CANSIGNAL>

RTC2CAN.dbc gives the RTC signal a range of 0 to 255, which is too small for a 32-bit value. Widen it in your copy.

RTC2CAN.xml, block by block REXGEN XML · RTC TO CAN EXAMPLE RTC2CAN.xml, block by block INTERNAL_PARAMETER a value inside the logger CANSIGNAL writes a value into a message CANMESSAGE OutputPeriodic, every 1,000 ms CANINTERFACE the CAN port InputUID MessageUID InterfaceUID UID 1200 Parameter_Type RTC ULONG, every 1,000 ms UID 44 RTC, unsigned 32 bits MOTOROLA (big-endian) StartBit 7 UID 42 ID 516, 204 hex UID 4 CAN 0, 500 kbit/s Each arrow is a link by UID, made by the field printed above it. StartBit 7 with MOTOROLA matches 7|32@0+ in RTC2CAN.dbc. The file also holds a recorder (SDINTERFACE 2), a USBINTERFACE and a USBMESSAGE that are not part of this chain; the guide says what to tidy.

The files are RTC2CAN.xml and RTC2CAN.dbc in the RTC_DATA_TO_CAN_BUS folder.

Where to go next

Products in this guide

REXGEN 2

Evidence data logger

View REXGEN 2 Ask an engineer

REXGEN 2 IMU GNSS

Motion & location data logging

View REXGEN 2 IMU GNSS Ask an engineer

REXGEN Air

CAN to cloud

View REXGEN Air Ask an engineer

REXGEN Pro

Edge data platform

View REXGEN Pro Ask an engineer

Still stuck?

Our engineers answer support questions on every Influx Technology product.