|
![]() MCU User Forum
![]() USB datalogger
|
| next newest topic | next oldest topic |
| Author | Topic: USB datalogger |
|
RaghuDevii New Member |
I need to build a datalogger to record two analog channles at 10ms intervals with time stamp on to a MMC / SD /CF memory. Iguess I need to start with the C8051F340 mcu and the USB-MSD ref. design. Question is whether I will be capable of storing data at the required frequency of 10ms and maybe go down to 1ms if required ? I am right now studying the ref. design and would like to get this specific query answered. IP: Logged |
|
Tsuneo Member |
For either MMC/SD/CF, quick write response is not always guaranteed. Requirement of 1 - 10 ms is critical, if you write the data directly to the external memory. Better approach is, Usually these external memory has 512 bytes / sector as the unit of single write. Therefore, when you choose RAM cache size as one of multiple of 512 bytes (ie. 512, 1024, ...), you'll get better speed performance as a whole. Tsuneo IP: Logged |
|
RaghuDevii New Member |
Thanks for the clarification. Would it be OK if I dump the logged data to flash once every 20ms ? This means I would need to plan for an XRAM of 20*512 = 10KB ? Also there are two ref designs AN189 and AN282. Which would fit in my need more closely ? I think AN189 has no means of reading the Flash card through the MCU and save it to PC ? Thanks IP: Logged |
|
erikm Member |
if you write the data directly to the external memory. I see no mention of an external memory Erik IP: Logged |
|
Tsuneo Member |
> Would it be OK if I dump the logged data to flash once every 20ms ? Here is an excerpt from a SD card manual. SanDisk SD Card Product Manual (ProductManualSDCardv2.2final.pdf) Usually, you can read from /write to SD card very quickly. But in the worst case, Write takes 250 ms. Design should be based on the worst case.
No. You don't count in that MMC / SD / CF are block I/O device. 1) Just when the data logging starts, your firmware puts a header block (start time, sampling interval, etc) to the RAM cache on the on-chip XRAM. 2) A timer triggers ADC for sampling. The ADC completion ISR appends the ADC data to the header on the RAM cache. Every time ADC completes, the ISR appends data to the RAM cache. At the end of the cache, the write position returns to the head (ring buffer). 3) On the main loop, another task polls the cache size on the RAM. When it goes more than SD sector size, this task writes out one sector (or two) from cache to the SD card. For two ADC channels, the ADC part should be more elaborated. But the outline of the code flow is same as above. The RAM cache size is determined by the ADC data size, sampling rate and the Block Write Access Time (worst case) of SD card. For example, In the worst case, ADC generates 4 x 250 / 1 bytes while the firmware writes to the SD card. RAM cache should hold twice of this size, at least. (4 * 250 / 1) * 2 = 2000 bytes To keep the throughput even in the worst case, you need to write 2 sectors (1024 bytes) at a time using multi-sector write. Tsuneo [This message has been edited by Tsuneo (edited August 12, 2010).] IP: Logged |
|
TimB27 New Member |
I would also recommend using a "Class 6" SD card, since these typically have the best response times. Unfortunately the SPI interface for these SD cards is not always well supported and response times can vary from manufacturer to manufacturer. IP: Logged |
|
erikm Member |
Do you NEED that capacity? You can get much better response with a flash chip, and they are CHEAP (last one I used was 2M*8 and cost ~$2.50). Also that would be wired as memory, not a SPI device keeping everything simpler Erik IP: Logged |
All times are CT (US) | next newest topic | next oldest topic |
![]() |
|
Have you seen our MCU Knowledge Base?