[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Realtime plot of floating point data from Serial

From: borabut
Subject: Realtime plot of floating point data from Serial
Date: Sun, 25 Feb 2018 13:36:13 -0700 (MST)

Im having trouble getting a real time plot of my serial data on Octave. Im
trying to read some floating point values being sent by an arduino, and plot
them at a rate of 1hz from Octave. My code is below.

    s1 = serial("COM4", 115200);
    set(s1, 'timeout', 1);

    pid_plot = 0;
    pid_sp = 0;

    while true    
      data_serial = srl_read(s1,4)
      data_float = typecast(uint8(data_serial), 'single')
      pid_plot = cat(1, pid_plot, data_float)
      plot(pid_plot, "color", "b")
      hold on
      plot([pid_sp,pid_sp], "color", "r")

This code is being used to visualize the output of a PID loop to aid in
tuning. Right now my arduino code is just dummy code that writes sine wave
data over serial. The arduino plotter works fine, showing a perfect sine
wave but octave shows garbage data. 


Obviously these data points are wrong since sine wave can only be between -1
and 1, and arduino plotter shows exactly that. What am I doing wrong that my
floating point values are getting mangled in Octave?

Sent from:

reply via email to

[Prev in Thread] Current Thread [Next in Thread]