MODBUS communication for the controlling of peristaltic pump,

조회 수: 10 (최근 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 CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by