Go to Triangle Digital Support Home Page TDS2020F TECHNICAL MANUAL
Hardware expansion
Automotive J1939 bus
Live website search
Enter key words


For more about the TDS2020F CAN adapter and its software click here.

Automotive CAN bus data logger module



The cost, weight and complexity of a vehicle's wiring has increased dramatically. The traditional method of providing a separate wire for each function was adequate when electrical systems were relatively simple. But the introduction of electronic engine management, active safety, navigation aids and luxury equipment have demanded a more sophisticated approach. A computer-controlled network for vehicles is now being implemented, in principle like the network between PCs in an office, but vastly more secure, responsive to real-time events and immune to external electromagnetic interference.

The Society of Automotive Engineers Inc. defines recommended practices for vehicles. The purpose of their set of seven J1939 documents is to provide an open interconnect system for electronic systems that allows devices to communicate with each other by providing a standard architecture. The J1939 specification is an implementation of a Controller Area Network (CAN bus) which permits any device to transmit a message when the bus is idle. Every message includes an identifier defining the message priority, who sent it, and what data is contained within it. Collisions are avoided due to the arbitration process that occurs while the identifier is transmitted (using a non-destructive arbitration scheme). This permits high priority messages to get through with low latency (delay) times because there is equal access on the network for any device. In particular the J1939 specification includes a high level protocol, network speed, types of connector etc. The bus length can be up to 40 metres (unless repeated) with one metre stubs. It runs at 250k bits per second and up to 30 nodes may be connected.


The TDS2020CAN adapter for the TDS2020F embedded computer provides the necessary hardware to interface with the automotive CAN bus. Free software library files for TDS2020F enable you to


q monitor information being broadcast by vehicular equipment on the CAN bus,

q send messages to request other information available on demand,

q forward received data to a serial port on the TDS2020F module,

q optionally log received data to a PCMCIA Flash-ATA or Compact Flash card.


The format of data passed on through the serial port, or logged, can be raw as received or scaled and formatted into intelligible units like kilometres or litres.


The software for the automotive CAN bus module is supplied as source code so that you can tailor it to meet exact requirements. If you plan to do this you may need official J1939 specifications which can be purchased on-line at www.sae.org.



A TDS2020F computer with TDS2020CAN Controller Area Network adapter is required. For more detail see the TDS2020F and CAN bus data sheets, or alternatively the TDS2020F Technical Manual. The full manual in HTML format is also available on www.TriangleDigital.com.

Either of the two CAN connectors on the adapter should be interfaced with the vehicle. If the CAN bus is not already terminated, link 11 should be made but otherwise it should be unmade. Other links should be left as shown in the manual.


The J1939-11 specification shows two different connectors, the 3-pin Deutsch part number DT06-3S-E008 for interconnection within the vehicle and the 9-pin Deutsch part number HD10-9-1939P for an off-board diagnostic connector normally located in the driver's cab.

The 3-pin connector has these pin assignments:


3-pin Deutsch     TDS2020F             Signal                    Description

DT06-3S-E008     CAN adapter

      A                       2                             CAN_L                  CAN bus line, dominant low

      C                      3                             CAN_GND            CAN ground

      B                      7                             CAN_H                  CAN bus line, dominant high

Deutch 3-pin CAN connector


The 9-pin connector has these pin assignments:


9-pin Deutsch     TDS2020F             Signal                    Description

HD10-9-1939P    CAN adapter

      D                      2                             CAN_L                  CAN bus line, dominant low

      E                      3                             CAN_GND            CAN ground

      C                      7                             CAN_H                  CAN bus line, dominant high

      A                                                      BATTERY -          battery return

      B                                                      BATTERY +          positive battery supply


Deutch 9-pin CAN connector


Development of this software was done using a CM570 Engine Control Module (ECM) from Cummins Engine Company Inc. The plugs and sockets for the Cummins module and the TDS2020CAN adapter have these connections:


Cummins ECM   TDS2020F          Signal                    Description

