Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverse engineering of Navico autopilot controls #309

Open
keesverruijt opened this issue Oct 5, 2022 · 16 comments
Open

Reverse engineering of Navico autopilot controls #309

keesverruijt opened this issue Oct 5, 2022 · 16 comments
Assignees

Comments

@keesverruijt
Copy link
Collaborator

(A lot of) work has already been done on this by @htool, see https://github.com/htool/RaymarineAPtoFakeNavicoAutoPilot

Hans' focus was to be able to use a Raymarine AP with a Navico control head, for this to work it needs to know that the AP is fully commissioned.

I intend to go the other way:

  • Add PGNs for the most common reports like mode (Standby/Auto/Wind/FollowUp).
  • Add PGNs for the most common commands like mode / -10 / -1 / +1 / +10.
  • Add PGNs that make the control head believe the autopilot is commissioned (if this exists, I think this may not be possible for all control heads.)
@TwoCanPlugIn
Copy link

Was following up a few issues I had raised on SignalK and saw a link to this. Canboat has been an inspiration for the OpenCPN TwoCan plugin, so happy to give something back.

I haven't been able to get the NAC-3 to go into Navigation or No-Drift Mode because I have yet to figure out what other PGN's are required. For example, in Navigation Mode, even though I generate and transmit valid PGN 129283 (XTE), PGN 129284 (Navigation) and PGN 129285 (Route/Waypoint List) messages, they are not sufficient to enable the NAC-3 to engage in Navigation Mode. There are a couple of PGN's sent by a B&G Zeus MFD that appear to be necessary to support Navigation Mode, but as yet, I have not been able to decipher them

Note the NAC-3 behaves as four separate NMEA 2000 devices, Autopilot, NMEA 183 Input, Rudder Feedback and Virtual Rudder Feedback. Similarly the Zeus-2 MFD behaves as several NMEA 2000 devices, MFD, Navigator, Autopilot Controller, GPS.

All of these are Manufacturer Proprietary PGN's, with the first two bytes encoded with the Manufacturer and Industry codes as per usual.

PGN 65305,
Broadcast by NAC-3 Autopilot.
Reports the Status and Mode of the Autopilot
These correspond to what is displayed on the Zeus-2 MFD

NAC-3 Autopilot Status

Sample Raw Data
0x41 0x9f 0x00 0x02 0x10 0x00 0x00 0x00
0x41 0x9f 0x00 0x02 0x02 0x00 0x00 0x00
0x41 0x9F 0x64 0x02 0x10 0x00 0x00 0x00

Byte 2 indicates the Autopilot Model. 0x64 - NAC-3, 0x00 - AC-12
Byte 3 (0x02) indicates Status Report
Byte 4 indicates the Autopilot Status, 0x10 - Enagaged, 0x02- Standby

NAC-3 Autopilot Mode

Sample Raw Data
0x41 0x9F 0x64 0x0A 0x40 0x00 0x00 0x40
0x41 0x9F 0x64 0x0A 0x00 0x04 0x00 0x04
0x41 0x9F 0x64 0x0A 0x10 0x00 0x00 0x00
0x41 0x9F 0x64 0x0A 0x00 0x01 0x00 0x00
0x41 0x9F 0x64 0x0A 0x08 0x00 0x00 0x00

Byte 2 indicates the Autopilot Model. 0x64 - NAC-3, 0x00 - AC-12
Byte 3 (0x0A) indicates Mode Report
Bytes 4,5 indicate the Autopilot Mode
GPS = 0x0040
Wind = 0x0400
Heading = 0x0010
No Drift = 0x0100
Standby = 0x0008

PGN 65431
Broadcast by NAC-3 Autopilot
Reports the heading or apparent wind angle dependent on the autopilot mode

Sample Raw Data
0x41 0x9F 0xFF 0xFF 0x03 0xFF 0x7F 0x3D
0x41 0x9F 0xFF 0xFF 0x02 0xFF 0xFF 0xFF
0x41 0x9F 0xFF 0xFF 0x0B 0xFF 0xD1 0x24

Byte 4 reflects the Autopilot Mode (or more correctly), the type of angle
Wind - 0x03
GPS - 0x0A
Heading - 0x02
No Drift - 0x0B

Byte 5 and Byte 6 encode the angle expressed as radians with a resolution of 0.0001

PGN 130856
Broadcast by NAC-3 as some sort of alarm message.
Noticed they were transmitted by the NAC-3 during Heading Hold and Nav Mode whilst the vessel was stationary

Sample Raw Data
0x41 0x9F 0x10 0x00 0x10 0x01 0x4C 0x6F 0x77 0x20 0x62 0x6F 0x61 0x74 0x20 0x73 0x70 0x65 0x65 0x64

