Servo controller(#28823) and MATLAB
servo
Posts: 6
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
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
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
The red light is on when the board is connected and the other is blinking when the commands are passed.
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,[noparse][[/noparse]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.
Instead of this:
fprintf(s,'!SCVER?')
fprintf(s,'\r')
You could try:
fprintf(ser,'!SCVER?\r')
The program given bleow works.
function out=sversion
ser = serial('COM4');
set(ser,'BaudRate',2400);
fopen(ser);
fwrite(ser,[noparse][[/noparse]33 83 67 86 69 82 63 13], 'uint8', 'sync');
out = fscanf(ser);
fclose(ser)
delete(ser)
clear ser