Centrale de navigation Low Cost sur plateforme Arduino - présentation
Publié le 22 Octobre 2013
Projet: réaliser une centrale de navigation sur base de processeur Arduino qui diffusera les données NMEA via le Wifi sur Tablette (instruments) et PC portable (navigation).
Outre Arduino, ce projet s'appuiera sur les logiciels:
- OpenCPN pour la navigation
- PolarCOM, multiplexeur NMEA, afficheur instruments sur Linux
- Iregatta, logiciel tactique dédié régate sur tablette Android
La réalisation sera totalement openSource sur ubuntu.
Références:
Le site qui a déclenché l'idée et montre les capacités étonnantes des liseuse (encre électronique) pour l'affichage des instruments: http://www.holdentechnology.com/sailing-and-fun
Multiplexeur NMEA sur base Arduino: http://pagesperso.univ-brest.fr/~flye/Instrumentation.html
Iregatta: https://play.google.com/store/apps/details?id=dk.letscreate.aRegatta&hl=fr
GPS Module: http://learn.parallax.com/KickStart/28500
Le routeur WIFI basse consommation: http://wiki.openwrt.org/toh/tp-link/tl-mr3020
Site de référence Arduino: http://www.arduino.cc/
Site d'approvisionnement pour Arduino et batteries Lipo low cost: http://www.hobbyking.com/hobbyking/store/index.asp
La carte Arduino Mega 2560, le mini routeur TP Link, trames NMEA sur OpenCPN et les instruments virtuels de PolarCOM
Les instruments (d'époque !) toujours opérationnels Pen Lann mariner 6
Spécifications
NMEA multiplexer (Arduino Mega car 4 ports série)
Inputs:
GPS (NMEA)
Speedo, Wind Angle and Strength sensors
AIS (option à étudier)
Outputs:
NMEA over Ethernet
NMEA over USB and RS232
Web server
Other:
Datalogger
WiFi Router
Ubuntu Notepad
OpenCPN
Cockpit tablet instrument display
Samsung Galaxy Tab2 10.1
Mast display
Tablet or 7segment led display (to define)
Un POC à la maison qui semble prometteur
Code du POC Arduino
les potentiomètres représentant les capteurs wind angle, wind speed, water speed sont sur les PINs analogiques 5,4 et 3.
Arduino est sur l'adresse 192.168.0.177, port 9999 et transmet trois trames NMEA (MRC, MWV, VHW) toutes les 500 ms.
///////////////////////////////////////////////////////////////////////////////////////////////////////////
include <SPI.h>
#include <Ethernet.h>
//#include <string.h>
char CSSentence[85] = "" ; //string for sentence assembly
char MRCSentence[85] = "" ;
char MWVSentence[85] = "" ; //string for MVW for sentence assembly
char VHWSentence[85] = "" ; //string for VHW sentence assembly
char NMEASentence[85] = "" ; //string for NMEA sentence
int cs ; //checksum
// network configuration. gateway and subnet are optional.
// the media access control (ethernet hardware) address for the shield:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
//the IP address for the shield:
byte ip[] = { 192, 168, 0, 177 };
// the router's gateway address:
byte gateway[] = { 192, 168, 0, 1 };
// the subnet:
byte subnet[] = { 255, 255, 255, 0 };
// telnet defaults to port 9999
EthernetServer server = EthernetServer(9999);
void setup()
{
// initialize the ethernet device
Ethernet.begin(mac, ip, gateway, subnet);
// start listening for clients
server.begin();
}
void loop()
{
// analog pin 5 is wind angle
// analog pin 4 is wind speed
// analog pin 3 is water speed (speedo)
// if an incoming client connects, there will be bytes available to read:
EthernetClient client = server.available();
/////////////////////////////////// Create MRC Sentence (GPS simulation)
strcpy(MRCSentence, "GPRMC,220516,A,5133.82,N,00042.24,W,3.8,4.8,130694,004.2,W"); // MRC sentence is simulated
// /////////////////////////////////Create MWV Sentence - Wind Speed and Angle
char b[50]="0";
char c[50]="0";
int Z = 0;
//Assemble a sentance of the various parts so that we can calculate the proper checksum
strcpy(MWVSentence,"PIMWV,"); //The string could be kept the same as what it came in as, but I chose to use the P (prefix for all proprietary devices) and I for instrument
//read Pin 5 : Relative wind Direction
Z=analogRead(5)/2; // Wind Direction can go from 0 to 360°
sprintf(b,"%d",Z);
strcat(MWVSentence, b);
strcat(MWVSentence, ",R,");
//read Pin 4 : Relative Wind Speed
Z=analogRead(4)/2; // Wind speed can go from 0 to 50 knots
sprintf(b,"%d",Z/10); //b represent the knots
sprintf(c,".%d",(Z-(Z/10)*10)); //c represent the deci knots
strcat(MWVSentence, b);
strcat(MWVSentence, c);
strcat(MWVSentence, ",N,A"); //the atoi command truncated the decimals, might as well stick .0 back on in case something is expecting this field to have a decimal
////////////////////////////////////Create VHW Sentence - Boat speed (water speed)h
//read Pin 3 : Boat Speed
Z=analogRead(3)/5; // Speed from 0 to 20 Knots - resolution of 0.1 Knots
//dtostrf(z, 5, 2, b); //dtostrf(floatVar, minStringWidthIncDecimalPoint, numVarsAfterDecimal, charBuf)
strcpy(VHWSentence, "PIVHW,,T,211,M,");
sprintf(b,"%d",Z/10); //b represent the knots
sprintf(c,".%d",(Z-(Z/10)*10)); //c represent the deci knots
strcat(VHWSentence, b);
strcat(VHWSentence, c);
strcat(VHWSentence, ",N,0.0,K");
////////////////////// NMEA to Ethernet //////////////////////////
EtherNMEA(MRCSentence);
delay (10);
EtherNMEA(MWVSentence);
delay (10);
EtherNMEA(VHWSentence);
delay (300);
}
// ////////////////////// Functions ////////////////////////////////////
String Checksum(char* CSSentence) {
cs=0; //clear any old checksum
char b[50]="0";
//return b;
for (int n=0; n < strlen(CSSentence); n++) {
cs ^= CSSentence[n]; //calculates the checksum
}
sprintf(b,"%02X",cs);
return b;
}
void EtherNMEA (char* NMEASentence) {
server.print("$"); // Assemble the final message and send it out the serial port
server.print(NMEASentence);
server.print("*");
server.print(Checksum(NMEASentence)); // Call Checksum function
server.println();
}
Next Step:
Connexion du module GPS