Decoded Message
0x41 0x9F Manufacturer & Industry Code
0x10 0x00 Some sort of command or message ID
0x10 0x01 Length 20, String Encoded as ASCII
0x4C 0x6F 0x77 0x20 0x62 0x6F 0x61 0x74 0x20 0x73 0x70 0x65 0x65 0x64
L o w sp b o a t sp s p e e d

PGN 130851
Broadcast by NAC-3
Seems to mirror PGN 130850 which is ordinarily transmitted by the MFD

Sample Raw Data
0x41 0x9F 0x03 0xFF 0xFF 0x0A 0x06 0x00 0xFF 0xFF 0xFF 0xFF 0xFF

Byte 2 - NAC-3 CAN Bus Network Address
Byte 5 - 0x0A Indicates Mode Report ?
Byte 6 - Autopilot Mode

PGN 130860
Broadcast by NAC-3

Sample Raw Data

GPS Mode
0x41 0x9F 0x00 0x6F 0x00 0x00 0x00 0xFF
0xFF 0xFF 0x7F 0xFF 0xFF 0xFF 0xFF 0xFF
0xFF 0xFF 0x7F 0x2E 0x39 0x2C 0x30 0xFF
0xFF 0xFF 0xFF

Standby
0x41 0x9F 0x00 0x00 0x00 0x00 0x00 0xFF
0xFF 0xFF 0x7F 0xFF 0xFF 0xFF 0xFF 0xFF
0xFF 0xFF 0x7F 0xFF 0xFF 0xFF 0xFF 0xFF
0xFF 0xFF 0xFF

No Drift Mode
0x41 0x9F 0x00 0x00 0x00 0x00 0x00 0xFF
0xFF 0xFF 0x7F 0xFF 0xFF 0xFF 0xFF 0xFF
0xFF 0xFF 0x7F 0x00 0x01 0x00 0x00 0xFF
0xFF 0xFF 0xFF

Wind Mode
0x41 0x9F 0x00 0x00 0x00 0x00 0x00 0xFF
0xFF 0xFF 0x7F 0xFF 0xFF 0xFF 0xFF 0xFF
0xFF 0xFF 0x7F 0xFF 0xFF 0xFF 0xFF 0xFF
0xFF 0xFF 0xFF

I haven't figured out what this PGN encodes

PGN 65305
Broadcast by Zeus-3 MFD every second, presumably a keep alive

Sample Raw Data
0x41 0x9F 0x01 0x03 0x00 0x00 0x00 0x00

Byte 2 - 0x01 Presumably indicate a keep alice/heartbeat message ??
Byte 3 - Toggles/Alternates between 0x0B and 0x03.

Although 0x03 corresponds to the CAN address as the NAC-3 on my network
0x0B (11) does not correlate to any other Navico device.

PGN 130850
Broadcast by Zeus-2 MFD to change NAC-3 autopilot mode, heading or wind angle

Sample Raw Data
0x41 0x9F 0x03 0xFF 0xFF 0x0A 0x09 x00 0xFF 0xFF 0xFF 0xFF 0xFF (change mode to heading)

0x41 0x9F 0x03 0xFF 0xFF 0x0A 0x1A x00 0x02 0xD1 0x06 0xFF 0xFF (change direction by 10 degrees to Port)

Decoded Message
0x41 0x9F nn 0xFF 0xFF 0x0A mm x00 dd aa aa 0xFF 0xFF

Byte 2 (nn) - CAN Address of NAC-3
Byte 5 - Mode Command (0x0A)
Byte 6 (mm)- Mode
Standby = 0x06
Heading = 0x09 |
Wind = 0x0F
GPS = 0x0A
Change Heading/Wind Angle = 0x1A

Byte 8 (dd) - Direction, Port = 0x02, Starboard = 0x03 When changing angle, otherwise 0xFF
Bytes 9, 10 (aa) - Angle (if not altering heading or wind angle, ie just changing mode) set to 0xFF 0xFF

Note, when changing to GPS mode (following a GPS course), the message must be transmitted twice.

The PGN broadcast from the MFD which seems to be the key to engaging the NAC-3 in GPS mode is PGN 139820

Sample Raw Data
0x7D 0x99 0x02 0x41 0x00 0x00 0x00 0x00
0x03 0x41 0x36 0x87 0x07 0x00 0x00 0x41
0x00 0x00 0x00 0x00 0x01 0x41 0xC0 0xE1
0x6C 0x30 0x06 0x41 0x40 0x62 0xC0 0x2E
0x04 0x41 0x40 0x44 0x78 0x32 0x05 0x41
0x80 0xE8 0x02 0x00

It doesn't match any of the formats in Canboat, but does seem to be a series of key/value pairs.

