This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SeaTalk 1 to NMEA0183/2000 with Raspberry Pi
#11
(2020-08-20, 09:44 AM)PaddyB Wrote:
(2020-08-19, 09:16 PM)abarrow Wrote: Is there a way for this program to use input other than GPIO? My SeaTalk to NMEA 0183 converter sends out NMEA strings, but is also sends $STALK strings. Can SignalK use those?

Sorry to ask the same question twice, I'm just not seeing the evidence that this is happening. Is the talker ID "ST" for these keys?

Signalk should decode STALK messages, just tried a few examples from here though depth units looked odd>
https://github.com/SignalK/signalk-parse...est/ALK.js

Send as UDP from node-red to a signalk UDP connection.

Tye depth & STW I tried showed up in opencpn dashboard via signalk, though the logbook seems to still need NMEA
Nice method checking ! [Image: thumbsup.png]
And, @abarrow, if Your converter sends out, ST1 sentences, matching the format in the test code above, it will work with the standard SK NMEA0183 parser.
________________________________________

Blog; https://pysselilivet.blogspot.com/
Reply
#12
The reason I'm asking is that I'm having issues with my magnetic heading flipping around on OpenCPN. Since it looks from the code that one of the SeaTalk datagrams converts to headingMagnetic, that would add yet another headingMagnetic key going to OpenCPN. I'm wondering if that might be contributing to my problem.

