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.

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Speed-Data directly from Sensor
#1
Photo 
Hi there,

I'm a total newbie to this whole think. But now - after some weeks of learning - I've made myself a OP Sailcomputer.
The whole thing sits in a watertight case, having a step up/step down converter for power and a USB-Hub for internal
connections.

Photos here:

https://drive.google.com/open?id=1_aU9Ev...0wGgJ51YPA

https://drive.google.com/open?id=1hwZKbc...vcTAaL8unw



There is a USB-Plug, a Ethernet plug and a HDMI plug at the side of the case.
Here I have Internet conection over the Ethernet, coming from a Ubiquiti Bullet M2 and a Antenne which connects to harbor wifi.
The HDMI plugs in my monitor on board and the USB-plug is used to connect via another hub the GPS, AIS and the AP.
Cirrently I'm waiting for Jean's weather sensor and his AP-controller for steering my Simrad TP22.

Besides Monitor and Keybord at the chart table, I have a 10" tablet in the cockpit under the sprayhood with a VNC-Viewer.
Also I have a small mobile in a arm pouch, on which I have the polar data, the ideal course to the appearent wind and all tactical data.
I use sailinstruments and the nke app.

One of my problems was, how to get the data from my old speed sensor into the system. The old Bidata ST30 is working with seatalk and my first idea was to use a seatalk to nmea converter. I found some code on the internet I had to alter a bit and programmed my arduino, but it was not working out.
Then, instead of buying a converter cable for 100 bucks, I thought of getting one step deeper into the system.
The speed sensor is a hall sensor.Three wires. You put voltage and ground in and recieve a signal in the same voltage on the third line whenever the little wheel in the water spins.
Luckily I found a ready to use C-scetch for the arduino that reads this signal and makes a nmea string from it:

http://www.holdentechnology.com/2017/09/...eedometer/

Easy to install on the arduino. Only thing left was the issue of the ST30 using 12V and the arduino only working with 3,3V-5,5V. So I used a selfmade voltage devider, that gets everything from 11v to 14V and devides it down by 3.

Now I have a simple Y-split in the signal cable and the data is still on the display of the Bidata ST30 and additionaly as nmea data in the OP.
Works fine when my wife is simulating the water current and spins the wheel under the boat. ;-)) Can't wait to use it in the water and calibrate it. 

Its not my invention. All credits go to Mr Mike Holden and its code. But maybe it will help anybody here with the same problem.
_____
OP on Raspberry Pi 3+
OpenCPN tactics plugin compiled on raspbian
Step up/step down power converter
AIS and GPS over USB / Serial2USB
Speed data converted directly from Sensor to NMEA by arduino
Wind data: Davis anemometer using Pypilots weather sensor
Pypilot driving Simrad TP22 Tillerpilot

  Reply
#2
The problem with Seatalk is that it uses 9-bit sentences. The UART uses 8 Bits by default. I'm not an Arduino expert, but I think you can read 9-bit sentences with Arduino.
Another possibility is to use a SeaTalk to NMEA converter like this one https://www.ebay.com/itm/SEAYAK-Seatalk1...:rk:5:pf:0
or this more complete one: https://ocenav.com/en/base-stations-atm105a/, with which you can integrate all marine communication standards.

More complicated, you can read the pulses from the speed sensor directly with a GPIO from the Raspberry Pi. As the hall sensor produces, as you said, 12 Volt pulses. This voltage must first be reduced to the 3V input of the Raspberry GPIO, for example by using a voltage divider mounted as a pull down system,
[Image: pull-down-abierto.png]

although the best system is by optoisolation, for example with the 4n25 or better with the LTV817

[Image: Raspberry-Optocoupler.jpg]

That if, it will be necessary to write a program in Python to read the pulses and to turn them into speed
  Reply
#3
Hi gypsylon,

Yes, you can read seatalk 9-bit with the arduino mega. That works, but than you have to write a sketch to transform it to nmea. I have none, so you have to write your own.

