Shop OBEX P1 Docs P2 Docs Learn Events
Servo controller(#28823) and MATLAB — Parallax Forums

Servo controller(#28823) and MATLAB

servoservo Posts: 6
edited 2006-08-06 18:17 in General Discussion
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

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-07-29 21:40
    This thread is being moved from the BASIC Stamp Forum to the Sandbox Forum.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • FranklinFranklin Posts: 4,747
    edited 2006-07-29 22:01
    You might try fprintf(s,'!SCVER?\n')

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Kevin WoodKevin Wood Posts: 1,266
    edited 2006-07-29 22:38
    Are you sure MATLAB is seeing your USB connection?
  • servoservo Posts: 6
    edited 2006-07-30 15:27
    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.
  • servoservo Posts: 6
    edited 2006-08-06 02:45
    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,[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.
  • Kevin WoodKevin Wood Posts: 1,266
    edited 2006-08-06 04:12
    Comparing your original code with your modified code:

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

    You could try:
    fprintf(ser,'!SCVER?\r')
  • servoservo Posts: 6
    edited 2006-08-06 18:17
    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,[noparse][[/noparse]33 83 67 86 69 82 63 13], 'uint8', 'sync');
    out = fscanf(ser);
    fclose(ser)
    delete(ser)
    clear ser
Sign In or Register to comment.