Posts: 7
Threads: 1
Joined: Aug 2024
Reputation:
0
Hello. This is just proof of concept but here is a quick video of a Raspberry Pico sending auto pilot commands to a Raymarine autopilot computer. I had it reading the Seatalk data from the Seatalk bus as well. Could be a cheap method of providing 433mhz wireless remote control of autopilot for when you need to dodge the ferries while putting fenders out on the foredeck coming into port. If anyone is interested I'd be happy to share the Micropython code. (Not my work, someone showed me how to do 9 bit serial with a Pi Pico and PIO).
Image is of a discarded custom PCB I made for my boat. I'm hijacking the transistors here to get the data onto the Seatalk bus.
http://kitcat.club/ki/STPico.mp4
Seatalk pico npn
Posts: 1,277
Threads: 105
Joined: Mar 2016
Reputation:
79
(2024-10-31, 06:23 PM)jimseng Wrote: If anyone is interested I'd be happy to share the Micropython code. (Not my work, someone showed me how to do 9 bit serial with a Pi Pico and PIO).
Hugely interested!!!
(Getting a 403 forbidden with your links)
Posts: 7
Threads: 1
Joined: Aug 2024
Reputation:
0
Sorry about the link permissions. Sorted now.
So I'm having trouble attaching things. I tried attaching a couple of Python scripts but it said "not allowed". So here is a zip file with two .py files. One is for receiving Seatalk data and one is just a test to send data as per the video.
http://kitcat.club/ki/Pico_pio_Seatalk.zip
The receive .py file reads seatalk data and sends it via a udp socket. Obviously it requires the usual opto set up as per this https://demo.signalk.org/documentation/s...atalk.html
I used this to test receiving seatalk data into the Pico and sending it to a Signalk dashboard instrument.
Sending seatalk requires building a simple interface with 2 transistors and two resistors.
I followed the "schematic" in the python script from here:
https://github.com/marcobergman/remote_p...ree/master
So far all I have done is tested it works, just to prove the Pi Pico 9 bit serial conecpt using PIO. I got as far as testing a cheap 433 mhz key fob from Amazon. In the attached script, it just toggles between auto and standby in the main loop, but it could be adapted for 433mhz wireless control or perhaps an auto helm repeater station.
Sorry if this is a bit rough and ready, I didn't know if anybody would be interested and since I am not on my boat right now so I can't be sure these still work. But they did! I just wanted to see if a £6.00 micro controller could embed itself in the seatalk bus. It might be useful. Let me know what you think and if I can help. And please someone, improve my code!
Posts: 1,277
Threads: 105
Joined: Mar 2016
Reputation:
79
Thanks so much! Spose I'll have to by a Pico now
Posts: 7
Threads: 1
Joined: Aug 2024
Reputation:
0
You haven't got several? I love 'em. I have 3 on my boat. (Well rp2040 based things anyway)
Posts: 1,277
Threads: 105
Joined: Mar 2016
Reputation:
79
(2024-10-31, 11:37 PM)jimseng Wrote: You haven't got several? I love 'em. I have 3 on my boat. (Well rp2040 based things anyway)
Got an extended family of esp8266 & esp32 onboard, even the fridge thermostat is an esp32 taking to signalk
Don't think they will do 7 bit comms though, or haven't found a way yet anyway. Pico on it's way from Amazon
It's actually one of the last few things that would be useful cruising, logging seatalk depth & waterspeed to check what the tides really do where you are.
Posts: 1,277
Threads: 105
Joined: Mar 2016
Reputation:
79
2024-11-05, 09:29 AM
(This post was last modified: 2024-11-05, 09:30 AM by PaddyB.)
Going OK so far, I got a Pico but not one with wifi so deleting the network related stuff it boots OK & sends test messages from serial so looking hopeful!
And for anyone struggling with code, https://www.perplexity.ai/ can be very useful!! Think it uses chatgpt.
Code: this is micropython running on a raspberry pi pico, explain what it does - def PioRx9N1(BITS=9):
wait( 0, pin, 0)
set(x, BITS-1) [10]
label("rxloop")
in_(pins, 1)
jmp(x_dec, "rxloop") [6]
push()
Code: The provided MicroPython code snippet is designed to run on a Raspberry Pi Pico and implements a simple input reading loop using the Programmable Input/Output (PIO) feature of the RP2040 microcontroller. Here’s a breakdown of what each part of the code does:
Code Explanation
python
def PioRx9N1(BITS=9):
wait(0, pin, 0)
set(x, BITS-1) [10]
label("rxloop")
in_(pins, 1)
jmp(x_dec, "rxloop") [6]
push()
Function Definition:
def PioRx9N1(BITS=9): defines a function named PioRx9N1 that takes an optional parameter BITS, which defaults to 9. This parameter likely specifies the number of bits to read from the input.
Wait Command:
wait(0, pin, 0) instructs the PIO to wait until a specified condition is met. Here, it waits for the pin to be low (0). This is typically used to synchronize the start of data reception.
Set Command:
set(x, BITS-1) initializes a counter variable x to BITS - 1. This sets up the loop counter for how many bits will be processed.
Label Definition:
label("rxloop") defines a label named "rxloop" that can be used as a target for jumps in the program flow. This is useful for creating loops.
Input Command:
in_(pins, 1) reads data from the specified pins. The second argument indicates how many bits to read at once (in this case, 1 bit).
Jump Command:
jmp(x_dec, "rxloop") decrements the counter x and jumps back to the "rxloop" label if x is not zero. This creates a loop that continues until all bits specified by BITS have been read.
Push Command:
push() saves the current state of the PIO's registers onto a stack. This is often used to store data temporarily for later use or processing.
Summary
This function effectively implements a loop that waits for a signal on a specified pin, reads a specified number of bits from that pin, and processes them in a continuous manner until all bits are captured. The use of PIO allows for efficient handling of input signals directly on the microcontroller without needing extensive CPU intervention, making it suitable for high-speed data acquisition tasks.
Look about right jimseng(AIs do make stuff up quite often)? Some of that micropython is unfamiliar to this esp8255/esp32 micropython user And thanks again!!
Posts: 7
Threads: 1
Joined: Aug 2024
Reputation:
0
Ah. Well, as I hopefully made clear, the PIO stuff was shared with me on the Rpi Pico forums. I asked a question and someone said here, try this. I don't know anything about the PIO side of the Pi Pico (well I do now after your AI post!) I initially went down this road as my Pi 5 was unable to read 9 bit Seatalk, until someone else far cleverer than me came up with a solution. I thought surely a Pico could do it. I think it would be handy to be able to pop a Pico into the Seatalk mix if needed. I got as far as reading the Seatalk data in and with the wifi version of the Pico had it transmitting $STALK strings via UDP to SignalK. The Seatalk_Build function of the receiving script is possibly not the most elegant way of constructing Seatalk datagrams but it works for me.
I'd like to try building a super cheap wireless remote for the autohelm. I reckon it could be done for about £15.00.
Glad you got things working.
Posts: 1,277
Threads: 105
Joined: Mar 2016
Reputation:
79
Yay!! It works. Just tried it, the nmea0183 coming out of the Pico didn't have a checksum but adding that manually came up with on signalk recognised.
fantastic, been wanting to get log/depth data into signalk & influx for so long
Adding a checksum should be easy enough.
Posts: 7
Threads: 1
Joined: Aug 2024
Reputation:
0
I was thinking of building a rev counter with a Pico in the engine room (or should that be "room", if I were to be modest) and injecting it into the seatalk bus. I probably should do some proper collision management though. Endless possibilities. Glad you got it working.
|