Hello,
I am a newbie in programming, so for my first project I needed it to be hardware oriented as well.
The hardware part comes in, when I thought of using one of the old TomTom GPS-mouse's we had lying around.
I wanted to see if and how an Arduino could make use of the information provided by this mouse.
One thing lead to another, so yet another GPS-clock is born.
I found the TomTom GPS-mouse has 4 wires:
Red = +5V
Shield = Ground
Brown = RS232 out
Orange = RS232 in (not used by me)
One interesting thing I found was: the TomTom GPS uses 5V as power, but does OUTPUT the "real" RS-232 signals. It seems it has a voltage-converter build in.
Meaning, the signal moves between +12Vdc and -12Vdc. To overcome this I used a simple (often copied) TTL-to-RS232 Vice-Versa converter. I used just the half part that converts RS-232 to TTL. It needs inverting as well, the -12Vdc in RS-232 must be a 'high' in TTL, to be readable characters.
To go step-by-step I just used one of the several output-strings the TomTom GPS gives, the $GPRMC-string.
My code is build on bits and pieces I found on this forum and elsewhere, I do hope I did put all the credits in.
For learning myself the Arduino code, I needed lots of comments, so every time I read it, there was an explanation.
Some may think it is overdone, but it helped me.
Although the program now works, I may need some extra help in actually understanding this part of the code, and to see if my explanation makes sense:
// show_time_date()Begin============================================================
void show_time_date(void) {
// For me this is the cool part, because the variables come out as integers.
// So we can make calculations with them
// I use the indices-array to point at the separators in the buffer, the variables I want are found 1 or 2 postitions behind the separator.
// For the hours we get de 1 or the 2 in eg. 15h or 23h, so I multiply by 10. The normal hours are just added to the previous value. ((1x10)+5) or ((2x10)+3)
// Explanation:
// Every serially received Character comes in as a Byte, containing 8 bits
// Eg. a received number '9' has an ASCII value of '39', which is '0011 1001' this a '3' and a '9'
// The '&0x0F' (&0x 0000 1111) "masks" the use of the left (higher) 4 bits, (0011) which is the '3' part, so the right (lower) part '9' (1001) gets through.
// So '&0xF0' (&0x 1111 0000) would allow for the '3' to get through.
// This (separated) '9' is than converted into an 'int' (integer) so we can use it in calculations.
// This is done with every individual number to get the full Time and Date.
// For the GPS-position we just use the Character 'A'(Active) or 'V'(Void).
myday = (((int)buffer[(indices[8])+1]&0x0F)*10)+((int)buffer[(indices[8])+2]&0x0F); // Since we know where the seperators are, we can can precisely identify the position of certain variables
mymonth = (((int)buffer[(indices[8])+3]&0x0F)*10)+((int)buffer[(indices[8])+4]&0x0F); // Since we know where the seperators are, we can can precisely identify the position of certain variables
myyear = (((int)buffer[(indices[8])+5]&0x0F)*10)+((int)buffer[(indices[8])+6]&0x0F); // Since we know where the seperators are, we can can precisely identify the position of certain variables
myhour = (((int)buffer[(indices[0])+1]&0x0F)*10)+((int)buffer[(indices[0])+2]&0x0F); // Since we know where the seperators are, we can can precisely identify the position of certain variables
myminute = (((int)buffer[(indices[0])+3]&0x0F)*10)+((int)buffer[(indices[0])+4]&0x0F); // Since we know where the seperators are, we can can precisely identify the position of certain variables
mysecond = (((int)buffer[(indices[0])+5]&0x0F)*10)+((int)buffer[(indices[0])+6]&0x0F); // Since we know where the seperators are, we can can precisely identify the position of certain variables
GPS_position_fix_indicator = ((int)buffer[(indices[1])+1]); // Since we know where the seperators are, we can can precisely identify the position of certain variables
// Since we know where the seperators are, we can can precisely identify the position of certain variables
/* The syntax is often as follows, depending on the version of the NMEA firmware the GPS receiver is using internally:
// indices are pointing at:
indexcounter = 0 1 2 3 4 5 6 7 8 9 10 12
$GPRMC,225446.123,A,4916.45,N,12311.12,W,000.5,054.7,191194,020.3,E*68
Here is a link to the full code I put together :https://drive.google.com/file/d/0B0OBe102ekzocUhYOVJBbXpDWTg/edit?usp=sharing
Un saludo,
Satbeginner

