mcu_ctrl_cmd_demo

Common board communication protocol (hw:serial port)

baudrate : 115200 bps 8,1,None command & feedback end with “\r\n”

Board summy

status board name *slaver address
range: 0-255
eg. remark standard
Herring board 2 2,get_volt,1\r\n
USB DAQ-S1 board 5 5,get_volt,1\r\n
Voltage balance - cell1\r\n


* standard board rules Format:slaver_address(addr) + ‘,’ + cmd (end with “\r\n”)


Herring board

index cmd para return eg. description
01 get_curr ch 0.0123 get_curr,[ch] get [ch] csa chip current
02 get_volt ch 12.345678 get_volt,[ch] get [ch] csa chip voltage
03 get_pwr ch 2.345678 TBD TBD
04 set_ovp ch,volt null set_ovp,[ch],[volt] set [ch] ovp voltage as [volt]
05 read_ovp ch 1.2345 read_ovp,[ch] read [ch] ovp voltage
06 set_curr_rate ch,rate null set_curr_rate,[ch],[rate] set [ch] csa rate as [rate]
07 set_curr_range ch,range null set_curr_range,[ch],[range] set [ch] csa rate as [range]
08 cat_io_set io,state null cat_io_set,[ch],[state] set [io] as [state]
09 cat_io_read io state cat_io_read,[io] read [io] state
99 *idn? - - read back version

USB DAQ-S1 board

index cmd para return eg. description
01 get_volt ch [pass],volt get_volt,[ch] get [ch] voltage
ch
1:AI1
2:AI2
3:AI3
4:AI4
5:reserve
6:reserve
7:reserve
8:AO1
9:AO2
02 set_volt ch,volt [pass] set_volt,[ch],[volt] set dac [ch] chip volt
ch
1:reserve
2:reserve
3:reserve
4:reserve
5:reserve
6:reserve
7:reserve
8:AO1
9:AO2
03 relay_get relay [pass],state relay_get,[relay] get [relay] [state]
relay
1:Rp1&Rn1
2:Rp2&Rn2
3:Rp3&Rn3
4:Rp4&Rn4
5:Rp&Rn
04 relay_set relay,state [pass] relay_set,[relay],[state] set [relay] as [state]…
05 di_get di [pass],state di_get,[di] get [di] state
di
1:DI_ISO1
2:DI_ISO2
3:DI_ISO3
4:DI_ISO4
06 dio_get io [pass],state dio_get,[io] get [io] state
io
1:DIO1
2:DIO2
3:DIO3
x:DIOx
8:DIO8
07 dio_set io,state [pass] dio_set,[io],[state] set [io] as [state]…
08 dio_cfg io,mode [pass] dio_cfg,[io],[mode] io
mode
0:output pull-push
1:output open drain
2:input
3:input analog
4:input pull-up
5:input pull-down
6:input floating
7:pwm output
8:pwm open-drain
9:comp intput
9 cal_get ch [pass],k,b,g cal_get,[ch] ch default:g=1.0 b=0.0
0:Vreference
1:AI1
2:AI2
3:AI3
4:AI4
5:reserve
6:reserve
7:reserve
8:AO1
9:AO2
10 cal_set ch,k,b [pass] cal_set,[ch],[k],[b] ch default:g=1.0 o=0.0 …
99 *idn? - version - -

Voltage balance board [nonstandard]

index cmd return description
1 cell_close ok close all relay
2 cell_now cellx
null
get now relay is cellx, or null
3 cell1 ok set cell1 ch relay
4 cell2 ok set cellx ch relay
… … ok set … ch relay
18 cell16 ok set cell16 ch relay
remark - - 1. whole channel only support set a channel
2. others channel will auto close when set a channel
3. out of cmd list cmd_str will not feedback

经典示例


作者:EnzoSun
微信关注:勿忘初兴
本文出处:http://sunduoze.github.io/post/mcu_ctrl_cmd_demo/
文章版权归本人所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。