0x7D 0x99
0x02 0x41 0x00 0x00 0x00 0x00
0x03 0x41 0x36 0x87 0x07 0x00
0x00 0x41 0x00 0x00 0x00 0x00
0x01 0x41 0xC0 0xE1 0x6C 0x30
0x06 0x41 0x40 0x62 0xC0 0x2E
0x04 0x41 0x40 0x44 0x78 0x32
0x05 0x41 0x80 0xE8 0x02 0x00

Decoding each of the values as int, unsigned int, short, unsigned short and converting to latitude, longitude, speed, distance, angle time, doesn't correspond to anything that makes sense.

Hope this is of some help.

@keesverruijt
Copy link
Collaborator Author

Thanks. I will be out sailing for a few months, but aim to pick this up after that.

@TwoCanPlugIn
Copy link

No probs,
I'm the reverse, packing up the boat for winter before heading home.

BTW, Apologies for posting in the wrong spot, but posted an analysis of PGN 130850 & 130851 from the data that Teppo provided in #272

Enjoy your sailing.

@TwoCanPlugIn
Copy link

BTW, Dyslexic fingers caused typo.
"The PGN broadcast from the MFD which seems to be the key to engaging the NAC-3 in GPS mode is PGN 139820 " should read
"The PGN broadcast from the MFD which seems to be the key to engaging the NAC-3 in GPS mode is PGN 130824

A little bit of further analysis, I think the value of key 5, corresponds to distance to waypoint. Really needs to be captured while underway as any values such as sog,, time to waypoint etc. are meaningless when stationary.

@tkurki
Copy link
Contributor

tkurki commented Jun 8, 2023

See also #409

keesverruijt added a commit that referenced this issue Jun 10, 2023
Started with proper analysis of AP48 commands.

The intention is to slowly add all 'operation' commands from the AP48
and all data coming NAC-3 and AC-42. This will allow development of
open source AP controllers.

'Commissioning' is considered out-of-scope. Although some users
seem to think this useful, I feel that it is dangerous to try and
emulate the control head / MFD to such an extent, and that this should
be left to the device manufacturer. Also, it is different for every
generation of AP computer so I also think the work/benefit ratio is too
low.
keesverruijt added a commit that referenced this issue Jun 19, 2023
@TwoCanPlugIn
Copy link

Revisited this.
All of the above regarding engaging the autopilot, including Navigation Mode, seem to be correct, at least on a NAC-3.

All that the NAC-3 requires is valid PGN 129283 (XTE) and PGN 129284 (Navigation Data) messages with the following weird observation, in that Navigation mode could only be reliably selected when the Device Class and Function class were set to 50 & 130 respectively. This made little sense to me.

Even if I set the other fields in PGN 60928 (address claim), such as the manufacturer code and the fields in PGN 126996 (Product Information) to match those from a B&G Zeus MFD, it seemed to give random results. Perhaps I was holding my tongue wrong.

@keesverruijt
Copy link
Collaborator Author

keesverruijt commented Sep 9, 2023

Note that in v5.0.2 I have just merged a number of fixes to the "Simrad: Key Value" PGN 130845 which is now mostly readable. Not really AP control yet, but most of the data generated by changing settings on my AP48 are now supported.

@sbender9
Copy link
Member

Does anyone have a log of n2k data when using the autopilot?

@ersingencturk
Copy link

ersingencturk commented Jun 15, 2024

Does anyone have a log of n2k data when using the autopilot?

i captured these recently. when i playback it successfully controls the boat:

1 starboard

2024-06-03-17:57:54.174,2,130850,0,255,8,20,0c,41,9f,01,ff,ff,0a
2024-06-03-17:57:54.175,2,130850,0,255,8,21,1a,00,03,af,00,00,ff

10 starboard
2024-06-03-13:55:23.757,2,130850,0,255,8,00,0c,41,9f,01,ff,ff,0a
2024-06-03-13:55:23.757,2,130850,0,255,8,01,1a,00,03,d1,06,00,ff

1 port

2024-06-03-17:57:43.925,2,130850,0,255,8,00,0c,41,9f,01,ff,ff,0a
2024-06-03-17:57:43.926,2,130850,0,255,8,01,1a,00,02,af,00,00,ff

10 port

2024-06-03-13:55:25.156,2,130850,0,255,8,20,0c,41,9f,01,ff,ff,0a
2024-06-03-13:55:25.157,2,130850,0,255,8,21,1a,00,02,d1,06,00,ff

@sbender9
Copy link
Member

That helps, but I need a complete session that includes changing navigation modes and includes all the messages coming from the AP.

@tkurki
Copy link
Contributor

tkurki commented Jun 17, 2024

@sbender9 dropped you a url for a capture file. If anybody else is interested ping me.

@TwoCanPlugIn
Copy link

I would be interested as well, if only to verify what I am already parsing.

Haven't been able to retest this year, but at the end of last year, pretty confident that I could control a NAC-3 (change mode, heading, wind angle) and generate the correct PGN 129283 & 129284 & Keep Alive messages.

