Pre-release SerialFlow 0.9.0 beta 2 works, but has rough edges. Tell us what you find.

Example · MDX-400 motor-drive bench · Graphs

Live graphs: a streamer and a logger

Seven lines set up the speed graph. After that, one short line per sample.

  • No library: Serial.print is enough
  • Streamer: auto-X, 800 points
  • Logger: X in minutes, 40-min run
  • Limits, events, notes: 1 line each

The MDX-400 is a simulated motor drive. A script printed the serial lines its firmware would send, and SerialFlow read them exactly as if they came from a COM port. Your own board works the same way.

The MDX-400 bench needed two kinds of graph: the speed loop, watched live while the set point stepped, and the temperatures and battery over the whole 40-minute run, with the key moments marked. Both come from one serial port, as plain text lines mixed in with the log.

What the firmware prints

Each graph starts with an init line (I) and one line per signal (S). Then every sample is one short data line. Optional lines set the Y range and legend, and add limit lines, event markers and notes.

Graph A: Speed Control, a streamer

The full set-up of graph A from showcase_preload.txt, then its first samples. The last two lines come from showcase_live.txt, where the set point steps from 3 000 to 1 200 rpm.

~{A:I:Speed Control:800:S:T:R:Sample (10 ms)::0}
~{A:S:1:F32:R:Setpoint:rpm:0:FFB74D}
~{A:S:2:F32:R:Speed:rpm:0:4FC3F7}
~{A:H:1:3000:78909C:T:Rated 3 000 rpm}
~{A:Y:R:-200:3800}
~{A:Y:L:Speed:rpm}
~{A:L:1:TL:12:200}
~{A:1:0:-3.6}
~{A:1:0:-5.6}
~{A:1:0:-4.1}
…
~{A:1:3000:3009.7}
~{A:1:1200:2986.1}

The init line, field by field. Graph B’s values are in the second column.

FieldGraph AGraph BMeaning
graphABGraph letter, A to Z, per port
commandIIInit: create the graph, or reset it if it exists
nameSpeed ControlThermal & BatteryTab title
buffer size800100000Streamer: points kept per signal (for a logger, see Good to know)
modeSLS streamer, L logger, F frame
X typeTTT time, V value. Stored with the graph; both draw the same axis
X displayRRR raw, F formatted. Stored with the graph; both look the same
X labelSample (10 ms)TimeX-axis label
X unit(empty)minX-axis unit
X SI prefix00Power of ten applied to X; 0 keeps it as sent

The signal line, for ~{A:S:1:F32:R:Setpoint:rpm:0:FFB74D}:

FieldValueMeaning
signal id11 to 32. Data values arrive in this order
value typeF3232-bit float (u8 … i64, f32, f64)
text formatRR real number, D decimal integer, H hex, F zero-padded
nameSetpointLegend name
unitrpmUnit shown with the value
SI prefix0Power of ten for Y: -3 shows millivolts as volts
colourFFB74DHex RGB; leave it empty for an automatic colour
visible(left out)1 shown (default), 0 hidden

~{A:Y:R:-200:3800} fixes the Y range, so the graph does not rescale at every step, and ~{A:Y:L:Speed:rpm} labels the axis. ~{A:L:1:TL:12:200} puts the legend top left, in 12 pt, on a background with opacity 200 of 255.

~{A:1:3000:3009.7} is an auto-X data line. The 1 means “next X”: a counter that starts at 0 and adds one per line. The values follow in signal order: set point 3 000, speed 3 009.7. The streamer keeps the newest 800 points per signal, and its X axis follows the live edge.

Graph B: Thermal & Battery, a logger

~{B:I:Thermal & Battery:100000:L:T:R:Time:min:0}
~{B:S:1:F32:R:Motor winding:°C:0:FF8A65}
~{B:S:2:F32:R:MOSFET:°C:0:F06292}
~{B:S:3:F32:R:Pack voltage:V:0:81C784}
~{B:S:4:F32:R:State of charge:%:0:64B5F6}
~{B:H:1:85:FF5252:D:MOSFET limit 85 °C}
~{B:Y:R:0:110}
~{B:Y:L:Temperature · Voltage · SoC:mixed}
~{B:L:1:TR:12:210}
~{B:0:0.0000:23.95:24.12:52.61:98.00}
~{B:0:0.0333:23.92:24.15:52.62:97.99}
~{B:0:0.0667:23.93:24.24:52.60:97.99}
…
~{B:0:40.0000:31.85:24.87:47.66:52.92}

Mode L makes a logger: the graph grows and keeps the whole run, with four signals on one axis fixed at 0 to 110.

The data lines use explicit X, command 0. The first value is X, the time in minutes: one row every 2 s, so 0.0333 min apart. The four signals follow in id order: winding 23.95 °C, MOSFET 24.12 °C, pack 52.61 V, state of charge 98.00 %. 1 201 rows cover the 40 minutes.

Auto-X: ~{A:1:y1:y2}Explicit X: ~{B:0:x:y1:y2:…}
X valueA counter: 0, 1, 2, … one step per lineThe first number, scaled by the X SI prefix
Line lengthShorterOne more number per line
Used here forThe streamer, graph ATime in minutes, graph B

Limit lines, event markers and notes

The H lines belong to the set-up blocks above. The rest was sent after the data.

