Hi all,
Please, I’m after some more help.
Finished my smbed-to-mbed synchronised PWM code but really struggling with the serial coms to the BMV.
Got all connected and terminal working well.
I used the SerialBufferedDemo code from Richard Sewell to write the data into a buffer
Terminal output varies but getting something like this every second as expected.
Bad byte 8b at 0
Bad byte 93 at 0
readBytes got 131
Done
I’ve been working on modifying the GPS_Test code to suit my identifiers and could really do with some help.
Its pretty much the same code but this is what I have
Main
#include "mbed.h"
#include "gps.h"
#include "data.h"
//Pin1-Vout, Pin2-rxp14, pin3-txp13, pin4-GND
int main() {
pc.printf("Device Starting.");
gps.baud(19200);
wait(0.25);
while(1) {
pc.printf("test point 1");
getGPSstring(1);
}
}
gps.h
#include "mbed.h"
#include "TextLCD.h"
#include "data.h"
DigitalOut led1(LED1);
DigitalOut led2(LED2);
DigitalOut led3(LED3);
DigitalOut led4(LED4);
Serial pc(USBTX, USBRX);
Serial gps(p13, p14);// BMV connection
TextLCD lcd(p21, p22, p23, p24, p25, p27, p28);
int parseGSV() {
gsv2 = strtok(gsv1, ",");
while (gsv2 != NULL) {
sep++;
switch (sep) {
case 1:
// # of sentences
lcd.printf("#:%s\n",gsv2);
break;
case 2 :
// Sentence # of #
lcd.printf("S#:%s",gsv2);
break;
case 3 :
// Number of Satellites in view (Should give a hint as to how many cases to expect here...
lcd.printf("#:%s\n",gsv2);
break;
case 4 :
// Satellite PRN Number
lcd.printf("PRN#:%s\n",gsv2);
break;
case 5 :
// Elevation in Degrees
break;
case 6:
// Azimuth in Degrees
break;
case 7:
// SNR - up to 4 satellites per sentence
break;
}
gsv2 = strtok(NULL, ",");
}
sep = 0;
return *gsv2;
}
int parseRMC() {
return 0;
}
int parseGGA() {
gga2 = strtok(gga1, ",");
while (gga2 != NULL) {
sep++;
switch (sep) {
case 1:
if (mode == 1) {
lcd.cls();
lcd.printf("Time:%s\n",gga2);
}
break;
case 2 :
if (mode == 2) {
lcd.cls();
lcd.printf("Lat:%s",gga2);
}
break;
case 3 :
if (mode == 2) {
lcd.printf("%s\n",gga2);
wait(0.25);
}
break;
case 4 :
if (mode == 2) {
lcd.cls();
lcd.printf("Lon:%s",gga2);
}
break;
case 5 :
if (mode == 2) {
lcd.printf("%s\n",gga2);
wait(0.25);
}
break;
case 6:
if (mode == 1) {
if (gga2 == "0") {
fix = "Invalid";
}
if (gga2 == "1") {
fix = "GPS Fix (SPS)";
}
if (gga2 == "2") {
fix = "DGPS Fix";
}
if (gga2 == "3") {
fix = "PPS Fix";
}
if (gga2 == "4") {
fix = "Real Time Kinematic";
}
if (gga2 == "5") {
fix = "Float RTK";
}
if (gga2 == "6") {
fix = "Estimated (Dead Reckoning)";
}
if (gga2 == "7") {
fix = "Manual Input Mode";
}
if (gga2 == "8") {
fix = "Simulation Mode";
}
lcd.printf("FIX: %s_%s",gga2,fix);
}
break;
}
gga2 = strtok(NULL, ",");
}
sep = 0;
return *gga2;
}
int getGPSstring(int str) {
if (gps.scanf("%s", &gpsString) ==1) {
if (str == 1) {
if (sscanf(gpsString, "$GPGSV,%s",gsv1) >= 1) {
sep = 0;
parseGSV();
}
return *gsv2;
}
if (str == 2) {
if (sscanf(gpsString, "$GPRMC,%s",rmc1) >= 1) {
sep = 0;
parseRMC();
}
return *rmc2;
}
if (str == 3) {
if (sscanf(gpsString, "$GPGGA,%s",gga1) >=1) {
sep = 0;
parseGGA();
}
return *gga2;
}
}
return 0;
}
Regards
John
Hi everyone,
I'm after some advice about connecting a battery monitoring unit victron BMV602 to the mbed. One initial problem is that the unit normally connects to PC via "rs232" output" using proprietary software. I have the spec sheet for the RS232 data formats which I can post, the unit provides a TTL output which is converted by the supplied cable to RS232 levels. But the second problem is I don't have that much experience with C or C++, microcontroller or rs232 protocol, despite this, I have been enjoying the mbed and put some code together, while I await delivery of the victon unit.
So I'm pretty new to everything...
I am trying to control the Mbed PWM output duty cycle % from a state of charge %value from the victron battery monitor. The PWM output code seems quite straight forward and I have put some code together that controls the PWM rate by an analogue input.
The signals on the BMV-602 serial link are non-isolated 3.3V logic levels. I have ordered the TTL to RS232 cable just incase! After doing some research am I write in thinking that the TTL levels can be connected directly into one of the three serial ports?
The Baud rate is 19200which seems quite standard and I can see how to adjust this parameter, although I am not sure how to access the required data field from the data. The forum work I have read “Reading GPS data” Richard Tennant writes the data out to a file all labels etc .
Any help and advice great fully received
Best regards
John