Skip to main content
FW version: Stable

SD card logging

With YOS scripts, it is possible to format and send out variables through UART. This may be used for debugging and logging purposes. This guide is a step-by-step tutorial on how to use the prepared logging script and OpenLog UART module to log data from YOS to an SD card.

OpenLog

The OpenLog Data Logger is a simple-to-use, open-source solution for logging serial data from your projects. The OpenLog provides a simple serial interface to log data from a project to a microSD card.

info

More info about OpenLog can be found on SparkFun website.

openlog

Wiring

Connect OpenLog GND, TX, RX, and VCC pins to your siliXcon device.

OpenlogsiliXcon
GNDIOGND
TXUARTCOM RX
RXUARTCOM TX
VCCIO+5V

Case

The Openlog module is delivered as bare PCB. To protect it, we recommend using a 3D-printed case. One case is available here.

SD card

The Openlog module store its configuration on the SD card. By default, the Openlog baud rate is 9600 and the siliXcon default value is 115200. To fix it, insert an SD card into your computer and update (or create) a file named config.txt, with this content:

  1. Config - create a new CSV file for each power-up:
115200,36,3,0,1,1,1
baud,escape,esc#,mode,verb,echo,ignoreRX
  1. Config - append data to a CSV file:
115200,36,3,1,1,1,1
baud,escape,esc#,mode,verb,echo,ignoreRX
tip

Check the OpenLog Hookup Guide for more info.

warning

Openlog requires a FAT32 formatted SD card with max size 32GB.

The logging script

On the siliXcon side, we will install a permanent script to the device. This script will be executed on every boot and will send data to UART.

The scripts are delivered with the SWTools and can be found in the /silixcon/scripts/uart_logging folder.

The scripts are also available on the GitHub.

How to use the scripts

  1. Connect siliXcon device
  2. Run the script.

The script will automatically store itself to the permanent script and will be executed on every boot.

In the folder /silixcon/scripts/uart_logging are prepared a few scripts.

ScriptDescription
LYNX_log.ysExample of logging for the LYNX application. Example of output
In the LYNX application, set dispmode 0 to disable using UART from the application.
OPHION_log.ysExample of logging for the OPHION application
BMS_log.ysExample of logging for the BMS
tip
  • To stop the script, press CTRL+C in the terminal.
  • To erase the permanent script, run script e in the term.
warning

The script will not work if the UART is used by the application.

How to create/update logging script

If you want, you can easily create your script and you can log any variable you want.

warning

The bellow script needs shared part of the script - /uart_logging/common/logging_common.ys. Put your own script in the folder /uart_logging, or copy also the common part to your script folder.

@c # Stop any running scripts
@! # Login

# If you do send the header, you will have about 2s delay before the first line is sent
# Comment this out if you want send first data immediately after power up
@d SEND_HEADER

# Send period
# Values lower than 500ms may not work due small RX buffer on OpenLog
@d LOG_PERIOD : 1000

# Store script in the device flash
# Use `script e` to remove it
@d STORE_SCRIPT

# Log current time ins [s]
@d VAR0 : /permanents/time

# Common block variables
@d VAR30 : /common/stat
@d VAR31 : /common/error
@d VAR32 : /common/din
@d VAR33 : /common/gpio
@d VAR34 : /common/gdin

# AM controller
# Because some of the variables are arrays, we need to define CSV header for them as well
@d VAR32_HEADER : din1,din2
@d VAR33_HEADER : gpio1,gpio2
@d VAR34_HEADER : gdin1,gdin2


# Include script with all the logging functions
@i ./common/logging_common.ys

In the script you can add @d VAR[number] : [variable], where you can specify up to 49 variables. The variable can be any variable from the device.

Optionally you can add @d VAR[number]_HEADER : [header] to specify the header in the CSV for the variable. This is useful for arrays. By default the header is path to the variable.

warning

If you value you specify in the script is an array, you need to specify the header as well. Otherwise, the header will not match the data.

Example: For an array /common/gpio you will get only one column in the CSV header, but the data will be in multiple columns. (depend on the array size)

Problems

If you see this error in the terminal, you are trying to log non existing variable.

error parsing/copying
error parsing/copying

Reading the data

As the output, you will get a CSV file on the SD card. You can open it in any text editor or Excel.

Example of CSV output:

/permanents/time,/driver/supply/voltage,/driver/supply/currentf,/driver/motor/rpmf,/driver/motor/currentqf,/driver/motor/Rthermistor,/driver/limit,/driver/stat,/driver/error,/driver/totallimit,/driver/temp,/driver/ptctemp,/driver/powerf,/driver/cmd,/driver/mode,/sig_acc,/sig_brake,/sig_pas,/sig_torque,/cadence,/speed,/maps/map,/mode,/common/stat,/common/error,din1,din2,din3,din4,gpio1,gpio2,gdin1,gdin2,
2954,20.0823,0.0,0.0,0.0,.nan,0,0,65535,1.0,45.8234,78.0959,0.0,0.0,0,0.0,0.0,0.0,0.0,0.0,0.0,1,0,0,0,0,0,0,0,0,1,0,0,
2955,20.1108,0.0,0.0,0.0,.nan,0,0,65535,1.0,45.8834,77.9770,0.0,0.0,0,0.0,0.0,0.0,0.0,0.0,0.0,1,0,0,0,0,0,0,0,0,3,0,0,
2956,20.0539,0.0,0.0,0.0,.nan,0,0,65535,1.0,45.9001,78.1566,0.0,0.0,0,0.0,0.0,0.0,0.0,0.0,0.0,1,0,0,0,0,0,0,0,0,1,0,0,
2958,20.0823,0.0,0.0,0.0,.nan,0,0,65535,1.0,45.8163,78.0643,0.0,0.0,0,0.0,0.0,0.0,0.0,0.0,0.0,1,0,0,0,0,0,0,0,0,3,0,0,
2959,20.1108,0.0,0.0,0.0,.nan,0,0,65535,1.0,45.8738,78.1056,0.0,0.0,0,0.0,0.0,0.0,0.0,0.0,0.0,1,0,0,0,0,0,0,0,0,3,0,0,
warning

siliXcon bootloader send to UART some data as well. This data are non-printable characters. If you got problems with the CSV file, try to remove the non-printable characters.

To do that you can use python script from folder /uart_logging:

  • python fix_csv.py SEQLOG00.TXT

Flow CSV Viewer

One tool that we recommend for its ease of use is Flow CSV Viewer. It is a free tool for viewing CSV files.

CSV_viewer