~{A:H:1:3000:78909C:T:Rated 3 000 rpm}
~{A:E:1:450:Load step:FF8A65:D}
~{B:H:1:85:FF5252:D:MOSFET limit 85 °C}
~{B:E:1:2:Cruise profile:00E676:S}
~{B:E:2:15:Hill climb 150 %:FFAB40:D}
~{B:E:3:21:Thermal derate:FF5252:D}
~{B:E:4:26:Regen:40C4FF:D}
~{B:E:5:29:Cool-down:B0BEC5:T}
~{B:T:1:19.33:89.6:Peak 82.6 °C:F06292:12:0}
~{B:B:16.4:Overcurrent trip:Phase B 42.3 A > 40 A - auto-restart 200 ms:FF5252}
CommandFieldsIn this run
H limit line (horizontal)id : Y : colour : style : labelA red dashed line at 85 °C on graph B
E event marker (vertical)id : X : label : colour : styleFive phases of the run, at 2, 15, 21, 26 and 29 min
T noteid : X : Y : text : colour : size : rotation“Peak 82.6 °C” at 19.33 min and 89.6, 12 pt, not rotated
B bookmarkX : label : comment : colourThe overcurrent trip at 16.4 min, listed in the Graph Bookmarks panel

Styles are S solid, D dashed, T dotted and A dash-dot. Positions are in the graph’s own X units: a sample number on graph A (450), minutes on graph B (21), so a line can be sent when the event happens or later. The note sits 7 °C above the MOSFET peak to keep the trace clear. The same id sent again moves or relabels the item.

Set it up in SerialFlow

  1. Pick the board’s COM port and baud rate in the toolbar and press Connect.
  2. That is all. The first ~{A:I:…} line opens a Speed Control tab, and ~{B:I:…} opens Thermal & Battery. Names, colours, axes, legend, limit lines and markers all come from the firmware.
  3. Optional: to see both graphs at once, drag one graph tab over the other graph and drop it on a side of the dock cross that appears.

The graph lines stay out of the terminal log, which keeps only the text meant for people.

The result

Animation: a speed graph scrolling left as the speed follows setpoint steps.
The streamer: the newest 800 samples slide left as the speed follows each set-point step.
Graph of motor and MOSFET temperature, pack voltage and state of charge over 40 minutes, with dashed event lines and a red limit line.
The logger: the whole 40-minute run, with the 85 °C limit line, five event markers and the peak note.

Look closer: lanes, markers and statistics

  • Stacked lanes: press Signals, expand each signal and set its Lane (here 0 for both temperatures, 1 for the pack voltage, 2 for the state of charge). Then press Overlay: it changes to Stacked.
  • Markers: right-click the plot → Add X Marker Here or Add Y Marker Here. In ☰ → View → Graph Markers, Ctrl+click two markers on the same axis and press Pair for the Δ, plus mean, RMS and peak-to-peak between X markers.
  • Statistics: Stats shows min, max, average, RMS, standard deviation, peak-to-peak and count over the last 100 points of each signal. Hold Alt and drag across the plot: a Sel column adds the values for that region.

In your own firmware

The main page’s sketch draws a streamer. This is its logger twin: time in minutes, a limit line, and an event marker the first time the MOSFET passes 82 °C. readMosfetTemp() stands for your own measurement code.

bool derated = false;

void setup() {
    Serial.begin(115200);
    Serial.println("~{B:I:Thermal:100000:L:T:R:Time:min:0}");   // logger, X in minutes
    Serial.println("~{B:S:1:F32:R:MOSFET:C:0:F06292}");
    Serial.println("~{B:H:1:85:FF5252:D:MOSFET limit 85 C}");   // red dashed limit line
}

void loop() {
    float t = millis() / 60000.0;              // minutes since reset
    float mosfet = readMosfetTemp();
    Serial.print("~{B:0:");                    // explicit X: the time comes first
    Serial.print(t, 4);
    Serial.print(":");
    Serial.print(mosfet, 2);
    Serial.println("}");
    if (mosfet > 82.0 && !derated) {           // once: an event marker at the same X
        derated = true;
        Serial.print("~{B:E:1:");
        Serial.print(t, 2);
        Serial.println(":Thermal derate:FF5252:D}");
    }
    delay(2000);                               // one row every 2 s
}

Good to know

  • Put one ~{…} command per line. A second command on the same line is ignored.
  • Auto-X keeps a streamer’s lines short, but an explicit time X works too: the live window is then as wide as the buffer holds, for example 800 samples 10 ms apart show 8 s.
  • A logger’s history is not set by the buffer size: it keeps up to 1 000 000 points per signal by default. Change that with right-click on the plot → Ingest Policies… (0 = no limit).
  • ~{B:E:3} removes event 3 and ~{B:E:0} removes them all; H and T work the same way. ~{B:C} clears the data, restarts auto-X and removes notes and events, but keeps limit lines and bookmarks.
  • ☰ → View → Raw Display shows the graph lines as text. The graphs stop updating while it is on.
  • Save Session keeps the data, limit lines, events, notes and bookmarks in one .sfplot file, and the firmware’s Y range, axis label and legend come back with it. Markers you place by hand are not saved.

Try it yourself

  1. ☰ → Test → Load Test File → Demo → showcase_preload.txt. Open the Speed Control and Thermal & Battery tabs.
  2. ☰ → Test → Delayed Playback → Demo → showcase_live.txt. Speed Control scrolls on for about 1 min 50 s.
  3. On Thermal & Battery, Alt-drag from 15 to 26 min and press Stats: the Sel column shows the hill climb.
  4. ☰ → View → Graph Bookmarks, then double-click Overcurrent trip to jump to it.