MODBUS communication for the controlling of peristaltic pump,

6 ビュー (過去 30 日間)
Kang Soo Lee
Kang Soo Lee 2019 年 5 月 31 日
コメント済み: Kang Soo Lee 2021 年 2 月 6 日
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 Center および File ExchangeModbus Communication についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by