December 4, 2023  SeaTalk 1 Autopilots Control

The NMEA 2000 Wi-Fi Router can control autopilots connected via SeaTalk 1 in the same way as a pilot head and can process incoming XDR sentences.

Control autopilots connected via SeaTalk 1 in the same way as a pilot head

Figure 1. Autopilot controls in Web Gauges

In an ideal world, when you click on a point on the chart, the autopilot engages and your boat heads to that point under full sail. In the real world, your PC or mobile software is probably sending NMEA 0183 sentences over TCP/IP and your autopilot is connected to an NMEA 2000 network. The gateway that connects your computer or mobile to the boat's network will have to convert NMEA 0183 to NMEA 2000 and everything should work.

But that is in an ideal world. In the real world, most autopilots need a proprietary command to activate TRACK mode, and may need to receive some proprietary commands during navigation. This locks the autopilot into the same manufacturer's MFD and pilot head.

Pilot heads are a much more complicated. They all send proprietary commands when you press "AUTO" or "+10" or something. For example, it is impossible to take a Garmin head and use it to control a Simrad autopilot, even though they all have the same navigation modes and the same +10/-10 controls, and both work over NMEA 2000.

TRACK and GOTO modes have been supported in our gateways for many years for all known SeaTalk NG, SeaTalk 1, NMEA 0183 and NMEA 2000 autopilots. Some autopilots do not require any tricks other than manually pressing the "Track" button on the pilot head and then activating the track or waypoint in the software. For Raymarine autopilots, we have added special support that must be enabled in the Gateway settings.

But we had many request to add pilot head functions to our Web Gauges, and in the previous firmware update we did it. We added control of SeaTalk NG Raymarine autopilots (SeaTalk NG is the branded version of NMEA 2000) from the web page in the same way as from the pilot head. You can switch on/off AUTO, WIND or TRACK mode, correct the course, make tacks, etc.

The "Third Party Autopilot" setting

Figure 2. Autopilot settings in Web Gauges

In this version we have added the same for autopilots connected via SeaTalk 1. If the "Third Party Autopilot" setting is set to "Raymarine SeaTalk 1", the Web Gauges will start generating $STALK sentences which need to be translated by the gateway into SeaTalk 1 datagrams and sent out via the SeaTalk 1 interface.

  $STALK,86,21,02,FD*4C
  $STALK,84,36,02,00,40,00,03,00,08*69
  $STALK,86,21,03,FC*4A
  $STALK,84,36,C2,08,4A,00,03,00,08*63

So this feature does not apply to NMEA 2000 Wi-Fi Gateway and Ethernet Gateway that do not have hardware SeaTalk 1 port, and only applies to NMEA 2000 Wi-Fi Router YDNR-02. However, we have released the new 1.71 firmware for all these products to synchronize the Web Gauges version. This year we also plan to add this feature to NMEA 0183 Wi-Fi Router YDWR-02 soon. And, of course, we are working to make pilot controls of Web Gauges compatible with autopilots of other manufacturers (send to us your NMEA 2000 logs!).

The next new feature of the NMEA 2000 Wi-Fi Router is the handling of incoming XDR sentences. This sentence is used to send measurement data from transducers that measure physical quantities such as temperature, force, pressure, liquid level, etc. The problem with this field is that transducer names are not defined by the NMEA standard, and for air temperature, for example, different manufacturers may use the names Air, TempAir, ENV_AIR_T, and so on.

XDR settings

Figure 3. New XDR settings

All our gateways have 21 editable fields in the settings to configure outgoing XDR sentences (mostly related to engine and environment), and three of these (Yaw, Roll and Pitch) are also used to process incoming sentences of this type. In this release we have added three more configurable data type fields to process data from batteries, fuel tanks, water tanks and other sensors.

For batteries, for example, we collect voltage, current and case temperature, whether they are all sent in one XDR sentence or in three different sentences. All data types and units are supported for declared sensor types. Below are examples of XDR sentences that can be processed with these new settings:

  $IIXDR,U,12.10,V,A016,*3B
  $IIXDR,I,2.1,A,A016,*31
  $IIXDR,C,22.5,C,A016*23
  $IIXDR,U,12.75,V,A017,I,-1.1,A,A017*69
  $IIXDR,V,15,P,FUEL*56
  $IIXDR,E,11,P,WATER*0E
  $IIXDR,U,12.75,V,A017,I,2.3,A,A017*45
  $IIXDR,P,1.02481,B,Barometer*29
  $YDXDR,P,99930,P,Baro*57
  $IIXDR,C,19.52,C,TempAir*19 

