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
Speed-Data directly from Sensor
#5
(2018-12-25, 10: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


Messages In This Thread
RE: Speed-Data directly from Sensor - by CVL - 2019-01-20, 11:08 AM
RE: Speed-Data directly from Sensor - by abarrow - 2019-01-07, 03:03 PM
RE: Speed-Data directly from Sensor - by abarrow - 2019-01-20, 03:42 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)