CM570 OEM        CAN adapter

      37                    2                           CAN_L                  CAN bus line, dominant low

      36                    3                           CAN_GND            CAN ground

                              6                           GND                      Optional CAN Ground

      46                    7                           CAN_H                  CAN bus line, dominant high

                              9                           CAN V+                 CAN supply, +7 to 13V

      50                                                 ECM GND             ECM power return

      28                                                 ECM SUPPLY      +24V powering ECM

      38                                                 ECM SWITCH      via keyswitch to +24V



The ways you can interact with the automotive CAN bus may be split into three general categories:


1.    Read available information being broadcast.

2.    Extract other information using request messages.

3.    Send control messages.


In particular, the software supplied enables you to


q read and re-send to the serial port up to 12 selected broadcast message types simultaneously,

q select a message every n seconds in cases where the amount of data available is very large,

q obtain simultaneously up to 12 messages not broadcast (but available on request from the vehicle) at n second intervals,

q interpret a received message in whatever units you want, for instance miles instead of the basic reading in units of 1/8 of a kilometre,

q retransmit the information in ASCII or hex form via the serial port,

q optionally log the information in an Excel spreadsheet format to a Windows-formatted PCMCIA or Compact Flash card.


ALL-CAN    (  -  )           Allows all CAN messages to be received and retransmitted to the serial port (for debug only)

AUTO-INIT  (  -  )           Initialise CAN controller for J1939 communications

B-HALT     ( obj -  )        Stop broadcast display from message object obj.

BROADCAST  ( PGN u obj -  )    Start displaying J1939 bus broadcast message allowing PGN to be displayed every u seconds using object obj.

BROADCAST? (  -  )           Display all broadcast PGNs currently being monitored

CSV        (  -  )           CSV, not display, formatting

D-HALT     ( obj -  )        Stop on-demand display from message object obj.

DEMANDED   ( PGN u obj -  )  Start display of J1939 bus on-demand messages allowing PGN to be displayed every u seconds using 'object' obj.

DEMANDED?  (  -  )           Display all on-demand PGNs currently being monitored

DISPLAY    (  -  )           Display, not CSV formatting

INSTRUCT   (  -  )           Send control message using data in array DATA and 29-bit identifier in double variable IDENTIFIER .

KMS        (  -  )           Kilometres, not miles

MILES      (  -  )           Miles, not kilometres

+LOG       (  -  )           Start logging to PCMCIA or Compact Flash card

-LOG       (  -  )           Stop logging to PCMCIA or Compact Flash card



#CANAUTO.TDS    Software to monitor, control and log data from the J1939 bus.

#CANPRIM.TDS     Low level support common to the above and other high level CAN protocols.


First put together the hardware, a TDS2020F embedded computer and a TDS2020CAN adapter. Add a TDS2020CM2 adapter if logging to PCMCIA cards is needed, giving a 3-layer module of boards. If you want to use Compact Flash also add a TDS2020CFA converter. Ensure that these work interactively with the TDS-PC for Windows development environment.

Next, connect the module to the automotive CAN bus, see HARDWARE for pin connections. With an oscilloscope, check that you can see broadcast CAN signals at pins 2 and 7 on the CAN adapter connectors. They have amplitude about 2 volts at a rate of 4Ás/bit.

Now make a copy of file #CANAUTO.TDS and to get North American formatted dates, in the word AUTO-INIT delete the comment mark in front of USA . Comment out two things if logging to PCMCIA or Compact Flash is not required:





Compile the file and type AUTO-INIT and return to initialise CAN controller for J1939 communications. Then type ALL-CAN and return to let the module read every CAN message and pass it on to the serial port. Hopefully you will see a stream of data looking similar to this:

 07.07.00 12.00.50 F001  61441  0  0 0  16.8  0  0  0  
 07.07.00  12.00.50 F003  61443  0  0 8.0  0.0  
 07.07.00  12.00.50 FEF1  65265  FE  FE 02  00  00  FF  FF FF  
 07.07.00  12.00.50 F004  61444  14  0 0  0.000  
 07.07.00  12.00.50 FEF6  65270  FF  81 7D  00  00  FF  FF FF  

To stop the data you will probably have to press the blue reset button or turn off the module. Messages will most likely come at too high a rate for the serial port. The word  ALL-CAN is for testing only, for real work some selection from the CAN messages is necessary.

