Circular buffer
Basil
Posts: 380
Hi All,
I am going crazy trying to figure out how to do a circular buffer.
I need it to record flight data for a high powered rocket.
I need to record 500ms of data (rounded to the nearest full page) prior to launch detection, and wen launch is detected, I need to dump the buffer into my dataflash memory and continue recording in realtime (no buffer needed I dont think).
To maximise the dataflash's life expectancy, I would like to write page by page (as discussed in a previous thread).
The data is 3 x longs: flighttime, bADC, iADC.
My recording period is variable, but 10ms is the shortest period.
If someone could point me in the right direction that would be super! I have 1 cog available to do this in.
Thanks,
Alec
I am going crazy trying to figure out how to do a circular buffer.
I need it to record flight data for a high powered rocket.
I need to record 500ms of data (rounded to the nearest full page) prior to launch detection, and wen launch is detected, I need to dump the buffer into my dataflash memory and continue recording in realtime (no buffer needed I dont think).
To maximise the dataflash's life expectancy, I would like to write page by page (as discussed in a previous thread).
The data is 3 x longs: flighttime, bADC, iADC.
My recording period is variable, but 10ms is the shortest period.
If someone could point me in the right direction that would be super! I have 1 cog available to do this in.
Thanks,
Alec
Comments
Cool, thanks for that pointer (no pun intended).
Im a little confused how to use 3 words per entry rather than longs?
The bADC and iADC are 12bit read from the MCP3208, and the flighttime variable need to record 600000ms (10 mins flight is probably overkill but I want to play it safe)
Ill take a look at the kdb routine when I get home [noparse]:)[/noparse]
Regarding the time, you only need to record the time prior to launch (for saving this information). If your unit is 1ms, that allows for over a minute prior to flight time. If you want, you can also save the absolute launch time as a single 32-bit value in the second page of the EEPROM.
Oh yeah! lol I new the 16bit thing but thought that was a long not a word :P
"Regarding the time, you only need to record the time prior to launch (for saving this information). If your unit is 1ms, that allows for over a minute prior to flight time. If you want, you can also save the absolute launch time as a single 32-bit value in the second page of the EEPROM."
The first data recorded (ie ~500ms prior to launch) I would liked to be tagged at 0ms. This would mean launch is at approx 500ms.
Is this what you mean by absolute launch time?
Time since launch is the most practical but I may have a reason to use absolute time in another project. Thanks for the hint [noparse]:D[/noparse]
Ill post again once I get stuck with the keyboard routine :P
Thanks Mike