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

Oscilloscope frames and an XY current vector

Send the points, then one flush line. The whole frame appears at once.

  • Frame mode: data lines, then F
  • 145 points per phase-current frame
  • XY: chosen by the data, no switch
  • Nothing to set up in SerialFlow

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 an oscilloscope view of the motor: the three phase currents over two electrical turns, and the current vector as a shape. Both change as a whole when the load changes, so the firmware sends a complete frame and SerialFlow shows it in one step.

What the firmware prints

Frame mode uses the same init and signal lines as any other graph, with mode F. The data lines fill a hidden staging buffer. One extra line, F for flush, puts them on screen.

Graph C: Phase Currents, one frame at a time

The set-up and one frame of graph C, from showcase_preload.txt:

~{C:I:Phase Currents:256:F:V:R:Electrical angle:°:0}
~{C:S:1:F32:R:Ia:A:0:FF5252}
~{C:S:2:F32:R:Ib:A:0:FFD740}
~{C:S:3:F32:R:Ic:A:0:40C4FF}
~{C:H:1:22:FF5252:T:Trip ±22 A pk}
~{C:H:2:-22:FF5252:T:}
~{C:Y:R:-28:28}
~{C:Y:L:Phase current:A}
~{C:L:1:TR:12:210}
~{C:0:0:0.018:-15.415:15.170}
~{C:0:5:2.154:-16.344:14.185}
~{C:0:10:4.246:-17.064:12.798}
…
~{C:0:715:-2.015:-13.884:16.253}
~{C:0:720:-0.157:-15.196:15.247}
~{C:F}

The init lines of both frame graphs, field by field:

FieldGraph CGraph DMeaning
namePhase CurrentsCurrent Vector αβTab title
buffer size256400The most points one frame can hold, per signal
modeFFFrame
X typeVVV value, T time. Stored with the graph; both draw the same axis
X displayRRR raw, F formatted. Stored with the graph; both look the same
X labelElectrical angleIαX-axis label
X unit°AX-axis unit
X SI prefix00X as sent

Graph C has three signals, Ia, Ib and Ic: 32-bit floats (F32) written as real numbers (R), in amps, in red, yellow and blue. The two dotted H lines mark the ±22 A trip level; the second has an empty label, so the text appears once. ~{C:Y:R:-28:28} fixes the Y axis, so a small frame and a large one are drawn to the same scale.

Each data line uses explicit X (command 0): the electrical angle in degrees, then Ia, Ib, Ic. The preload sends 145 points, every 5° from 0 to 720°, which is two electrical turns. Then ~{C:F} ends the frame. This is how the swap works:

  1. Each data line goes into a staging buffer, one per signal. Nothing on screen changes.
  2. ~{C:F} replaces the displayed frame with the staged points in one step, empties the staging buffer and adds one to the frame count.
  3. The graph redraws only then, so you never see half a frame.

