Oh no - not another GPS logger

nerdegutta

Senior Member
Hi, so I've made a GPS logger.

Everything seems to work fine, but when I read the data back from the 24LC16b EEPROM, something strange is happening. It looks like the EEPROM address has moved one place too far. I've not seen any pattern. Sometime all data is read back perfect, and other times the last digit in the Lon has become the first digit in the Hour.

I'd appreciate if someone could see if I've made any obvious mistakes in my program, or in my schema.

The idea: I will have the GPS logger in my pocket/backpack. It will receive GPS data, and store it on a 24LC16b EEPROM. When I get home, I want to download the GPS data to my computer, and bring it up in Google Earth.

This is my schema:
GPSlogger.png

The GPS-module is a EM-411, sending NMEA sentences.

The program is attached. I have used a lot of comments in the program. :)

- nerdegutta
 

Attachments

hippy

Ex-Staff (retired)
Code:
save_data_to_24lc16b:
	hi2cout Mempos, (Hour1): pause 10
	Mempos = Mempos + 1: hi2cout Mempos, (Hour2): pause 10
	::
	Mempos = Mempos + 1: hi2cout Mempos, (LonMin5): pause 10
return
After you write the last data 'LonMin5' you don't seem to increment the 'Mempos' pointer, so next time round you write the new 'hour1' data over the same location which was used to hold 'LonMin5'.

You either need to increment 'Mempos' before writing 'hour1' or after 'LonMin5'.

There's a similar bug in your 'send_log_to_pc:' routine and in other code #rem'd out.
 

nerdegutta

Senior Member
Hi hippy.

There's still a bug. I've gone through the code over and over, but I can't seem to find/understand the error.

I'm a bit confused....:confused:

- nerdegutta
 

nerdegutta

Senior Member
I've noticed a pattern....

It seems like when retrieving the values, the last 14 entries are correct.

