June 18, 2020  New case for the NMEA 2000 Bridge YDNB-07

This article describes how to connect Orion BMS2 battery monitor to NMEA 2000 marine network.

Orion BMS2

Picture 1. Orion BMS2

The Orion BMS is a full featured lithium ion battery management system that is specifically designed to meet the tough requirements of protecting and managing battery packs for electric vehicles (EV), plug-in hybrid (PHEV) and hybrid vehicles (HEV) with automotive grade quality.

New BMS2 system offers user-programmable CAN bus interface. Upon a customer request we have developed a program for the YDNB-07 bridge to convert battery voltage, current, temperature and capacity estimate from BMS2 units to corresponding NMEA 2000 PGNs.

This solution allows to connect up to 3 BMS2 units to a single CAN bus and provide NMEA 2000 data on up to 3 batteries with a single YDNB-07 unit.

Device will send the follwing PGNs to NMEA 2000 network:

  • 127506 "DC Detailed Status"
  • 127508 "Battery Status"

You will be able to get the follwoing NMEA 2000 data:

  • battery voltage and current
  • battery SOC and SOH
  • estimated time remaining
  • cumulative amp hours drawn since a battery was full
  • battery case temperature

Also, BMS2 units CAN bus will be galvanically isolated from the NMEA 2000 CAN bus.

We have tested the program and now are ready to share it with the community.

1. Bridge connection to the CAN buses.

BMS2 units should be connected to YDNB-07 CAN2 interface. In addition to CAN High and CAN Low bus wires you should also provide power to YDNB-07 CAN2 interface (+10..+30V DC). YDNB-07 CAN2 interface will be connected to the NMEA 2000 network.

Multiple BMS2 units CAN bus interfaces can be connected to a common CAN bus network. Each BMS2 unit should be programmed with an individual CAN bus address like shown below. BMS unit has two CAN buses, CAN1 and CAN2. We will use BMS2 CAN2 bus as an example.

2. Configuration of BMS2.

BMS2 units needs to be configured via Orion BMS 2 Utility. Install and run "Orion BMS 2 Utility" and connect it to BMS unit. In the main window open "CANBUS Settings" tab and set the CANBUS #2 Frquency [kbps] to 250.

CAN bus speed configuration (Orion BMS2)

Picture 2. CAN bus speed configuration

Then hit "Edit CAN bus messages" button, editor window appears. We will use 29-bit CAN ID for BMS2 outgoing data, and to distinguish multiple BMS units we will use the same technique as used on J1939 or NMEA 2000 bus, where the LSB byte of 29-bit CAN frame ID will designate the BMS 2 unit "device address".

We will construct two 8-byte payload PGNs for BMS2 to output on CAN2.

2.1 "BMS 2 SOC/SOH"

CAN message ID: 0xFF00xx, where "xx" - BMS2 device address. Interval (speed): 1496 ms. Field length: 8 bytes.

  • [0] Pack State of Charge (1 byte, units in %, resolution 0.5 %) UNSIGNED
  • [1] Pack State of Health (1 byte, units in %, resolution 1 %) UNSIGNED
  • [2-3] Pack Amphours (2 byte, units Ahr, resolution 0.1 Ahr) UNSIGNED
  • [4-5] Pack Current (2 byte, units A, resolution 0.1 A) - SIGNED
  • [6] Internal Temperature (1 byte signed, units °C, resolution 1 °C) SIGNED
  • [7] Reserved

2.1"BMS 2 Live Data"

CAN message ID: 0xFF01xx where "xx" - BMS2 device address. Interval (speed): 1496 ms. Field length: 8 bytes.

  • [0-1] Pack Voltage (2 byte, units V, resolution 0.1 V) UNSIGNED
  • [2-3] Pack Current (2 byte, units A, resolution 0.1 A) SIGNED
  • [4-5] Adaptive Total Capacity (2 byte, units Ahr, resolution 0.1 Ahr) UNSIGNED
  • [6-7] Adaptive Amphours (2 byte, units Ahr, resolution 0.1 Ahr) UNSIGNED

BMS 2 Device address can be 0,1 or 2 - it will be the same as NMEA 2000 "DC Instance"/"Battery Instance".

CAN messages (Orion BMS2)

Picture 3. CAN messages configuration

In "CAN bus messages" editor you will need to create two new messages (PGNs).

In section "Message settings":

  • check "Extended ID" checkbox, click "Apply", then you will be able to enter 29-bit values to "ID" column
  • set speed (ms) = 1496
  • set CANBUS interface = CAN2
  • set Receive/transmit to Transmit
  • click Apply

Then in the main table enter "CAN message ID" into "ID" column. For example, on first BMS2 unit you will have 0xFF0000 and 0xFF0100, on second BMS 2 unit - 0xFF0001 and 0xFF0101, on third - 0xFF0002 and 0xFF0102. Set the Length to 8.

Then edit payload bytes. Note that payload items have different size, some are single byte wide, others are 2-byte wide.

In all payload bytes set: Bit Order (First) = Most Significant Bit.

In all 2-byte payload bytes set: Byte Order = Little Endian.

For signed payload values check "Signed" checkbox, for unsigned uncheck it.

Click Apply each time you are ready to move to next payload item.

When ready, hit "Send profile changes to BMS" button, BMS2 unit will reboot and starts broadcasting our programmed PGNs onto its CAN2 bus.

3. Program for NMEA 2000 Bridge YDNB-07.

Full program is available here. Rename the file to YDNB.CFG and upload the program into the Bridge, and if all connections are made correctly and BMS 2 unit is also correctly configured, you should get the battery data on a compatible NMEA 2000 chartplotter or display.

Notice on SLOT3 usage (please, see the line 174 of the program). In this program, we demonstrate how you can use one of the device SLOTs as a large memory buffer. We use 3 chunks of SLOT3, each 12 bytes in length to store intermediate data from up to 3 BMS units.

When we need to update the data we will LOAD the SLOT, then modify values, and then SAVE the SLOT. Of course, this operation is destructive on the current buffer contents, make sure to store all data from current buffer prior to LOADing the SLOT.


# SLOT3 as working memory array
# load the slot
load(SLOT3)
	
# set values
	
# data TTL counter
set (DATA + X * 12, UINT8, 0)
	
# data values obtained from BMS2 are in variables B,C,F,G
set (DATA + X * 12 + 1, UINT8, B)
set (DATA + X * 12 + 2, UINT8, C)
set (DATA + X * 12 + 3, UINT16, F)
set (DATA + X * 12 + 9, INT8, G)

#save the slot
save(SLOT3)

4. In conclusion

The NMEA 2000 Bridge YDNB-07 is a very powerful instrument to create custom gateways. The program for Orion BMS2 contains 116 lines of the code only (excluding comments), because the language of the Bridge is especially designed to process CAN messages. And the language is very easy: if you are familiar with any from programming languages, you can learn it in a hour.

 

Next articles:

Previous articles:

See also: recent news, all news...