The Parameter Group Number (PGN) defines the contents of a message. For example PGN hex F004 (decimal 61444) comes from an electronic engine controller on the network and contains:


q Engine/retarder torque mode

q Driver's demand, engine-percent torque

q Actual engine-percent torque

q Engine speed


The different PGNs are defined in section 4.3 of the J1939/71 specification and the interpretation of the data in each one is in section 4.2 of the same specification. In the snapshot above the displayed data represents:


q 07.07.00       date

q 12.00.50       time

q F004             Parameter Group Number, hex

q 61444           Parameter Group Number, decimal

q 14                  engine/retarder torque mode

q 0                    driver's demand, engine-percent torque

q 0                    actual engine-percent torque

q 0.000            engine speed in rpm.


Selection of broadcast messages is made choosing a particular Parameter Group Number and forwarding only some of the received messages for that PGN. See this example:



$F004  5 2 BROADCAST

$F001 10 5 BROADCAST


The first line selects PGN hex F004 and only allows one through every 5 seconds. The 2 represents the 'message object' in the CAN controller chip on the TDS2020CAN adapter that will be used to receive the data. The second line allows PGN hex F001 through every 10 seconds using another 'message object'. The resulting display will look something like this:


 07.07.00  13.01.33  F001 61441  3  3 3  102.0  3 3  3  

 07.07.00  13.01.34  F004 61444  14  0 0  0.000  

 07.07.00  13.01.39  F004 61444  14  0 0  0.000  

 07.07.00  13.01.43  F001 61441  3  3 3  102.0  3 3  3  

 07.07.00  13.01.44  F004 61444  14  0 0  0.000  


The time stamp shows that the messages are now coming more slowly because other PGNs are being rejected and not all messages of selected PGNs are being let through. Up to 12 PGNs can be selected for display at a time, 'message objects' 1 to 12 inclusive. To change a PGN just use BROADCAST again, even on the fly without stopping the module. For example $FEF6 2 2 BROADCAST would change the present display of PGN hex F004 every 5 seconds to PGN hex FEF6 every 2 seconds by altering the use of 'message object' number 2.

To display all 12 'message objects', their currently assigned PGNs and time intervals use BROADCAST? .

To stop all output use AUTO-INIT to re-initialise the CAN controller. Alternatively 5 B-HALT would stop display from PGN hex F001 through 'message object' 5 in the above example.

All reception is done under interrupt. Once a PGN message has been selected for display it will continue to do so even though you are typing in new instructions. It does not matter that your input is broken up. If you find it disconcerting, put your commands in a new Forth word like this:



   $F004  5 2 BROADCAST

   $F001 10 5 BROADCAST ;


From the point of view of the user, the scheme adopted to extract information using request messages mirrors the broadcast one. For example



$F004  5 2 BROADCAST



This will display broadcast message PGN hex F004 every 5 seconds. Each 10 seconds the module will send a message to request on-demand PGN hex FEE0 (total and trip distances). The resulting display or data collection will be a mixture of broadcast and on-demand, the difference is not important. The on-demand scheme uses a set of 12-element RAM arrays that mirror the 'message objects' in the CAN chip. There is one set of objects 1 to 12 for broadcasts and another set 1 to 12 for on-demand. Note that the syntax is the same for BROADCAST and DEMANDED even though the mechanisms they invoke are quite different. Likewise DEMANDED? will show you all on-demand messages currently requested. This is an example display:



         1    0          0          0

         2 FEE0      65248         10

         3    0          0          0

         4    0          0          0

         5    0          0          0

         6    0          0          0

         7    0          0          0

         8    0          0          0

         9    0          0          0

        10    0          0          0

        11    0          0          0

        12    0          0          0


Requests for on-demand information can be halted in a way similar to broadcast messages, 2 D-HALT would stop display from on-demand object 2.


In order to format any chosen CAN message how you want, it will be necessary to write short formatting code. To do so you will probably need to buy specification J1939/71 from www.sae.org.

