MODBUS communication for the controlling of peristaltic pump,
6 views (last 30 days)
Show older comments
Kang Soo Lee
on 31 May 2019
Commented: Kang Soo Lee
on 6 Feb 2021
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
0 Comments
Accepted Answer
Gustavo Dacanal
on 3 Jun 2019
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
More Answers (0)
See Also
Categories
Find more on Modbus Communication in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!