@tkurki
Copy link
Contributor

tkurki commented Jun 18, 2024

@TwoCanPlugIn drop me an email at teppo.kurki@iki.fi and I'll reply with link to the capture file.

@keesverruijt
Copy link
Collaborator Author

keesverruijt commented Jun 18, 2024 via email

@TwoCanPlugIn
Copy link

OK, Here goes. I was able to "borrow" neighbour's boat on weekend to capture some more data. It agrees what I had written earlier and at least for scenario 1. Controlling a NAC-3 with another device, it confirms what I was able to do at the end of last season. (My problem is how to package it for OpenCPN, either include it in TwoCan, develop a separate plugin that uses TwoCan, or a separate plugin that uses OpenCPN's native NMEA 2000 support. However that's my problem, not yours).

Regarding the other scenarios, 2. Commissiong, is going to require a lot of configuration & analysis, and for 3. Using something like a MFD or Triton 2 to control a PyPilot I think would also be difficult. I also doubt whether someone who invests in a PyPilot (hobbyist, tinkerer) is going to spend a large sum of money on a Triton2?

The setup, or at least the captures, which I've filtered to exclude the noise.
3. NAC-3 Autopilot. (not to be confused with NAC-3 Pilot Controller, NMEA 0183 Gateway, Rudder Feedback)
5. Zeus Pilot Controller
12. Zeus Navigator
18. Zeus Display

For Autopilot functions, the capture is between 3 & 5. and the order is the following:
Standby->Heading Hold->Port 10->Starboard 10-> Port 1-> Port 1-> Starboard 1-> Starboard 1->Standby
Standby->Wind->Port 10->Starboard 10-> Port 1-> Port 1-> Starboard 1-> Starboard 1->Standby
Standby->No Drift->Port 10->Starboard 10-> Port 1-> Port 1-> Starboard 1-> Starboard 1->Standby
Standby->Nav->Standby Note there are two Nav messages, the Zeus needs a confirmation to start in Nav mode.

Important PGNS are 130850 (Event Command), 130851 (Event Reply), 65305 (SImnet Autopilot Status), 65341 (Simnet Angle). Also important is he use of 65305 as a Keep lAlive from the Pilot Controller to the Autopilot.

As moored alongside, a few "Low Boat Speed" alarms.

BTW, A couple of additional Alram messages. (PGN 130856 contains the code & text, 130850 contains the error code).
0x15 - No Nav Data
0x16 - Compass Data missing.
0x22 - No autopilot computer

For Nav mode, the capture is between 12 and 3.
It was simply a matter of selecting a route (in this case named RRR,, the first waypoint named AAA) and starting it. Evident in PGN 129284.

I was only able to perform the Dockside commissioning, which looks to only configure the NAC-3 Virtual Rudder Feedback (eg. turning wheel to full lock and centering. I wasn't going to play with the other settings (eg. boat displacement, boat type, tacking angle etc.), so perhaps not much use.

The attached text files are just my parsing of some of the PGN's. They kind of make sense to me and at least for PGN's 130850, 130851, 65341 and 65305 it matches what I have been able to use to control the NAC-3.

I guess the one important thing to note, and perhaps one should feel some sympathy towards the developers of the MFD's at Navico. I guess through all of the acquisitions/mergers (Simrad/Robertson, B&G) each autopilot (TP32, AC-12, AC-42 and NAC-2/3), each autopilot has an inconsistent set of commands, so the decoding for the NAC-3 will differ to that of say for example the Simrad TP-32 Tillerpilot.

It would be great to get another capture of Teppo's TP-32, albeit with a description of the modes & commands that were issued.

Regards...
nac3-zeus-autopilot.log
nac3-zeus-dockside.log
nac3-zeus-nav.log
65305.txt
65341.txt
130850.txt
130851.txt

@TwoCanPlugIn
Copy link

Oops, forgot to add Non Follow Up mode (NFU).

When autopilot is in Standby.

Again PGN 130850 sent from MFD to Controller. The usual palaver, Byte 2 is the autopilot controller's CAN bus address, Byte 5 is the Command (0x02) and Byte 8 controls whether to move rudder to port or starboard. For the port & starboard commands these are sent continuously while the port or starboard button is pressed.

0x41 0x9F 0x03 0xFF 0xFF 0x02 0x0D 0x00 0xFF 0xFF 0xFF 0xFF - NFU Mode
0x41 0x9F 0x03 0xFF 0xFF 0x02 0x0D 0x00 0x04 0xFF 0xFF 0xFF - NFU Mode Move rudder to Port
0x41 0x9F 0x03 0xFF 0xFF 0x02 0x0D 0x00 0x05 0xFF 0xFF 0xFF - NFU Mode, Move rudder to Starboard

Didn't get the opportunity to test "dodging" when in Nav mode nor auto tacking when in Wind mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

5 participants