Problems receiving data from serial device

2 Ansichten (letzte 30 Tage)
Katherine
Katherine am 18 Dez. 2014
Kommentiert: Star Strider am 19 Dez. 2014
Hello,
I am trying to receive data from a serial device - a motor controller. This controller reports position, velocity, acceleration, and the status of the device over a serial interface.
I have opened the correct comport, have the baud rate set to the correct value, and am able to write commands to the device and have it respond properly. However, I am unable to get any kinds of messages from the device.
The fprintf(s,'R/n') command will write the command 'R' to the serial device - this requests the status of the device (i.e. busy, idle, able to recieve inputs, etc). When I am connected to a serial port console (Putty), I get a status message reading back in the console - a *R, *B, *S, or *C, depending on the status of the device.
This is not the case for Matlab. I have tried fscanf, freadf, fgets, and basically every kind of serial communication command that I can find online. fcanf will return the last command that was sent to the device, as opposed to the status - similar outcomes for the other commands.
Here is an example of what is occuring.
>> s = serial('COM6');
>> fopen(s)
>> s.Terminator = 'LF/CR';
>> fprintf(s,'R/n')
>> fscanf(s)
ans =
R/n
Help is very much needed and appreciated - I'm at a loss.
  1 Kommentar
Star Strider
Star Strider am 19 Dez. 2014
I’m not sure what to suggest, other than to go online to get the documentation for the interface hardware and driver. I don’t have experience with motor controllers, but remember having to do that to understand how to get data from a fingertip pulse oximiter connected to a USB port (virtual serial port).
You don’t say what you’re doing in any detail, so this is only a guess.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by