PDA

View Full Version : Servo controller(#28823) and MATLAB



servo
07-30-2006, 04:09 AM
Hello everyone,

I bought Parallax servo controller (#28823)·with USB interface to control 16 servo motors. I am using MATLAB for the programming purpose.

I used the following program to get the version number of the controller board but that does not give me the required output.

function out=new
s = serial('COM4');
set(s,'BaudRate',2400);
fopen(s);
fprintf(s,'!SCVER?')
fprintf(s,'\r')
out = fscanf(s);
fclose(s)
delete(s)
clear s
The output I got is as following.
ans =
!SCVER?

Please suggest what corrections I need to make.

Thanks in advance

Chris Savage
07-30-2006, 04:40 AM
This thread is being moved from the BASIC Stamp Forum to the Sandbox Forum.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com (mailto:csavage@parallax.com)

Franklin
07-30-2006, 05:01 AM
You might try fprintf(s,'!SCVER?\n')

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen

Kevin Wood
07-30-2006, 05:38 AM
Are you sure MATLAB is seeing your USB connection?

servo
07-30-2006, 10:27 PM
Yes, the light is blinking when I pass the commands to it. There are 2 lights, the red and the green ones.
The red light is on when the board is connected and the other is blinking when the commands are passed.

servo
08-06-2006, 09:45 AM
I am able to get the version of the Parallax servo controller using MATLAB.
Parallax servo controller accepts commands in the form of ASCII characters, so converting all the commands into ASCII code worked.

function out=sversion
ser = serial('COM4');
set(ser,'BaudRate',2400);
fopen(ser);
fwrite(ser,[33 83 67 86 69 82 63 13], 'uint8', 'sync');
out = fscanf(ser);
fclose(ser)
delete(ser)
clear ser

The above program gives the version of the Parallax servo controller. The numbers in the square brackets in the fwrite command are ASCII conversion of !SCVER? and the last number 13 is for the carrige return.

Kevin Wood
08-06-2006, 11:12 AM
Comparing your original code with your modified code:

Instead of this:
fprintf(s,'!SCVER?')
fprintf(s,'\r')

You could try:
fprintf(ser,'!SCVER?\r')

servo
08-07-2006, 01:17 AM
The fprintf(ser,'!SCVER?\r') doesnot work.

The program given bleow works.

function out=sversion
ser = serial('COM4');
set(ser,'BaudRate',2400);
fopen(ser);
fwrite(ser,[33 83 67 86 69 82 63 13], 'uint8', 'sync');
out = fscanf(ser);
fclose(ser)
delete(ser)
clear ser