It is flexible enough, but of course not a universal solution. Our technical support receives many requests regarding old NMEA devices, connecting devices of different generations, removing corrupted data from broken sensors, and so on. Some requests can be solved with NMEA 2000 Bridge, but it has two CAN (NMEA 2000) interfaces and no NMEA 0183 connectivity options.

And as you may know, we expect to launch the Yacht Devices Python Gateway in January 2024. It has NMEA 0183 and NMEA 2000 interfaces and can run programs in the Python programming language to process data on the fly. It also has a USB port and you can plug it into a PC, run a terminal program and type in Python commands to test your code on the fly, monitor data interfaces or just look like a cool hacker (we recommend the tried and tested green color for text in the terminal settings).

Below is the code for the Python Gateway to process incoming XDR sentences with battery data and convert them to NMEA 2000. If you are not familiar with Python, this may seem too long, too difficult and too complex. But many on the planet love this language and we recommend spending a weekend with a Python book to see the elegance, beauty and power in these lines.

import struct

TALKER = b'II' # talker id to receive XDR from
XDR_ID = b'A016' # sensor id to process measurements from
BATTERY_INSTANCE = 1 # NMEA2000 battery instance to send

XDR_UNITS = { # (coefficient, offset)
    b'U' : { b'V': (1.0, 0.0) }, # voltage
    b'I' : { b'A': (1.0, 0.0) }, # current
    b'C' : { b'K': (1.0, 0.0), b'C': (1.0, 273.15) } # temperature (kelvin)
}

xdr_sensor = dict() # collected sensor data

# converts NMEA0183 units to default NMEA2000 units
def to_n2k_unit(type, value, unit):
    coeff, offset = XDR_UNITS[type][unit]
    return float(value) * coeff + offset

# returns sensor measurement value in correct format for NMEA2000
def xdr_n2k_value(type, resolution, na):
    return int(round(xdr_sensor[type] / resolution)) if type in xdr_sensor else na

# sends battery information to NMEA2000
def xdr_send_n2k_battery():
    voltage = xdr_n2k_value(b'U', 0.01, 0x7FFF)
    current = xdr_n2k_value(b'I', 0.1, 0x7FFF)
    temperature = xdr_n2k_value(b'C', 0.01, 0xFFFF)
    n2k_data = struct.pack('<BhhHB', BATTERY_INSTANCE, voltage, current, temperature, 0xFF)
    n2k.sendpgn(n2k_data, 127508)

# called upon receive of '$IIXDR' message
def rx_xdr(n0183, line):
    line = line[7:line.find(b'*')] # b'$IIXDR,U,12.10,V,A016,*3B\r\n' -> b'U,12.10,V,A016,'
    args = line.split(b',') # [b'U', b'12.10', b'V', b'A016', b'']
    has_voltage = False
    
    for I in range(0, len(args) & (~0x3), 4):
        id = args[I+3]
        if id != XDR_ID:
            continue
        
        type = args[I]
        xdr_sensor[type] = to_n2k_unit(type, args[I+1], args[I+2])
        has_voltage = has_voltage or type == b'U'
    
    if has_voltage:
        xdr_send_n2k_battery()
    # return True in case we want to retransmit received XDR to TX port (see line below)
    return True 

# disable retransmittion of received NMEA0183 messages to uart_tx
n0183.forward(False) 
# register callback on receive of '$IIXDR' NMEA0183 message
n0183.rxcallback(0, rx_xdr, b'$' + TALKER + b'XDR') 

If you are having trouble using the new settings added in this firmware update, our technical support team has released a document with step-by-step instructions: Release and Application Notes for YDNR-02, YDWG-02, YDEN-02 firmware 1.71.

The firmware updates 1.71 for the NMEA 2000 Wi-Fi Router, NMEA 2000 Wi-Fi Gateway and Ethernet Gateway are available in the Downloads section.

 

Next articles:

Previous articles:

See also: recent news, all news...