I'm going to block $STALK messages at the serial interface from my Quark-Elec SeaTalk converter and see what that does. I've already tried using the SKFilter and it's not helping. Right now I'm getting STALK and other NMEA strings out of my SeaTalk converter.
Reply
#13
Okay, update on this. I guess I need a better tutorial on SKFilter. I was able to get my headingMagnetic from flipping around by blocking the HDM string from my masthead wind transducer (I know that compass isn't calibrated correctly) at the serial connection to the SK server. I also found that my magneticVariation was flipping from 0 to 6 radians, which I was able to block with SKFilter. I didn't have to block $STALK strings from my SeaTalk converter, although it does appear that I'm getting the same headingMagnetic from an $STALK string and a converted NMEA string.

I'm still having occasional dropouts of GPS data, which causes my ship icon to disappear from OpenCPN. It's usable, but annoying. I tried logging the port, but I can't see any problems with the incoming NMEA data
Reply
#14
ÍI’ve been playing for a while with the STALK_read.py trying to make my ST2000+ work with the autopilot app without success. Also tried the new standard signalk connection. I’ve found that the 9c seatalk1 datagram gets translated to signalk but not the 84 that reports autopilot state.

This is one example taken from my device:

$STALK,84,56,e,0,0,0,0,0,8*0F

I tried even pasting it into the Data Fiddler but it didn’t translate into any delta. I also installed the nmea signalk parser and got the same result so i did a step trace debug of the code and found that when it parses for the values of:

[U, VW, V, XY, Z, M, RR, SS, TT]

I get this results:

[ 5, 14, 14, 0, NaN, NaN, 0, 0, 8 ]

And the function returns a null after finding the NaNs

Those values are parsed like this:

  var Z = parseInt(parts[4].charAt(1), 16)
  var M = parseInt(parts[5].charAt(1), 16)

After this finding i tried the following modified datagram adding some zeros:

$STALK,84,56,e,00,00,00,00,00,8*3F

And the translation worked in both command line parser and data fiddler.

In conclusion I see two posible solutions, modify the STALK_read.py code to add the additional zeros or modify the parser so it can parse the single 0 correctly (I guess charAt(0)).

If anybody can guide me to the location of the files on sk server and which solution will be more suitable I can try making the changes, test and report the final solution.

Best regards,
Cari20
Reply
#15
(2020-08-25, 05:48 AM)Cari20 Wrote: ÍI’ve been playing for a while with the STALK_read.py trying to make my ST2000+ work with the autopilot app without success........

Interesting findings and nice analys.

The best way to find the source is ' sudo find / -name "pigpio-seatalk.js" '. This is the js program, with Python code embedded, which does the the job in the SK server.
________________________________________

Blog; https://pysselilivet.blogspot.com/
Reply
#16
Thanks for creating this.

Would it in the future be possible to do the reverse, convert signalk to seatalk?
An example of sending seatalk with an Arduino is here: https://blog.arribasail.com/2015/08/seat...duino.html
I'm just not smart enough to convert this to js or python, let alone implement this in signalk...
This way pypilot could talk to a seatalk autohelm ST2000+ (old version without NMEA).
Reply
#17
(2020-09-03, 09:02 PM)Nikotine Wrote: Thanks for creating this.

Would it in the future be possible to do the reverse, convert signalk to seatalk?
An example of sending seatalk with an Arduino is here: https://blog.arribasail.com/2015/08/seat...duino.html
I'm just not smart enough to convert this to js or python, let alone implement this in signalk...
This way pypilot could talk to a seatalk autohelm ST2000+ (old version without NMEA).

Hi Nikotine,

Yes, but not exactly. I've developed a simple flow in Nodered based in marcoberman remote Python code to send the seatalk1 datagrams emmited by the signalk-remote app through one of the RPi GPIO pins using the Thomas Knauf bidirectional hardware plus a level adapter.

It´s working fine with my ST2000+ but as for Pypilot to directly steer it, I´ve looked into that and I think it's not posible because ST2000 is not desinged to be controled by a control unit (ACU, as other more expensive models do) and doesn´t have the logic to it. 
In spite of that I've been working in emulating the seatalk1 output of a ST40 Course Computer to be able to send the magnetic heading obtained by Pypilot from a MPU sensor to the ST2000. I'm not sure if it will be of any use because as stated in the Raym. official forum the data is only used for long term heading corrections but for short term it still uses the internal fluxgate. I think it´s only useful when the outboard or some other device on the cockpit produce variations on the internal fluxgate.

I can publish the details of my flow in the next few days if you're intrested.

Cari20
Reply
#18
(2020-08-25, 05:48 AM)Cari20 Wrote: If anybody can guide me to the location of the files on sk server and which solution will be more suitable I can try making the changes, test and report the final solution.
https://github.com/SignalK/signalk-serve...seatalk.js, but I see there was already a bug report opened and resolved.

(2020-09-03, 09:51 PM)Cari20 Wrote: I can publish the details of my flow in the next few days if you're intrested.
Yes please, or PM me, because we might be going off-topic.

I've been experimenting this weekend.
Because I'm not near my boat at the moment, I programmed an Arduino to send out Seatalk.
It's based on the SeatalkTest program here, but I didn't use the 9-bit versions of HardwareSerial from there.
Instead I used those posted by Nick Gammon here.
Finally I had to update the Arduino script to use the correct serial.begin and serial.write9bit lines, as described in the example code in the same post by Nick Gammon.

When I use STALK_read.py with these settings:
Code:
gpio= 17        # Define gpio where the SeaTalk1 (yellow wire) is sensed
invert = 1      # Define if input signal shall be inverted 0 => not inverted, 1 => Inverted
pud = 2         # define if using internal RPi pull up/down 0 => No, 1= Pull down, 2=Pull up

I can see the seatalk sentences roll in, and comparing them to Thomas Knauf's website, I think they are correct:
Code:
pi@GuldenDraak:~/STALK_read $ sudo python STALK_read.py
$STALK,
$STALK,24,02,00,00,00
$STALK,00,02,40,fc,00
$STALK,20,01,42,00
$STALK,89,b2,0a,00,20
$STALK,10,01,00,78
$STALK,11,01,09,05
$STALK,24,02,00,00,00
$STALK,00,02,40,ff,00
$STALK,20,01,3f
$STALK,89,b2,0a,00,20
$STALK,10,01,00,78

However, SignalK with below settings doesn't seem to receive a thing:
[Image: p9MnD1i.png]

There's no option to set the pull up/down resistor, so I assume it will default to a pull up for that pin?

I also tried copying the STALK messages I get with STALK_read.py in the data fiddler and it says it's invalid.

So is there something wrong with the datagrams, or SignalK?
Reply
#19
Oh, it's working now! SignalK is reading the simulated Seatalk messages!

The only things I changed was to power the Arduino with my lab power supply instead of the RPi, disconnect my scope and restart the RPi.
One of these three things fixed it Smile
Reply
#20
As promissed, this is the solution I developed for sending seatalk1 datagrams generated by signalk (In this case the signalk-autopilot plugin) to the seatalk1 bus (ST2000+).

First, a little about the hardware:

I used the bidirectional interface published by Thomas Knauf:

http://www.thomasknauf.de/rap/seatalk3

In particular I assembled this version because it was easy for me to get those transistors, but it should be the same:

https://berreizeta.blogspot.com/2016/08/...rface.html

This interface is desing to be connected to a RSR232 interface and is not compatible with the RPi GPIOs, so I used a MAX3232 level adapter in between the interface board and the RPi.

https://www.amazon.com/Mini-RS232-Conver...B01DAR1ZOY

The TTL input of the adapter is connected to the GPIO23 pin and configured as a seatalk1 GPIO standard connection in signalk.

Now, for the output, I connected it to the GPIO14 (TXD0), you have to enable the UART on that ping to be able to use the hardware serial output (This disables the bluetooth on the RPi, I’d like to try sometime if it’s posible to use a software serial output with some other GPIO but 9bit logic is tricky).

Finally, there is a very simple Nodered flow, the first node is a Signal-app-event-node with the same value in the event name as you put in the signalk-autopilot “NMEA 0183 outputEvent for the Seatalk Connection” config. The second node is a python function node with this code:

https://github.com/dnegrotti/seatalk1_ou...lk1_out.py

You can import the flow directly into Nodered with this code:

Code:
[{"id":"c964b9cf.79b678","type":"signalk-app-event","z":"46419c75.a897b4","name":"NMEA0183 Out","event":"seatalkOut","x":110,"y":140,"wires":[["4633789b.f5aac8"]]},{"id":"4633789b.f5aac8","type":"python-function","z":"46419c75.a897b4","name":"Seatalk1 Out","func":"#!/usr/bin/env python\n#Sends seatalk1 datagrams to serial output\n#By Cari20 (2020) loosely based on Marco Bergman ST2000 RPi remote\n\nimport RPi.GPIO as GPIO\nimport serial\nimport binascii\n\nmsg2 = msg['payload']\nlst = msg2.split(\"*\")[0].split(\",\")\nlst.append(msg2.split(\"*\")[1])\n\nif lst[0]=='$STALK':\n  with serial.Serial('/dev/serial0', 4800, timeout=10, writeTimeout=0) as ser:\n      ser.parity = serial.PARITY_MARK\n      ser.write(binascii.unhexlify(lst[1]))\n      ser.parity = serial.PARITY_SPACE\n      for i in lst[2:-1]:\n        ser.write(binascii.unhexlify(i))\n      ser.close()\n\nreturn msg","outputs":1,"x":290,"y":140,"wires":[[]]}]


With this setup you can have bidirectional communication with the ST2000 and the autopilot app is fully functional, I have a very long ToDo list to keep adding functionality, as I mentioned before the ST40 emulation and also the OpenCPN waypoint navigation. This can be extended to any signalk event provided you translate it to a seatalk1 datagram and inject the message into the “Seatalk1 Out” node. 

If you (or any other member) need any further details feel free to enquire.

Cari20
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)