NMEA Project

The following description has been provided for this project. It covers all the aspects in detail but if you should need more information, please write to us at: Tech Support (techsupport@elmelectronics.com).

Sections:

Introduction


The National Marine and Electronics Association (NMEA) has defined a standard, called NMEA2000, for interfacing electronic instruments, displays, computers, etc. on boats and ships. NMEA2000 (often abbreviated to N2k) is based on a standard for land vehicles (J1939) from the Society of Automotive Engineers (SAE) which in turn uses the Controller Area Network (CAN bus). There are many web pages on these subjects.

N2k messages are fixed length, multi-drop connections at 250 kbit per second. N2k uses special connectors that are suitable for marine environments.

This document discusses the design of electronics to interface to a personal computer or mobile phone.

Considerations


N2k buses on boats are critical to the operation of the boat and a failure of the bus at sea could have dire consequences. Accordingly, I have disabled transmission to the bus. For this reason I have dismissed from consideration commercially available interface devices, such as Actisense.

An N2k connection supplies +12 VDC and Ground, two signal wires, CAN-Hi and CAN-Lo and a shield. Any interface device connected to an N2k network must utilise the same earth/ground as the network, otherwise ground loop currents and interference, or worse, may be the result. It is therefore advisable that any computer or mobile phone that is charged by AC mains or otherwise, be electrically isolated from the network or isolated from AC ground when connected to the N2k network. I have chosen a Bluetooth connection but equally optical isolation is a suitable isolation method.

It is necessary to set up both the interface chip and the Bluetooth module via a serial interface and so an RS232 interface is included in the design.

Components


The critical microelectronic chips in any design are:

  • Decoding chip for the CAN bus,
  • Bus interface chip that has the correct detection levels, etc, and
  • Bluetooth chip/module.

After a search on the web, I chose the ELM329P chip from ELM Electronics in Canada who also supplied the MCP2551 bus receiver chip. The Bluetooth module is the HC-06 which is available from many sources on the web. Note that the HC-06 is a slave-only module, that is, capable only of accepting a paring but not initiating one. (The HC-05 can operate as a master or slave.)

In addition, an LM7805CT regulator chip and MAX323 RS232 driver are used.

The circuit is slightly modified from that shown in the Application Note for the ELM329 with the addition of two sockets for the HC-06; one for setup and the other for normal operation.

Obviously, the LEDs are optional, although very useful during development.

Likewise, the MAX323 is not required, provided the ELM323 and HC-06 can be programmed elsewhere, however it is included in the circuit diagram below for convenience.

It is not possible to have the ELM329, HC-06 and MAX323 in place at the same time and so a special procedure is required, described later.

Circuit


The circuit diagram is contained in a separate file that has been drawn using the KiCad software.

Download a pdf copy of the CANbus schematic (97K) here:

pdf icon

Programming the Chips


9.6 kbaud is available on the ELM329 but is far too slow for my purposes, so it and the HC-06 baud rates have to be set manually. I found that I needed a 115 kbaud as the highest rate available on both chips. Please note that a suitable terminal emulator is required on the laptop computer, see the procedure for communicating with the HC-06.

I suggest that you set “No local echo” on the terminal emulator.

ELM329 Setup Procedure

After building the interface board, the ELM329 baud rate has to be changed as follows:

1. Ensure that the circuit board is not connected to the N2k network.

2. Remove the HC-06 module from the circuit board.

3. Plug in the MAX232 chip and connect a serial interface to it. I used a USB-RS232 adapter which plugged into my laptop.

4. Run a terminal emulator and set the baud rate of the appropriate serial port on the computer to 38.4 kbaud, no parity, 8 bits and no stop bit.

5. Apply power and see the LEDs flash in turn. Connect to your computer and ensure that the ELM329 is responding to commands such as AT @1, AT RV, etc – see the ELM329 data sheet.

6. Send the following two commands to set the baud rate to 115 kbaud. (The > character is the prompt issued by the ELM329, so don’t type it):


>AT PP 0C SV 23
To set divisor into Programmable Parameter 0C


>AT PP 0C ON
To enable Programmable Parameter
(Divisor is 4,000/115.2=35 =0x23)

7. Restart the circuit board and the terminal emulator at the new rate of 115 kbaud and
check that you are able to communicate with the ELM329. If not, the ELM329 data sheet has
advice on recovering from such failure.

Once the ELM329 baud rate has been correctly set up, set the same baud rate in the HC-06 as follows.

HC-06 Setup Procedure

Unfortunately, the HC-06 module requires all commands be completed within one second and so a special terminal emulator is required, see documentation for the HC-06 available on the web:

1. Ensure that the circuit board is not connected to the N2k network and unpowered.

2. Remove the ELM329 from the circuit board.

3. Plug in the HC-06 module into the Setup socket, not the Normal socket.

4. Plug in the MAX232 chip and connect a serial interface to it. I used a USB-RS232 adapter which I plugged into my laptop.

5. Run a terminal emulator and set the baud rate of the appropriate serial port on the computer to 9.6 kbaud, no parity, 8 bits and no stop bit.

6. Connect power and the computer. Ensure that the HC-06 is responding by sending commands such as:
AT
and
AT+VERSION?
All commands must be completed within one second.

7. Send the command:
AT+BAUD8
To set the baud rate to 115 kbaud
Restart the circuit board and the terminal emulator at the new rate of 115 kbaud and check that you are able to communicate with the HC-06.

Disconnect power, remove the MAX323 chip and place the HC-06 in its Normal socket. It should now be possible to pair the HC-06 with the laptop and communicate with the ELM329 via the Bluetooth connection. Ensure that communication with the ELM329 is operating correctly.

Communicating with the N2k Bus


Connect the interface board to the computer and send the following commands to the ELM329 from the laptop via the terminal emulator:


>AT E1
To turn on ELM329 echo


>AT SP A
To specify the N2k/CAN protocol


>AT L1
To turn on linefeeds


>AT H1
To show message headers


>AT MA
To monitor all N2k messages.
Stand by for a flood of messages!

Messages from the N2k system should be recorded for later analysis. www.openskipper.org has software for decoding messages.

The ELM329 data sheet gives an excellent overview of the N2k message structure. The message content of those messages defined by NMEA are available from the web. However, most suppliers utilise NMEA-defined and proprietary messages, so making the decoding of some of the messages more difficult.

< back to the OBD User’s page