Panteltje's xgpspc, a Raspberry Pi based navigation system for boats
This project is released under the GPL license
Added anchor alarm.
I want to point out the lookup routines for shipname and callsign from MMSI in ais.c.
Downloaded the roepletterlijst-scheepvaart.csv from the Agentschap Telecom website, then made a new list with MMSI in increasing order.
Used successive approximation to find the (sometimes approximate) callsign and shipname in just 15 steps,
then did a linear search of maximum 10 steps in the right direction if it is not a hit at that position.
This is very fast, so I could hang it in the AIS processing where it is only executed if a new MMSI is added to the structure list.
This results in shipname and callsign immediately shown even if just a message type 1 is received,
as all we need is the MMSI, makes it simpler to call 'Vessel Atlantis' or whatever.
For now this uses a 60000 position array, for sure if I ever get the world wide list maybe use malloc(),
but the successive approximation makes sure that even then the MMSI is found in just a few steps.
There is a test program ais_name_lookup_test.c supplied in the tgz archive, compile it with
gcc -Wall -o ais_name_lookup_test ais_name_lookup_test.c
then run it like:
it will ask for an MMSI, and find the callsign and shipname in record time.
So for now only for Dutch MMSIs.
That code is of course integrated in xgpspc.
The modified list must be in ~/.xgpspc/
testing cheap Chinese ethernet cables from ebay for wet salty environment
Multiple waypoints and auto proceed to next one.
Also I did some work on the steering motor.
I decided that as we need galvanic isolation, and serial via USB numbering (say re-numbering) on Raspi (or Linux in general) SUCKS,
why not use ethernet?
It provides the isolation. and even waterproof ethernet connectors exist.
It need not be more complicated, I wrote an UDP stack, programmed a PIC, and for the ethernet use a 3$ ENC28J60 based ebay module.
This can drive the stepper driver step_pic I wrote via RS232 _in_ the same box, step_pic drives an ebay stepper motor driver
As that is becoming a project of its own, I gave it its own web page: udp_steering_unit
NEW: added import for .csv format markeringen from http://126.96.36.199/customizeddownload/
many code changes, more threads, see CHANGES, this is a mayor re-write, chart format now in degrees,
make your own charts from google maps with the supplied modified scripts from
http://www.bdcc.co.uk/Gmaps/ll_grat_v3_demo.htm make-map.c make_map.html and make_map.js
the modified scripts put the lat lon limits of the chart at the bottom of the page so you can paste into a xgpspc compatible filename directly,
work in progress.
testing with stepper motor for tiller steering, see README, step pulse from Raspberry frequency output.
Ordered this ballscrew plus ballnut to drive the tiller,
stepper plus ballscrew and ballnut should be in a waterproof housing with only some rod extending, use end stop optos,
or maybe just use dyneema and keep the mechanics inside and dry.
Ballscrew with ballnut arrived, curious about the pull strength, dyneema fishing line good for 300 pounds...
23 lb, say 10 kg, using step_pic as driver at 1000 Hz, not very fast.
Anchor drift and water in boat alarm with SMS and PMR radio alert
Hit 'a' key with cursor in screen to activate, 'b' key to deactivate, numlock + and - sets range in steps of 5 meters, default 50 meter.
Added a system() call in io.c to a bash script /usr/local/sbin/xgpspc_alarm.
You can modify that to do things without changing the code.
In the provided example a SMS can be send with the script /usr/local/sbin/ssms if you have a 3G / 4G USB modem stick,
this SMS contains the distance, the location, and the magnetic heading at the time the limit was exeeded.
Also I use GPIO 25 pin 22 to activate my Baofeng porto transmitter,
in this case to send a voice message with the festival speech synthesizer on a channel the Baofeng should be set to.
If you have a ham license you can use this, or maybe use it to send a PMR (free band) radio message,
so if no cellphone coverage and you are shopping on land, you will still be alerted if your boat is hijacked or drifts away.
Modify scripts as needed.
The system("/usr/local/sbin/xgpspc_alarm") call is only executed again after 15 minutes if the alarm condition persists,
this is to prevent your SMS prepaid being depleted, or to prevent radio congestion.
Note that in case of hijack the position is transmitted every 15 minutes.
Also added a water sensor and alarm.
You can use a simple phono connector in the bilge as detector, one side is ground, see circuit diagram below.
SMS is send (or radio voice message) every 10 minutes if water is detected and anchor alarm is on.
Serial out 9600 Bd RYN25AI UBLOX-7 based GPS / GLONASS module is connected to /dev/ttyAMA0 on GPIO.
There is also a MPU6050 acceleration sensor (ebay), a HMC5883L compass module (ebay), and a BMP180 pressure module (ebay), all these modules run on 5 V.
Included in the archive is the asm and hex source for an experimental PIC 18F14K22 based temperature based wind direction and speed sensor that should be connected to an USB interface via a serial to USB module (ebay).
Quite a bit of effort was made to make the software crash proof.
The system is designed to display on an small 800x480 monitor, an analog NTSC or PAL monitor is no longer recommended as it does not display the small characters.
but can also be accessed remotely with a web browser, or even netcat.
If you plug in a access point capable WiFi module it will create an access point where you can see the data, position, AIS of other ships, wind direction, and direction and distance to next waypoint.
Waypoints are supported.
Server access via wire:
192.168.178.73:8073/index.html (graphics charts, refresh every 6 seconds).
192.168.178.73:8073/text.html (text only, position etc, refresh every 2 seconds).
netcat 192.168.178.73 8073 will show all data.
In case of WiFi access point the IP address is 192.168.178.74:8073
Of course if you plug in an external WiFi access point, like I have a Linksys, then it is ..73 again.
For AIS I use a slim_jim antenna, rtl_fm, aisdecoder, rtl-sdr and DVB-T USB stick, xgpspc listens on UDP port 10123, and I run a script like this:
rtl_fm -f 161975000 -p 49 -s 48k -r 48k | aisdecoder -h 127.0.0.1 -p 10123 -a file -c mono -d -f /dev/stdin
The -p 49 is the frequency correction and needs to be very precise and differs from one DVB-T stick to an other,
I wrote a script to try all values, let it run overnight, and picked the one that showed the most ships.
Screen shot, the white line is the magnetic direction where the boat is heading, the yellow line points to the next waypoint, the red arrow is the wind.
The litte black boxes are the MSIs of the AIS transmitters received, with their distance (white) and a white line showing their direction, size proportional to speed (these are on a canal inland).
The software expands all direction and speed vectors and tests for crossings at the same time within some specified time, collision detection.
screen shot north up mode
Screen shot with collision alert, as we are heading directly towards the 3 km away anchored (no speed vector) AIS object.
The green AIS object indicates a reception timeout, maybe was turned off.
browser screen shot north up mode, with AIS callsign and shipname, proximity alert.
screen shot browser north up with AIS info on right, and collision alarm detection by extrapolating speed and direction vectors.
Note that each AIS object now has an ID number, the listing on the right side shows the info for each ID number.
This makes it easier to read all info if AIS objects are closer together.
There are now many more buttons to select display modes...
browser screen shot version 0.7.8 with more buttons...
Note the GLONASS text at the top of the screen to indicate receiving GLONASS (it reads GPS for GPS).
The 'P' button selects GPS mode, the 'L' button GLONASS.
Pressing the 'H' button displays a help text explaining what each button does..
browser screen shot heading up mode
The purple color of the 3 km away AIS object indicates proximity alert.
browser screen shot text mode
GPIO interface board
GPIO interface board component side
thermal wind sensor test setup
Basically this acts as a wet finger to feel what direction the wind comes from.
The diodes at that side will be cooled of a bit, and their voltage drop will change, this is measured.
Important is to note that the resistors actually heat the diodes! The resistors and diodes need to be free from the mounting tube.
It is a differential system: front versus rear -, left versus right voltage drop.
The PIC 18F14K22 has plenty of analog inputs and a 10 bit ADC, here used with the PICs 2 V internal reference.
Thing should be kept out of the sun, and away from water splashes, perhaps high up in the mast under a sun screen?
The GPS module is in a separate box, connected with a flexible cable, so it can be placed in a position with good reception.
GPS box inside
New RYN25AI UBLOX-7 based GPS / GLONASS module
USB to serial adaptor, I added a .47 uF tantalum cap to reduce RF on the 3,3 V pin and output, maybe they forgot the decoupling cap?
I also added a PNP pulldown as the module requires 5 mA pulldown on data in, I see a wrong resistor value mounted (1 k while its says 1.5 k on the solder screen) so YMMV with these serial to USB ebay modules.
Anyways the serial adaptor is not really needed, and do not put its output and GPIO ouput in parallel! Was just for test, USB serial does NOT work right on Raspi!!!
Although this GPS box has a serial to USB adaptor (ebay), the Raspberry Pi cannot keep up with the speed, the USB sucks big time, even drops characters from a USB keyboard sometimes.
For this reason I use the GPIO /dev/ttyAMA0 serial interface directly (only the RX side).
The GPS module is now an RYN25AI UBLOX-7 based GPS / GLONASS one that sends by default data at 9600 Bd every second.
For the very slow data rate of the wind sensor USB seems to work OK so far.
An other big problem with that USB is renumbering if there ever is a bad contact or whatever, basically it is total shit, seems to be a MS invention.
In my view (tm) maybe if you need many UARTs, then use an FPGA add on board for the Raspi, and avoid USB at all cost.
The other thing required is galvanic isolation for the serial data from the PIC in the wind sensor to the Raspberry, use an optocoupler (it is only one way 4800 Bd).
Glassfiber or something would work too.
Full sources in C and asm and bash:
Note: This is GPL Linux software, also if you download this file use right mouse 'save as', else you get a messed up screen,
return to main page