You idea of reading the pulses of the speed sensor directly with the raspberry pi might work. But as you noticed, you will need optoisolation and - again - some piece of script that translates it into nmea. Here too, I have no such script and you have to develop you own.

So - the easiest way is to rrad the pulses of the speed sensor with an arduino and use the sketch of Mike Holden (see link above) to translate them to nmea.
No hassle with optoisolation and a ready to use piece of software.
For reducing the 12V of the sensor to readable 3.3-5.2V your pull down resistor should work.

If you run into any probs, just send me a pm. Should be easy to copy my running solution to your environment.....
_____
OP on Raspberry Pi 3+
OpenCPN tactics plugin compiled on raspbian
Step up/step down power converter
AIS and GPS over USB / Serial2USB
Speed data converted directly from Sensor to NMEA by arduino
Wind data: Davis anemometer using Pypilots weather sensor
Pypilot driving Simrad TP22 Tillerpilot

  Reply
#4
I notice you have a Quark-Elec box there. You could potentially sell that one and purchase their AIS/GPS/SEATALK box. It's excellent. Another way if you still have a Raymarine repeater in your Seatalk bus like an ST-60, is to look for the NMEA output on them. Many of them that used the old original SEATALK had NMEA outputs. I found on my ST-60+ display output I had to write a Node-Red script to add checksum.

If all that fails, I agree with the brain-trust here: take the output from the sensor directly into an Arduino or ESP, count the pulses and determine speed and log from that. Arduinos can be made to read 9-bit data with a modified Serial module, but it also requires changing levels and ideally optical isolation.
  Reply
#5
(12-25-2018, 05:52 PM)gypsylyon Wrote: More complicated, you can read the pulses from the speed sensor directly with a GPIO from the Raspberry Pi. As the hall sensor produces, as you said, 12 Volt pulses. This voltage must first be reduced to the 3V input of the Raspberry GPIO, for example by using a voltage divider mounted as a pull down system,

That if, it will be necessary to write a program in Python to read the pulses and to turn them into speed

I connected the paddlewheel sensor (an old VDO sensor) directly to GPIO. But it's a little bit more of quick'n dirty hack: Instead of feeding 12V, it works well even with 5V which I forked off the Pi power supply.
No opto-isolation, but just a voltage division with 1kO-resistance to get 3.3V on pin 24

and then a simple phython script to transform the pulses into NMEA-sentences, which are fed to kplex with a FIFO:


Code:
#!/usr/bin/python
import RPi.GPIO as GPIO
import time
import os

GPIO.setmode(GPIO.BCM)
GPIO.setup(24, GPIO.IN, pull_up_down = GPIO.PUD_UP)

path = "/var/run/nmea.fifo"
os.mkfifo(path)

fifo = open(path, "w")
fifo.write('$VWVHW,,,,,0,00,N,,K\r\n')
fifo.close()

impulse_count = 0
NUM_CYCLES = 100
Counter = 100
while 1:
   start = time.time()
   for impulse_count in range(NUM_CYCLES):
       GPIO.wait_for_edge(24, GPIO.FALLING)
   duration = time.time() - start

   Counter = Counter + 100
   distance = Counter / 27368
   distancer = round(distance,2)
   speed = 7.6 / duration
   speedr = round(speed,2)
   nmea = '$VWVHW,,,,,' + str(speedr) + ',N,,K\r\n$VWVLW,,N,' + str(distancer) + ',N\r\n'

   fifo = open(path, "w")
   fifo.write(str(nmea))
   fifo.close()

   time.sleep(0.5)

GPIO.cleanup()


The values are experimental, I found it very hard to get documentation on how many pulses the sensor should give for 1 nautical mile.

This worked nicely during our summer cruise last summer, even though it can surely be made better.

Fair winds
Christian
  Reply
#6
Very nice! My old Raymarine paddlewheel is calibrated by doing measured distance calibration runs in opposite directions.

This might be something that could be added to your script to get more accuracy.
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)