A MATLAB example codes with RS485 Modbus RTU

Discuss Stepper motors, Drivers, Controllers, GUI's and related Accessories here.
kiwi
Posts: 1
Joined: Tue Apr 15, 2014 8:11 pm

A MATLAB example codes with RS485 Modbus RTU

Postby kiwi » Tue Apr 15, 2014 8:31 pm

Hello, I am a newer on stepper motor control. My motor is PK543AW-T10. I have to use MATLAB control the stepper motor. One example is for continuous operation. Here is my Matlab code,but it doesn't work, i do not know how to write operation codes in Matlan.Please help me:) .

Code: Select all

clc;
disp('BEGIN PROGRAM');
s=serial('COM1');
set(s,'BaudRate',9600);
set(s,'DataBits',8);
set(s,'Parity','even');
set(s,'StopBits',1);
set(s,'FlowControl','none');
set(s,'OutputBufferSize',50000);
set(s,'InputBufferSize',50000);
set(s,'Timeout',100);
set(s,'Terminator','CR');
fopen(s);

fwrite(s,[1 6 0 30 32 0 240 12]);%C-ON start in dec
fread(s);
fwrite(s,[1 16 5 2 0 2 4 0 0 19 136 64 112]);%Frequency 5000Hz
fread(s);
fwrite(s,[1 6 0 30 34 1 48 172]);%FWD on
fread(s);

fclose(s);
delete(s);
clear s
disp('STOP')

Here is user manual:http://www.orientalmotor.com/products/pdfs/opmanuals/HM-40112-3E.pdf Continuous operation is on P.77

opppasopooew
Posts: 13
Joined: Tue Oct 28, 2014 1:49 pm

Re: A MATLAB example codes with RS485 Modbus RTU

Postby opppasopooew » Wed Oct 29, 2014 4:42 am

A great exchange of information.

User avatar
om_tech_support_JT
Posts: 1058
Joined: Fri Mar 12, 2010 2:59 pm
Location: Torrance, CA
Contact:

Re: A MATLAB example codes with RS485 Modbus RTU

Postby om_tech_support_JT » Mon Dec 08, 2014 6:08 pm

Unfortunately, the product was designed for Modbus RTU so Oriental Motor does not support MATLAB. Thanks to your notes, I understand what you're trying to do.

Regarding this line:

fwrite(s,[1 16 5 2 0 2 4 0 0 19 136 64 112]);%Frequency 5000Hz

For the 5000 Hz, which Data # / register address did you write to? If only FWD input is ON (without M0~M5 inputs ON), it refers to the speed set for Data 0. If nothing is programmed for Data 0, then it wouldn't respond.

icontrolthings
Posts: 4
Joined: Thu Aug 24, 2017 10:46 am

Re: A MATLAB example codes with RS485 Modbus RTU

Postby icontrolthings » Thu Sep 07, 2017 2:59 pm

Were you ever able to properly control via matlab?


Return to “Stepper Motors and Controls”

Who is online

Users browsing this forum: No registered users and 1 guest