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
Is it posible to have Seatalk1 output?
#11
i would go another way to deal with these old protocols,
just use an ESPxx and its USB or WiFi Port to communicate with the pi.
Reply
#12
ESP32s have to bit-bang as well, but libraries for that are fairly well known. Arduino Unos or Megas will do 9 bit data in their installed UARTs.

If you have one of the Yak products, if you look inside they have what looks like a Teensy or Arduino, and only a few extra parts. Adding more (and the appropriate programming) is do-able.
Reply
#13
Does anyone have a working bit of code that runs on an ESP32 that reads Seatalk1 and feeds it to SignalK?
Reply
#14
(2024-05-21, 04:26 PM)broosmaxim Wrote: Does anyone have a working bit of code that runs on an ESP32 that reads Seatalk1 and feeds it to SignalK?

sorry, I don't have, but what is the reason to use ESP32 instead of a simple optocoupler and some shielded cable?
███ - SV Haimana
Reply
#15
If you use an ESP32, you'll have to bit-bang. The internal UARTs can't be set to 9 bit data.
Reply
#16
(2024-05-21, 05:43 PM)abarrow Wrote: If you use an ESP32, you'll have to bit-bang. The internal UARTs can't be set to 9 bit data.

Hi everyone! Along the above lines would a raspberry pi pico work? If the current code is python it might be portable to micro python and then run on the pico without too much modification? And then use usb or i2c? I appreciate the 9bit argument
Reply
#17
(2024-05-25, 11:13 AM)WT380 Wrote:
(2024-05-21, 05:43 PM)abarrow Wrote: If you use an ESP32, you'll have to bit-bang. The internal UARTs can't be set to 9 bit data.

Hi everyone! Along the above lines would a raspberry pi pico work? If the current code is python it might be portable to micro python and then run on the pico without too much modification? And then use usb or i2c? I appreciate the 9bit argument

It would be very reasonable to use a RPi Pico to do the bit-banging to transmit and receive ST1. It has a low-level I/O driver that is perfect for that kind of thing.
Reply
#18
Pretty sure I have pico code somewhere which can run 9 bit so inputs 9 bit seatalk & sends out nmea0183 over USB. Will have a hunt later
Reply
#19
(2025-10-27, 07:54 AM)PaddyB Wrote: Pretty sure I have pico code somewhere which can run 9 bit so inputs 9 bit seatalk & sends out nmea0183 over USB. Will have a hunt later

This **might** be the code which works on a Pico, micropython

Code:
timestamp = None
send_cmd=True
from   machine import Pin,Timer
import time
tmrsuppress=Timer(-1)

from   rp2     import asm_pio, PIO, StateMachine

Helm_Bytes=[[0x01,0xFE],[0x02,0xFD],[0x06,0xF9],[0x08,0xF7]] #2 bytes for auto, 2 for standby.

TX_PIN = 0
RX_PIN = 1
BAUD   = 4800

@asm_pio(sideset_init = PIO.OUT_HIGH,
         out_init     = PIO.OUT_HIGH,
         out_shiftdir = PIO.SHIFT_RIGHT,
         fifo_join    = PIO.JOIN_TX)
def PioTx9N1(BITS=9):
    pull()            .side(1)  [7]
    set(x, BITS-1)    .side(0)  [7]
    label("txloop")
    out(pins, 1)
    jmp(x_dec, "txloop")        [6]

@asm_pio(set_init     = PIO.IN_HIGH,
         in_shiftdir  = PIO.SHIFT_RIGHT,
         fifo_join    = PIO.JOIN_RX)
def PioRx9N1(BITS=9):
    wait( 0, pin, 0)
    set(x, BITS-1)              [10]
    label("rxloop")
    in_(pins, 1)
    jmp(x_dec, "rxloop")        [6]
    push()

# Need to initialise RX first if using same pin for TX

rxPin = Pin(RX_PIN, Pin.IN, Pin.PULL_UP)
rx = StateMachine(0, PioRx9N1, freq=BAUD * 8, in_base=rxPin)
rx.active(1)

txPin = Pin(TX_PIN, Pin.OUT, value=1)
tx = StateMachine(1, PioTx9N1, freq=BAUD * 8, sideset_base=txPin, out_base=txPin)
tx.active(1)

def Tx(n):
    print("TX  >  {:>03X}  {:>09b}".format(n, n))
    tx.put(n)

def Rx():
    n = rx.get() >> 23
    print("RX  <  {:>03X}  {:>09b}".format(n, n))
    return n

def AnyAvailable():
    return rx.rx_fifo()

# Flush any data caused by confguration glitches

time.sleep(0.1)
if AnyAvailable():
    print("Flushing\n")
    while AnyAvailable():
        discard = Rx()
        if not AnyAvailable():
            time.sleep(0.1)
    print("")
def suppress_repeat(nothing):
    global send_cmd
    print("###")
    send_cmd=True
    #LastSend=0
   
   
def Send_Ahelm(cmd):
    try:
        global Helm_Bytes,send_cmd
     
        print(cmd)
        Tx(0x186) #command byte  AH attribute
        Tx(0x11)  #AutoHelm attribute
        for i in range(2):
            Tx(Helm_Bytes[cmd-1][i])
          #  time.sleep(0.001)
        send_cmd=False
       
    except:
        print("error")
  
while True: # just send auto/standby every second as a proof of concept.
    Send_Ahelm(1)
    time.sleep(2)
    Send_Ahelm(2)
    time.sleep(2)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)