Formatting routines have already been written for popular messages such as hex F001 for the electronic engine controller and hex FEE0 that gives you vehicle trip and total distances. There is a default format showing the eight hex bytes received should a formatting routine not be present for a particular PGN. The first of these two examples is with a formatting routine for PGN hex F003, the second without. The difference now will be explained. For PGN hex F003 the specifications say that bits 3 & 2 of the first byte represent the state of the accelerator pedal kick down switch. The F9 of the hex display below shows that bits 3 & 2 are binary 10 so the formatted display shows 2 for the first data. Likewise bits 1 & 0 represent the accelerator pedal low idle switch and F9 shows that bits 1 & 0 are binary 01 so 1 is shown for the second parameter.


07.07.00  13.22.48 F003 61443    2   1    101.6   0.0  

07.07.00  13.22.48 F003 61443   F9  FE  00  FF  FF  FF  FF    FF  


All hex data parameters can be interpreted by similar means. The detail you need to write new formatting routines is in sections 4.2 and 4.3 of the J1939/71 specification. Use the examples in file #CANAUTO.TDS as a model.

Formatting words may contain user-level commands. In the library file MILES and KMS are available to allow for display in either unit of distance.


The displays shown in examples above are useful for direct display or capture to a file in a PC for subsequent printing. Comma-Separated-Variable format is more useful if an Excel spreadsheet is needed. The two words CSV and DISPLAY toggle output between the two forms:







07.07.00  13.50.02  F003 61443  2  1  101.6  0.0

07.07.00  13.50.02  FEE0 65248  322.625  322.625

07.07.00  13.50.04  F003 61443  2  1  101.6  0.0  


In the CSV form the display separator changes from a double space to a comma. For Microsoft's Excel spreadsheet dates are days, they start from 1 Jan 1900 (day 1). Times are fractions of a day, for instance, 0.75000 represents 6pm. After the logged data is opened in Excel, and date and time columns have been correctly formatted, the first three lines received above will look like this:


7-Jul-00 13:49:57   F003 61443   2       1       101.6   0

7-Jul-00 13:49:57   FEE0 65248   322.625 322.625

7-Jul-00 13:49:58   F003 61443   2       1       101.6     0


To collect data from the automotive CAN module in a PC turn on the capture facility of TDS-PC for Windows. See CAPTURE TO FILE, page 222, in the TDS2020F Technical Manual. If the Comma-Separated-Variable format has been turned on with CSV , the resulting file can be opened in Excel.

To log the data onto a PCMCIA Flash-ATA or Compact Flash card, initialise the card with HARD-FORMAT and then use +LOG and -LOG to start and stop the logging process. When the card is put into a PC, copy the file DATA.FIL to the hard disk. If CSV has been used, again the file can be opened as an Excel spreadsheet.

See DATA LOGGING TO COMPACT FLASH AND PCMCIA, page 250, in the TDS2020F Technical Manual for more information.


Requests for information only available on demand are made through CAN chip message object 14. It may also be used to transmit control messages to equipment in the vehicle. First put the 8 bytes of data to be sent into array DATA , then put the required 29-bit identifier into the 32-bit variable IDENTIFIER . The word INSTRUCT in file #CANAUTO.TDS will then send the required control message. The identifier is made up of these parts, see specification J1939/21 for more details.


bits 28-26          Priority, usually 3 (binary 011) for control messages

bit 25  Reserved, usually 0

bit 24 Data Page

bits 23-16          (PF) PDU format

bits 15-8            (PS) PDU specific. Destination address if PF is 0 to 239

bits 7-0               (SA) Source Address


For convenience, uncommenting the last line of #CANAUTO.TDS will make the J1939 automotive CAN module available immediately after compilation. Uncomment only if not compiling to Flash-EEPROM.

While compiling to Flash-EEPROM interrupts are disabled. Even the clock does not increment. You need to lock the Flash-EEPROM before running any program that uses interrupts. For example type SET AUTO-INIT once compilation of #CANBUS.TDS is complete. Be sure you can always exit to Forth so that you can use COLD to erase everything if necessary. See FLASH-EEPROMS, page 234, for more information.


Go to Triangle Digital Support Home Page Go to top   Next page