TurboStreetCar
Active member
Hello, ive created a datalogger from a Teensy 3.6 and using the onboard uSD card slot to save the data in CSV format.
I have pretty much all of it working properly but i have a few questions about the behavior ive noticed. Ill preface this by saying i have ZERO formal education or training in writing code or the technical aspects of how these micro-controlers work. Its just been pure hobby, but i pick up on it pretty quick. The current logger code is two pages and a total of 540 lines of code.
The logger is a CAN logger that pulls messages from the bus, identifies the address, pulls the data contained in the message, and formats it into a char array for each parameter. THEN every 50mS it formats all the parameter char arrays into a string and stores it in a 8KB buffer. When the buffer reaches 7730bytes (full minus a complete max length line of data) it prints to the uSD Card.
My question stems from how the data is moved to the card.
With my 50mS interval i see an exact 50mS interval as measured and logged in the data from every time it enters the loop.
If i change the interval to 20mS, i see single peaks that push the recorded interval to ~30mS.
Does the code pause on myFile.println()? Or does the actual writing to SD take place in the background with no effect on the running code? Could the latency be that while the buffer is being "printed" to SD, the code is modifying the buffer?
I have pretty much all of it working properly but i have a few questions about the behavior ive noticed. Ill preface this by saying i have ZERO formal education or training in writing code or the technical aspects of how these micro-controlers work. Its just been pure hobby, but i pick up on it pretty quick. The current logger code is two pages and a total of 540 lines of code.
The logger is a CAN logger that pulls messages from the bus, identifies the address, pulls the data contained in the message, and formats it into a char array for each parameter. THEN every 50mS it formats all the parameter char arrays into a string and stores it in a 8KB buffer. When the buffer reaches 7730bytes (full minus a complete max length line of data) it prints to the uSD Card.
My question stems from how the data is moved to the card.
With my 50mS interval i see an exact 50mS interval as measured and logged in the data from every time it enters the loop.
If i change the interval to 20mS, i see single peaks that push the recorded interval to ~30mS.
Does the code pause on myFile.println()? Or does the actual writing to SD take place in the background with no effect on the running code? Could the latency be that while the buffer is being "printed" to SD, the code is modifying the buffer?