Serial Port Logging with the Prius Mini-Scanner

This section of the Prius Mini-Scanner User Manual discusses serial port logging.

Logging via the Serial Port

Data retrieved from the vehicle by the Mini-Scanner can be sent to a computer via the serial port.  The data items sent are the same as those selected for display.  However, only numerical data is sent, the descriptive text and units that you see on the display are not sent.  You must remember what data was being displayed on each line when you examine the data.  This purely numerical data is very easy to import into a spreadsheet.

The format of the data is ASCII, in other words the number 62.5 will be sent as the four ASCII characters '6', '2', '.' and '5'.  The serial port operates at 9,600 bit/s, 8 data bits, no parity and one stop bit.  These are the same setting used by the Flash Loader, so if you have a terminal emulator set up for firmware updates, you can use it to view the serial port data.  Just connect the computer up and start the terminal emulator as if you were going to update the firmware (but don't hold down the escape key).  Using the terminal emulator's capture features, you can save the data to a file for later analysis or charting in a spreadsheet program.

Timestamps

Each data value is associated with a "timestamp".  This indicates the approximate time at which the data item was sampled and had that value.  In firmware versions 0.51 and later, the timestamp is given in seconds (in earlier firmware versions, the timestamp was given in milliseconds).  Timestamps start at zero when you turn on or reset the Mini-Scanner and do not represent real-world or "wall-clock" time.  The long-term accuracy of the timestamps has not been measured, but will be of the order of a second per hour.

The resolution of the timestamp is one millisecond, but this is not its short-term accuracy.  Do not assume that the logged data samples are as precisely placed in time as the timestamp resolution suggests.  When the data is actually sampled by an ECU in the vehicle is not known.  It could be sampled at some regular rate so that a request for the data returns the most recent sample, whenever that was taken.  Or, it is also possible that the sampling of data is triggered by the request on the OBD-II bus.  But, exactly when this happens in relation to the request message and response is not know.  The Mini-Scanner records the timestamp from an internal clock when the first octet of the vehicle's response is received.  In a future firmware version, the timestamp resolution may be reduced to 0.01 seconds to discourage false assumptions about accuracy.

Log Format

The format in which timestamps and data are sent to the serial port is designed to be logged in a file and then imported into a spreadsheet.  The data can then be analysed and visualized as a chart.  The timestamps and data values are separated by tab characters, so when importing to a spreadsheet program, specify the file type as a tab-delimited text file.  The format is best explained by an example:

126.456 14.84
126.927         14.0
127.394 17.18     
127.861         14.5
128.329 19.53
128.796         14.0
129.263 19.92
129.730         6.0
130.197 20.31
130.668         1.5
131.135 19.92
131.606         -4.0
132.074 19.92
132.540         -8.5

Each line begins with a timestamp in the first column.  Data values are placed in columns after the timestamp, separated from the timestamp by one or more tab characters.  The values of the data item selected for display in line one appear in the second column and are separated from the timestamp by a single tab.  The values of the data item selected for display in line two appear in the third column and are separated from the timestamp by two tabs.  When you capture the serial port data to a file and import the file into a spreadsheet program, the timestamp, line one data and line two data will appear in columns A, B and C, respectively.

As you pass 999.999 seconds (sixteen minutes and change) since the Mini-Scanner was turned on or reset and the timestamp length steps up to eight digits, the data columns will appear to jump one column to the right.  This has no effect when the data is imported into a spreadsheet.

If you select for display two data items that are retrieved from the same vehicle ECU using the same parameter ID (PID), then each vehicle response updates both display lines.  The effect on the serial port data is that twice as much data will appear and consecutive lines will have the same timestamp.

Creating a chart from data in this format imported into most spreadsheet programs is very easy.  Simply select the block of data you want to chart, both rows and columns, and instruct the program to make a chart from it.  Specify the type of chart as X-Y or "scatter" so that the first column is used as X axis values.  You may also be able to specify that data points are joined by a line, though some low-end spreadsheets mishandle the blank cells.  By default, both data columns will be plotted against the same Y axis, so if they differ in scale (for example engine r.p.m. varying from 0 to 4000 and throttle varying from 15 to 60) you will have some more work to do to plot each column against its own Y axis.

Alternate Log Format

Although not currently implemented, here is an alternate format for the data shown above:

 126.456    14.84     126927     14.0
 127.394    17.18     127861     14.5
 128.329    19.53     128796     14.0
 129.263    19.92     129730     6.0
 130.197    20.31     130668     1.5
 131.135    19.92     131606     -4.0
 132.074    19.92     132540     -8.5

The values of the data item selected for display in line one appear in the second column and their timestamps are in the first column.  The values of the data item selected for display in line two appear in the fourth column and their timestamps are in the third column.  All columns are separated by tabs.

This alternate format is tricker to chart properly in a spreadsheet program.  Each data column should be plotted on the Y axis against a different set of timestamps on the X axis.  This is supported by Microsoft Excel, but not by other spreadsheets such as OpenOffice Calc.  However, because there are no blank cells, adding columns for derived data values is easier than with the first format.  In cases where you are not too concerned about time accuracy, you could pretend that all data columns are referenced to the timestamps in the first column.  Or, you could interpolate data values onto the first column timeline.  Now you can plot all data columns against the same set of X axis values.  This is possible even in low-end spreadsheets, such as Microsoft Works, that do not handle blank cells well.

Whether this format will be supported instead of or as well as the current format is to be determined, largely from user feedback.  However, there is a tricky problem to solve when multiple items are selected for display that come from the same ECU and PID.  The current firmware logic produces extra columns as the two values are decoded from the same vehicle response.

Control of Logging

Logging can be controlled using the Right button when the Mini-Scanner is in Display mode.  Holding the right button toggles logging off and on.  Logging is always on after powering up or resetting the Mini-Scanner.  If you turn it off, this selection will not be saved and it will be on again after a power cycle or reset.  The only reason you'd turn it off would be if you have a computer connected and are capturing data and you want to reduce the file size by not logging during uninteresting driving periods.

So that you can find interesting events in a log file, you can drop a mark into the file by tapping the Right button.  This happens even if logging is off, so you can drop the mark and then turn logging on to keep the mark outside your data.  The format of the mark is "Mk_n", where n is the mark number.  The mark number starts at zero for the first mark after power on or reset and increases by one for each mark you drop.  Should you use 255 marks, the next number will go back to zero.  So that you know which mark number to look for in the file, it is briefly shown on the display.  You can write it down, together with a description of the interesting driving event (but if you're driving, you should of course have someone else write it down).  Marking the log file can be more useful than turning logging off and on because you can drop a mark after the interesting thing happened, when it would be too late to turn logging on.

The above actions of the Right button are effective only in Display mode.  In all other modes, you have no control over logging.

User Manual Home

Mini-Scanner Home

Prius Home

Last edited November 13, 2003.  All material Copyright ©  2003 Graham Davies.  No liability accepted.