help-octave
[Top][All Lists]
Advanced

[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);
    srl_flush(s1);

    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")
      drawnow()
      pause(1)
    endwhile
    srl_close(s1)

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. 

<http://octave.1599824.n4.nabble.com/file/t372752/data.png> 

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: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html



reply via email to

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