problem with serial port

2 views (last 30 days)
Zhiguang
Zhiguang on 28 Apr 2014
I tried to use Matlab to control a motor with RS485 serial port. My PC does not have an original serial port, this port is transformed with a USB plugin (provided with the motor). The PC recognizes it as COM3. The motor can be controlled by the manufacturer's GUI. Now I am trying Matlab to control it. After setting the parameters of the port, I can get its information by command get(s) and the status is open, but if I want to send any command to the port, the motor does not act at all. When I tried to read the response from it, it always shows "Warning: Unsuccessful read: A timeout occurred before the Terminator was reached." Who can help me out? My codes:
s = serial('COM3'); fopen(s);
set(s,'BaudRate',9600,'DataBits',8,'StopBits',1,... 'Parity','none','FlowControl','none', 'Terminator', 'CR/LF');
fprintf(s,'*IDN?') out = fscanf(s);
Now came out "Warning: Unsuccessful read: A timeout occurred before the Terminator was reached. " The same information for other commands sent to the port.

Answers (0)

Categories

Find more on MATLAB 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!