使用串口繪制實時曲線 —— SerialChart


SerialChart:下載

1. 實驗效果

2. 串口程序

  while(1){
        if(++x>=180){
            y = 90;
            x = 0;
        }
        if(x>=90)    y++;
        else             y--;
        z = sin(x*Pi/90);
        p = cos(x*Pi/90);
        r = tan(x*Pi/90);
    printf("%d,%d,%d,%d,%f,%f,%f\n",t,0,x,y,z,p,r);
        delay_ms(50);
        t++;
    }

 

3. 數據格式

Interval

Dat1

Dat2

。。。

Datn

\n

 

 

數據以幀為單位,其中Interval設為整形即可,用處是用來分辨當前數據是那一時刻的數據,你也可以用來顯示,甚至不用Interval(把它當成一個通道的數據),例子中Interval的值設置為了transparent,即不顯示。

Dat是你想用來顯示的數據,最多支持多少沒有測試,不夠是夠用了。

最后‘\n’代表着該幀的結束

總結一下

  • 通過  ‘,’  來區分不同通道數據,從前往后依次為通道“1...n”。
  • 通道1,一般用來作為時間標志來確定那一時刻的數據,也可作序列號來確定丟包率。
  • 通道2..n,根據自己需要配置
  • 最后輸出換行符 '\n' 作為幀結束標志

4. 配置

[_setup_]
port=COM2   
baudrate=115200

width=1000
height=201
background_color = white

grid_h_origin = 100
grid_h_step = 10
grid_h_color = #EEE
grid_h_origin_color = #CCC

grid_v_origin = 0
grid_v_step = 10
grid_v_color = #EEE
grid_v_origin_color = transparent

[_default_]
min=-1
max=1

[interval]
color= transparent
min=0
max=500

[level]
color=black

[sawtooth]
color=blue
min=-10
max=190

[triangular]
color=red
min=-10
max=110

[sin]
color=green    
min=-1.3
max=1.3

[cos]
color=pink
min=-1.3
max=1.3

[tan]
color=purple
min=-10
max=10 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM