MODBUS communication for the controlling of peristaltic pump,

10 次查看(过去 30 天)
Hi,
I am working on the MODBUS communication to control my peristaltic pump. I am using the following code:
peri_pump = serial('COM7');
set(peri_pump,'BaudRate',9600,'DataBits',8,'StopBits',1,'Parity','Even','Timeout',10);
fopen(peri_pump);
% start the pump
request = uint8(hex2dec(['01'; '06'; '03'; 'F0'; '00'; '01'; '48'; '7D']));
fwrite(peri_pump, request);
% stop the pump
request = uint8(hex2dec(['01'; '06'; '03'; 'F0'; '00'; '00'; '89'; 'BD']));
fwrite(peri_pump, request);
% set the flow rate 50 ml/min
request = hex2dec(['01'; '10'; '03'; 'EC'; '00'; '02'; '04'; '42'; '48'; '00'; '00'; '7D'; '2C']);
fwrite(peri_pump, request);
fclose(peri_pump)
'start' and 'stop' commands are working, however 'set the flow rate' is not working (nothing happens). In the manufacturer's instruction (link; page 5), 'start/stop' uses 'unsigned short int format' and 'set the flow rate' uses 'float format'. Anyone knows how to make 'set the flow rate' work? Any input would be appreciated.
Thanks!
Kang

采纳的回答

Gustavo Dacanal
Gustavo Dacanal 2019-6-3
Dear Kang,
I will reccomend you try to send the hex command using "SimpleModbus software" and verify if your pump is regulating and working well.
If you get a satisfatory pump command with SimpleModbus but your matlab code still not working, then, you could try to insert the matlab commands fread and/or fclose after an input fwrite. *you will need to open the COM port every time you close it.
Tell me if you get any progress.
Regards
Gustavo
  1 个评论
Kang Soo Lee
Kang Soo Lee 2021-2-6
Sorry for being late! I decided to use only "on" and "off" functions, as I did not need to frequently change the flow rate. But, your reply inspired my curiosity. I will check and see if your suggestion works. When I have an update, I will write again in this post for future users.
Thank you!
Best regards,
Kang

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by