|
Megasquirt 3 - SD card datalogging |
Intro -
Supported cards -
Settings -
Button/light -
Log extraction -
Utilities -
Error codes -
Introduction
Megasquirt-3 has a built-in SD card slot which allows fast datalogging to a supported SD card without the need for a laptop. The operation can be continual or button controlled. Once logging is complete, TunerStudio is used to convert the compact SD log data files into regular datalogs that can be viewed in logging software as normal.
Supported cards
Most SD cards and SDHC cards ought to work.Here are some example cards tested by the firmware developers.
Settings
The configuration for the SD card is on the Datalogging menu in TunerStudio.
SD card logging
- Disabled - turns off the SD logging feature
- Insertion - basically it means always log. It is best not to insert the SD card while the MS3 is powered on and most certainly do not unplug the card while the power is on. Card damage can result.
- Button - logging is controlled by a push button
- Button+WTF - not yet supported
Datalog button - selects the input pin used for the button if used.
LED indicator - selects the output used for the optional LED indicator
Log data block size
- 64 byte is the most common setting
- 64 byte + stream allows the simultaneous recording of data and a 8kHz mono sound input. This could be used as a commentary during a datalog such as position on a racetrack or notable incidents in the log. Presently the tuning software does not support extracting this audio data.
Sampling
- Timed - a data sample is taken at predefined time interval - this is the most common option
- every tooth, every cycle - for special logging and at low engine speeds these options take a data sample at these events
Sample interval - how often to take a data sample.
3ms is the fastest supported, but many cards will only sustain 5ms before you start getting small gaps in the logs. See the utilities section for speed testing.
Log file max duration - how long each datalog should be.
The files are always created full size and fill up the allocated space during logging. If the log file is filled, a new file is started. If you turn off the power to the Megasquirt (which is safe to do during a log) the log will be there and will show full size. When the log file is extracted, the unused part of the allocated file will be ignored. (Note, it is impossible for the MS3 to set the file length or otherwise "clean up" the log file in this case because there is no power and the processor is off !) A result of this is that all log files on the SD card will appear the same size.
Stream input - where the 0-5V audio input is connected
Log field selection
The field selector allows you to choose which data fields you want to log. Because of the compact datalog format, only 64 bytes are available total, so you need to pick the data that you find most critical.
To add a field, highlight it on the left and then click on > to move it to the right.
To remove a field, highlight it on the right and then click on < to move it to the left.
An optional extra that can be very useful with the SD logging feature is a realtime clock. Without the realtime clock, the MS3 has no idea what time or date it is and all log files on the card are stored with a bogus timestamp.
There are presently two supported clock options.
a. On the MS3X card there is space to install a clock module (coming soon)
b. The JBperf IO-Extender has a realtime clock which is used via CAN.
Configuration for both of these options is on the "CAN, VSS, gear, RTC" dialogue
Button / light Wiring and usage
Within "insertion" mode you do not need the button. It is required for "button" mode to start and stop datalogs.
The LED/light output is optional in either mode but can be helpful to more quickly diagnose any error conditions and confirm that logging is happening. It is recommended when using button mode. When using the MS3X spark outputs, it is likely convenient to set the "middle LED" as the LED output as zero wiring is required.
Button usage
When Megasquirt-3 powers up it will create an empty datalog file ready for logging.
Press and hold the button for over half a second to start a log.
A quick press of the button will end the log.
When extracting the log files you will likely find a blank logfile on the card after your real logs, this is normal.
LED flash codes
Off - SD logging not active
On (solid) - Ready but not logging
Fast flashing - Initialising card
Slow flashing - Logging
Pause, sequence of flashes - error code (See Error codes section)
Log file extraction
The log files on the card use a compact binary format. Before you can view these files it is necessary to convert them to the conventional log format using TunerStudio.
The firmware supports fetching the log files directly over the serial connection. Presently TunerStudio does not support this and a standalone utility sd_sync2 is used. This could be useful at the track, but for large or multiple log files it is often fastest to pop the card out of the MS3 and plug it into your computer or card reader. When inserting the card into a Windows computer, cancel all dialogues and attempts to handle camera files etc.
Open TunerStudio and ensure your current Project and tune file are open.
Go to DataLogging > Import/Conversion > Convert Binary Log
Browse to find the file you want to import from the SD card, select it and then click ok.
A progress window should pop up as the log file is converted.
Repeat for all files needed.
Processed datalogs are stored along with regular datalogs in the Datalogs directory under your project.
View the logs in MegaLogViewer.
Software utilities
Presently there are a few utilities for the SD card system, these are somewhat rudimentary and are all commandline tools. If you are not familiar with using commandline utilities you might want to skip this section.
Windows
sd_speed - this performs a speed test on the SD card
NOTE! this utility WILL erase data on the card. Ensure there is nothing of value on the card first.
This utility is not presently available for Windows
Exit TunerStudio and ensure your Megasquirt is powered up and the serial/USB connection is available.
Then open a command prompt and...
cd c:\efi\ms3
sd_speed com1:
The utility will then make a test on the card and report on the fastest log rate you can use. e.g.
|
Card status = 0x6f
Stopping log and resetting Card status = 0x21 Card busy - sleeping Card status = 0x21 Card busy - sleeping Card status = 0x67 Fetch full status Test start sector = 0x100000 - caution writing blindly to card Waiting.4%.6%.10%.16%.23%.31%.41%.52%.65%.78%.94%.100% Summary Min = 13 ms, max = 61 ms, average = 14 ms Shortest write interval 2 ms, gapless write interval 5 ms |
Linux
The operation is much the same as Windows, but your serial port is more likely named /dev/ttyUSB0 or /dev/ttyS0
The executable files can be downloaded from http://www.msextra.com/doc/ms3/files/sdcard/linux/
Error codes
If the card fails to initialise or has another problem you will usually get an error code. This is visible through the "SD error" gauge in TunerStudio or through the LED flash sequences.
| Error no. | Name | Meaning / remedy |
| 0 | no error | OK |
| 1 | sending clocks | Card fault? |
| 2 | idle | Card fault? |
| 3 | init | Card fault? |
| 4 | set blocksize | Card fault? |
| 5 | request CSD | Unsupported card? |
| 6 | reading MBR | Remove files and reformat card |
| 7 | MBR end marker not found | Remove files and reformat card |
| 8 | no partition 1 defined | Remove files and reformat card |
| 9 | reading partition boot sector | Card fault? |
| 10 | reading directory | Card fault? |
| 11 | (not used) | |
| 12 | reading FAT | Card fault? |
| 13 | reading FAT continuation sector | Card fault? |
| 14 | writing FAT | Card fault? |
| 15 | reading directory | Card fault? |
| 16 | writing directory | Card fault? |
| 17 | writing log sector | Card fault? |
| 18 | unsupported non-FAT16 | Remove files and reformat card |
| 19 | - | |
| 20 | SDHC detection | |
| 21 | VCA check pattern failed | |
| 22 | VCA voltage rejected | |
| 23 | OCR1 | |
| 24 | OCR2 | |
| 25 | OCR3 | |
| 26 | OCR4 | |
| 28 | processing CSD | Try a lower SPI speed |
| 29 | write failed | |
| 30 | directory full | Root directory is full, delete some files |
| 31 | can't find space in FAT | Card is full, delete some files |
| 32 | looks like VBR but not valid | Remove files and reformat card |
If you have a question, comment, or
suggestion for this FAQ please post it on the forum.
No part of this manual may be reproduced or changed without written permission from James Murray and Ken Culver.