Code:
<?xml version="1.0" encoding="UTF-8"?>
<gpx version="1.0">
<trk>
<trkseg>
<name>Track</name>
<trkpt lat="72.1018" lon="45.4439"><time>2013-01-01T81:00:00Z</time></trkpt>
<trkpt lat="72.1018" lon="45.4439"><time>2013-01-01T81:00:00Z</time></trkpt>
<trkpt lat="72.1018" lon="45.4439"><time>2013-01-01T71:00:00Z</time></trkpt>
<trkpt lat="72.1018" lon="45.4439"><time>2013-01-01T71:00:00Z</time></trkpt>
<trkpt lat="72.1018" lon="45.4439"><time>2013-01-01T71:00:00Z</time></trkpt>
<trkpt lat="72.1018" lon="45.4439"><time>2013-01-01T71:00:00Z</time></trkpt>
<trkpt lat="72.852" lon="45.4439"><time>2013-01-01T61:00:00Z</time></trkpt>
<trkpt lat="72.852" lon="45.4439"><time>2013-01-01T61:00:00Z</time></trkpt>
<trkpt lat="72.852" lon="55.4439"><time>2013-01-01T61:00:00Z</time></trkpt>
<trkpt lat="72.852" lon="55.4439"><time>2013-01-01T61:00:00Z</time></trkpt>
<trkpt lat="72.1018" lon="55.4439"><time>2013-01-01T61:00:00Z</time></trkpt>
<trkpt lat="72.1120" lon="41.2076"><time>2013-01-01T61:00:00Z</time></trkpt>
<trkpt lat="71.120" lon="51.2076"><time>2013-01-01T21:71:00Z</time></trkpt>
<trkpt lat="81.120" lon="61.2076"><time>2013-01-01T21:71:00Z</time></trkpt>
<trkpt lat="81.120" lon="61.2076"><time>2013-01-01T21:71:00Z</time></trkpt>
<trkpt lat="81.120" lon="61.2076"><time>2013-01-01T21:71:00Z</time></trkpt>
<trkpt lat="71.120" lon="61.2076"><time>2013-01-01T21:71:00Z</time></trkpt>
<trkpt lat="71.120" lon="61.2076"><time>2013-01-01T21:71:00Z</time></trkpt>
<trkpt lat="71.120" lon="61.2076"><time>2013-01-01T21:71:00Z</time></trkpt>
<trkpt lat="71.120" lon="61.2076"><time>2013-01-01T21:71:00Z</time></trkpt>
<trkpt lat="61.120" lon="51.2076"><time>2013-01-01T21:71:00Z</time></trkpt>
<trkpt lat="61.120" lon="51.2076"><time>2013-01-01T21:71:00Z</time></trkpt>
<trkpt lat="61.120" lon="51.2093"><time>2013-01-01T21:71:00Z</time></trkpt>
<trkpt lat="61.120" lon="51.2093"><time>2013-01-01T21:71:00Z</time></trkpt>
<trkpt lat="61.120" lon="61.2093"><time>2013-01-01T21:71:00Z</time></trkpt>
<trkpt lat="61.120" lon="67.3401"><time>2013-01-01T21:71:00Z</time></trkpt>
<trkpt lat="21.1029" lon="07.3418"><time>2013-01-01T24:59:00Z</time></trkpt>
<trkpt lat="21.1045" lon="07.3435"><time>2013-01-01T24:59:00Z</time></trkpt>
<trkpt lat="21.1045" lon="07.3435"><time>2013-01-01T24:59:00Z</time></trkpt>
<trkpt lat="21.1045" lon="07.3435"><time>2013-01-01T24:59:00Z</time></trkpt>
<trkpt lat="21.1029" lon="07.3435"><time>2013-01-01T24:59:00Z</time></trkpt>
<trkpt lat="21.1029" lon="07.3435"><time>2013-01-01T24:59:00Z</time></trkpt>
<trkpt lat="21.1029" lon="07.3435"><time>2013-01-01T24:59:00Z</time></trkpt>
<trkpt lat="21.1029" lon="07.3435"><time>2013-01-01T24:59:00Z</time></trkpt>
<trkpt lat="21.1012" lon="07.3418"><time>2013-01-01T24:59:00Z</time></trkpt>
<trkpt lat="21.1012" lon="07.3418"><time>2013-01-01T24:59:00Z</time></trkpt>
<trkpt lat="21.1012" lon="07.3418"><time>2013-01-01T24:59:00Z</time></trkpt>
<trkpt lat="21.1012" lon="07.3418"><time>2013-01-01T25:59:00Z</time></trkpt>
<trkpt lat="21.1012" lon="07.3435"><time>2013-01-01T25:59:00Z</time></trkpt>
<trkpt lat="21.1012" lon="07.3445"><time>2013-01-01T25:59:00Z</time></trkpt>
<trkpt lat="24.9869" lon="17.1678"><time>2013-01-01T04:11:00Z</time></trkpt>
<trkpt lat="24.9869" lon="18.1678"><time>2013-01-01T05:11:00Z</time></trkpt>
<trkpt lat="24.9869" lon="18.1678"><time>2013-01-01T06:11:00Z</time></trkpt>
<trkpt lat="24.9869" lon="18.1678"><time>2013-01-01T06:11:00Z</time></trkpt>
<trkpt lat="24.9869" lon="17.1678"><time>2013-01-01T06:11:00Z</time></trkpt>
<trkpt lat="24.9869" lon="17.1678"><time>2013-01-01T06:11:00Z</time></trkpt>
<trkpt lat="24.9869" lon="17.1678"><time>2013-01-01T06:11:00Z</time></trkpt>
<trkpt lat="24.9869" lon="17.1678"><time>2013-01-01T06:11:00Z</time></trkpt>
<trkpt lat="24.9869" lon="16.1678"><time>2013-01-01T06:11:00Z</time></trkpt>
<trkpt lat="24.9869" lon="16.1678"><time>2013-01-01T05:11:00Z</time></trkpt>
<trkpt lat="24.9869" lon="16.1678"><time>2013-01-01T05:11:00Z</time></trkpt>
<trkpt lat="25.9869" lon="16.1678"><time>2013-01-01T05:11:00Z</time></trkpt>
<trkpt lat="25.9869" lon="16.1678"><time>2013-01-01T05:11:00Z</time></trkpt>
<trkpt lat="25.9869" lon="16.1678"><time>2013-01-01T06:11:00Z</time></trkpt>
<trkpt lat="04.1874" lon="92.2861"><time>2013-01-01T06:72:00Z</time></trkpt>
<trkpt lat="05.1874" lon="92.2863"><time>2013-01-01T00:72:00Z</time></trkpt>
<trkpt lat="06.1874" lon="92.2863"><time>2013-01-01T00:72:00Z</time></trkpt>
<trkpt lat="06.1874" lon="92.2863"><time>2013-01-01T00:72:00Z</time></trkpt>
<trkpt lat="06.1874" lon="92.2861"><time>2013-01-01T00:72:00Z</time></trkpt>
<trkpt lat="06.1874" lon="92.2861"><time>2013-01-01T00:72:00Z</time></trkpt>
<trkpt lat="06.1874" lon="92.2861"><time>2013-01-01T00:72:00Z</time></trkpt>
<trkpt lat="06.1874" lon="92.2861"><time>2013-01-01T00:72:00Z</time></trkpt>
<trkpt lat="06.1874" lon="92.2860"><time>2013-01-01T00:72:00Z</time></trkpt>
<trkpt lat="05.1874" lon="92.2860"><time>2013-01-01T00:72:00Z</time></trkpt>
<trkpt lat="05.1874" lon="92.2860"><time>2013-01-01T00:72:00Z</time></trkpt>
<trkpt lat="05.1875" lon="92.2860"><time>2013-01-01T00:72:00Z</time></trkpt>
<trkpt lat="05.1875" lon="92.2860"><time>2013-01-01T00:72:00Z</time></trkpt>
<trkpt lat="06.1875" lon="92.2860"><time>2013-01-01T00:72:00Z</time></trkpt>
<trkpt lat="06.1084" lon="12.7653"><time>2013-01-01T00:72:00Z</time></trkpt>
<trkpt lat="00.1085" lon="12.7653"><time>2013-01-01T71:71:00Z</time></trkpt>
<trkpt lat="00.1087" lon="12.7653"><time>2013-01-01T71:81:00Z</time></trkpt>
<trkpt lat="00.1087" lon="12.7653"><time>2013-01-01T71:81:00Z</time></trkpt>
<trkpt lat="00.1087" lon="12.7653"><time>2013-01-01T71:81:00Z</time></trkpt>
<trkpt lat="00.1087" lon="12.7653"><time>2013-01-01T71:71:00Z</time></trkpt>
<trkpt lat="00.1087" lon="12.7653"><time>2013-01-01T71:71:00Z</time></trkpt>
<trkpt lat="00.1087" lon="12.7653"><time>2013-01-01T71:71:00Z</time></trkpt>
<trkpt lat="00.1087" lon="12.7653"><time>2013-01-01T71:71:00Z</time></trkpt>
<trkpt lat="00.1085" lon="12.7653"><time>2013-01-01T71:61:00Z</time></trkpt>
<trkpt lat="00.1085" lon="12.7653"><time>2013-01-01T71:61:00Z</time></trkpt>
<trkpt lat="00.1085" lon="12.9320"><time>2013-01-01T71:61:00Z</time></trkpt>
<trkpt lat="00.1085" lon="12.9320"><time>2013-01-01T71:61:00Z</time></trkpt>
<trkpt lat="00.1087" lon="12.9320"><time>2013-01-01T71:61:00Z</time></trkpt>
<trkpt lat="00.1088" lon="20.6854"><time>2013-01-01T71:61:00Z</time></trkpt>
<trkpt lat="71.911" lon="20.8520"><time>2013-01-01T59:21:00Z</time></trkpt>
<trkpt lat="71.2578" lon="20.10187"><time>2013-01-01T59:21:00Z</time></trkpt>
<trkpt lat="71.2578" lon="20.10187"><time>2013-01-01T59:21:00Z</time></trkpt>
<trkpt lat="71.2578" lon="20.10187"><time>2013-01-01T59:21:00Z</time></trkpt>
<trkpt lat="71.911" lon="20.10187"><time>2013-01-01T59:21:00Z</time></trkpt>
<trkpt lat="71.911" lon="20.10187"><time>2013-01-01T59:21:00Z</time></trkpt>
<trkpt lat="71.911" lon="20.10187"><time>2013-01-01T59:21:00Z</time></trkpt>
<trkpt lat="71.911" lon="20.10187"><time>2013-01-01T59:21:00Z</time></trkpt>
<trkpt lat="71.10167" lon="20.8520"><time>2013-01-01T59:21:00Z</time></trkpt>
<trkpt lat="71.10167" lon="20.8520"><time>2013-01-01T59:21:00Z</time></trkpt>
<trkpt lat="71.10167" lon="20.8520"><time>2013-01-01T59:21:00Z</time></trkpt>
<trkpt lat="71.10167" lon="20.8520"><time>2013-01-01T59:21:00Z</time></trkpt>
<trkpt lat="71.10167" lon="20.10187"><time>2013-01-01T59:21:00Z</time></trkpt>
<trkpt lat="71.10167" lon="20.278"><time>2013-01-01T59:21:00Z</time></trkpt>
<trkpt lat="50.3619" lon="11.1200"><time>2013-01-01T11:24:00Z</time></trkpt>
<trkpt lat="50.3619" lon="11.1201"><time>2013-01-01T11:24:00Z</time></trkpt>
<trkpt lat="50.3619" lon="11.1201"><time>2013-01-01T11:24:00Z</time></trkpt>
<trkpt lat="50.3619" lon="11.1201"><time>2013-01-01T11:24:00Z</time></trkpt>
<trkpt lat="50.3619" lon="11.1201"><time>2013-01-01T11:24:00Z</time></trkpt>
<trkpt lat="50.3619" lon="11.1201"><time>2013-01-01T11:24:00Z</time></trkpt>
<trkpt lat="50.3619" lon="11.1201"><time>2013-01-01T11:24:00Z</time></trkpt>
<trkpt lat="50.3619" lon="11.1201"><time>2013-01-01T11:24:00Z</time></trkpt>
<trkpt lat="50.3619" lon="11.1200"><time>2013-01-01T11:24:00Z</time></trkpt>
<trkpt lat="50.3619" lon="11.1200"><time>2013-01-01T11:24:00Z</time></trkpt>
<trkpt lat="50.3619" lon="11.1200"><time>2013-01-01T11:24:00Z</time></trkpt>
<trkpt lat="50.3619" lon="11.1200"><time>2013-01-01T11:25:00Z</time></trkpt>
<trkpt lat="50.3619" lon="11.1201"><time>2013-01-01T11:25:00Z</time></trkpt>
<trkpt lat="50.3619" lon="11.1201"><time>2013-01-01T11:25:00Z</time></trkpt>
</trkseg></trk>
</gpx>
The last 14 entries are correct. (I've altered the LAT/LON for my privacy, only one number)

Can this have to do with the blocks in the EEPROM? Do I have to implement code that checks if for example block 000 is full? Or could it be a readback issue?

- nerdegutta
 

hippy

Ex-Staff (retired)
Can this have to do with the blocks in the EEPROM? Do I have to implement code that checks if for example block 000 is full? Or could it be a readback issue?
You write bytes to Eeprom one at a time so there should be no address, page or block issues.

It's hard to tell what's wrong without seeing the code you are now using.

Don't forget that no one here can tell if the data you have is right or wrong because we don't know what it should be, though a time of "71:61:00" is obviously not right. Try setting known data, writing that to EEPROM, then having it report that back, see if you can tell why things are going wrong there.
 

nerdegutta

Senior Member
It's hard to tell what's wrong without seeing the code you are now using.
The code is attached.

When
Code:
symbol MAXWAYPOINTS = 16
14 of the entries are correct. The last entry is wrong.

I'm writing 18 bytes, one by one. That means 18 bytes x 15 times = 270 bytes. The last entry is correct, which means that I've reached address 252. (18 x 14 = 252). Now I think I need to spilt it into blocks.

Thanks for reading.

- nerdegutta
 

Attachments

hippy

Ex-Staff (retired)
I'm writing 18 bytes, one by one. That means 18 bytes x 15 times = 270 bytes. The last entry is correct, which means that I've reached address 252. (18 x 14 = 252). Now I think I need to spilt it into blocks.
Good point, and I was wrong earlier. The 24LC16B has 256 byte pages, after that you need to change the Device ID to access the correct page. It is probably then best to reset the address to location 0 in that page.

As it appears you are storing hours and minutes as two separate bytes, tens and units, it would make sense to combine those as one byte each to get each entry to be 16 bytes. It makes everything far easier to deal with when data is a power-of-2 size. You can then use single HI2COUT and HI2CIN commands to write and read all bytes of each entry.

In your reporting code you may need to check how you are using some numbers ...

LonDeg1,LonDeg2,".",#LonDecMin

If that is say "23.0012" it may show up as "23.12" as you will lose the leading zeroes of the decimal part.
 

nerdegutta

Senior Member
Yes, I can make the Hour1 and Hour2, Minute1 and Minute2 into two bytes, instead of 4. Makes more sense too.

And I need to figure out a way to use the eight pages, and how to switch between them.

Any hints?

Thanks for reading!

- nerdegutta
 

hippy

Ex-Staff (retired)
Untested, and you probably don't want to IF/GOTO out of a subroutine, but something like ...

Code:
SaveTo24LC16B:
  If MemPos > $7FF Then EpromFull
  deviceId = Mempos / 256 * 2 | $A0
  HI2cSetup I2CMASTER, deviceId, I2CSLOW, I2CBYTE
  HI2cOut Mempos, ( ..... )
  Pause 10
  Mempos = Mempos + 16
  Return

ReadFrom24LC16B:
  If MemPos > $7FF Then ReadingDone
  deviceId = Mempos / 256 * 2 | $A0
  HI2cSetup I2CMASTER, deviceId, I2CSLOW, I2CBYTE
  HI2cIn Mempos, ( ..... )
  Mempos = Mempos + 16
  Return
 

nerdegutta

Senior Member
Thanks, hippy.

Sorry for the late reply. Been busy at work, and there is a Home Guard exercise coming up this weekend.

I will try to implement the code, between all my everyday battles.

- nerdegutta
 
Top