View Full Version : Time clock
11-11-2011, 04:25 AM
I know this is a simple task but after spending a day batting my head, I thought I'd ask the experts .
I have a loop running at 100ms rep rate for telemetry logging.
In the loop I have 4 byte varibles, hours, minutes, seconds, and tenths of seconds.
These varibles increment correctly and will display on CRT
I want to create a string in HH:MM:SS.S format from these varibles to insert in SD-FAT file record (Excel CSV format)
11-11-2011, 04:45 AM
There's an AppNote on how to use a SD card.
EDIT: I just looked through this code again. This is a really old example. I'll try to find a newer (better) example tomorrow. This code is very akward.
Here are parts of an old program that does this. I don't think the SD card methods in this example are named the same as they are in the newest FAT driver. I think the clock driver is an old one too.
The AddDecToString method is probably the most useful method (of those in the code below) to help you with what you want to do.
Tv : "tv_terminal" ' Uses two cogs
Sd : "FATEngine.spin" ' Uses one cog
Clock : "RTCEngine.spin" ' no added cog, uses I2C lines
PUB RecordData | indexPrivate2, localIndex
' write other data
Sd.writeCharacter(44) ' a coma seperates fields
Sd.writeCharacters(@timeArray + 5) ' I don't want to write the first five characters in the array
Sd.writeCharacter(10) ' New line (new row in Excel)
days := Clock.getday
years := Clock.getyear
months := Clock.getmonth
date := Clock.getdate '(_i2cSCL, _Address)
hours := Clock.gethours
minutes := Clock.getminutes
seconds := Clock.getseconds
PRI AddDecToString(value, position) | indexPrivate
if position == 0
byte[@TimeArray][position * 3 + 5] := value / 1000 + "0"
value //= 1000
byte[@TimeArray][position * 3 + 6] := value / 100 + "0"
value //= 100
byte[@TimeArray][position * 3 + 7] := value / 10 + "0"
value //= 10
byte[@TimeArray][position * 3 + 8] := value + "0"
11-12-2011, 04:13 PM
Your info put me on the right track. Progress continues