The status strip in the graph toolbar shows the frame count (Frame # 1), how full the staging buffer is (0/256), and Receiving… while points arrive or Static once the frame is shown.

Graph D: Current Vector αβ, drawn as XY

~{D:I:Current Vector αβ:400:F:V:R:Iα:A:0}
~{D:S:1:F32:R:Iβ:A:0:69F0AE}
~{D:Y:R:-26:26}
~{D:Y:L:Iβ:A}
~{D:L:0}
~{D:0:19.542:-0.027}
~{D:0:19.531:0.672}
~{D:0:19.437:1.166}
…
~{D:0:19.598:-0.028}
~{D:F}

Graph D has one signal, Iβ. Iα travels as the X value of each point: ~{D:0:19.542:-0.027} is the point Iα = 19.542 A, Iβ = −0.027 A. One frame is 181 points, one every 2° around a full turn, then ~{D:F}.

There is no XY command and no XY menu item: SerialFlow decides from the data. While every X is at least as large as the one before, it draws an ordinary trace. Once an X value goes back, it joins the points in the order they arrived. Around a turn, Iα rises and falls, so the frame becomes a closed curve. The V in the init line marks X as a value axis, with Iα and A as its label.

~{D:Y:R:-26:26} fixes Y at ±26 A and ~{D:Y:L:Iβ:A} labels it. ~{D:L:0} hides the legend, whatever Show legend says on the New View Defaults tab of Graph View Settings…. Click the plot and press G to show it anyway.

The demo file leaves X free, so each frame fills the width of the pane. Two more lines keep the vector round: ~{D:X:R:-26:26} fixes X the way Y:R fixes Y, and ~{D:X:E:1} draws one amp as long on X as on Y, so a circle stays a circle in a wide pane. They need SerialFlow 0.9.0 beta 2: beta 1 reads every ~{D:X…} line as “delete graph D”.

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. ~{C:I:…} opens a Phase Currents tab and ~{D:I:…} opens Current Vector αβ, each redrawn at every F.
  3. Optional, if the firmware sends no X:R line: once Current Vector αβ shows a frame that spans the X range you want, press Fit on its toolbar. Later frames keep that X range instead of each one filling the width, until you double-click the plot.

The result

Both animations are frame sequences: SerialFlow drew each frame from its own one-frame file, 64 frames per loop.

In your own firmware

The same Serial.print pattern as the sketch on the main page, now in frame mode. One function sends a frame of each graph; your own sampling code fills the arrays. Keep n at 256 or fewer, the buffer size of graph C.

void setup() {
    Serial.begin(921600);
    Serial.println("~{C:I:Phase Currents:256:F:V:R:Electrical angle:deg:0}");
    Serial.println("~{C:S:1:F32:R:Ia:A:0:FF5252}");
    Serial.println("~{C:S:2:F32:R:Ib:A:0:FFD740}");
    Serial.println("~{C:S:3:F32:R:Ic:A:0:40C4FF}");
    Serial.println("~{D:I:Current Vector:400:F:V:R:I alpha:A:0}");
    Serial.println("~{D:S:1:F32:R:I beta:A:0:69F0AE}");
    Serial.println("~{D:Y:R:-26:26}");                          // fix Y ...
    Serial.println("~{D:X:R:-26:26}");                          // ... and X (beta 2)
    Serial.println("~{D:X:E:1}");                               // 1:1, a circle stays round
}

void sendFrames(const float *ia, const float *ib, const float *ic,
                const float *alpha, const float *beta, int n, int stepDeg) {
    for (int i = 0; i < n; i++) {
        Serial.print("~{C:0:"); Serial.print(i * stepDeg);      // X = angle
        Serial.print(":"); Serial.print(ia[i], 3);
        Serial.print(":"); Serial.print(ib[i], 3);
        Serial.print(":"); Serial.print(ic[i], 3); Serial.println("}");
    }
    Serial.println("~{C:F}");                                   // show frame C at once
    for (int i = 0; i < n; i++) {
        Serial.print("~{D:0:"); Serial.print(alpha[i], 3);      // X = I alpha
        Serial.print(":"); Serial.print(beta[i], 3); Serial.println("}");
    }
    Serial.println("~{D:F}");                                   // show frame D at once
}

Good to know

  • Points beyond the buffer size (256 for graph C, 400 for graph D) before the F are dropped.
  • F also restarts the auto-X counter, so frames sent with auto-X (~{C:1:…}) start at X = 0 every time. While a graph is paused (~{C:P}), data lines and F are discarded.
  • A frame graph fits X to every new frame until ~{D:X:R:min:max} fixes it; ~{D:X:A} lets it fit again. ~{D:X:E:1} keeps the aspect ratio at 1:1 (0 switches it off; overlay layout only). A zoom, pan or Fit on the PC wins over the firmware’s X range until you double-click the plot.
  • Put one ~{…} command per line, so a text frame costs one line per point. For high-rate data there is also a packed binary mode that carries many rows per packet. The MDX-400 example does not use it.

Try it yourself

  1. ☰ → Test → Load Test File → Demo → showcase_preload.txt. Open the Phase Currents tab: one frame, Frame # 1.
  2. ☰ → Test → Delayed Playback → Demo → showcase_scope_live_c.txt. Fourteen frames of 73 points follow, and the amplitude climbs from 10 A to 20 A, then settles at 14 A. The file plays at about 60 lines/s (DELAY:16), so a new frame appears about every 1.2 s, and the frame count in the status strip goes up by one each time.
  3. Open Current Vector αβ and play showcase_scope_live_d.txt the same way: 27 frames of 37 points.