Shop OBEX P1 Docs P2 Docs Learn Events
Parallax Servo Controller (PSC) with SX/B. — Parallax Forums

Parallax Servo Controller (PSC) with SX/B.

Wissam Ch.Wissam Ch. Posts: 36
edited 2008-12-08 00:07 in General Discussion
Dear All ,
Iam working on the PSC but using the SX 28 MC and SX tech board.
The documentation and code examples for PSC is based on BS2 MC.
To communicate with the PSC and set the position of a servo·the documentation states the following·:
Position Command – Set the Position of a Servo Channel
Syntax: “!SC” C R pw.LOWBYTE, pw.HIGHBYTE, $0D
Reply: none
C· : is the servo channel
R : is the ramping value .
PW : is the position value.
and the code i used is· :
SEROUT Sdat, Baud,[noparse][[/noparse]"!SC", 0, 15, pw.LOWBYTE, pw.HIGHBYTE, CR]
The command string is 8 byte long ending with "CR" .

the Baud value is 396 corresponding to speed 2400 which is the defualt for the PSC.

The code runs properly in BS2 and the servo responds to position commands.

I tried to do this using SX/B and used the following code :

PW·········· VAR· WORD
PSC········· PIN· RC.7
ServoCmd· VAR· Byte(8)
idx··········· VAR Byte
Baud········· CON· "T2400"

........
........
........
Start:
· ' initialization code here
·INITIALIZE_PSC_CMD
Main:
· ' main code here
· TX_PSC_CMD
· END


SUB INITIALIZE_PSC_CMD
····· PW = 750· 'Center the servo.
······ServoCmd(0)="!"
····· ServoCmd(1)="S"
····· ServoCmd(2)="C"
······ServoCmd(3)=·0
····· ServoCmd(4) = 15 'Ramping value
····· ServoCmd(5)= PW_LSB
····· ServoCmd(6)= PW_MSB
····· ServoCmd(7)=13
·ENDSUB

SUB TX_PSC_CMD
··· FOR idx = 0 to 7
····· ·SEROUT PSC, Baud, ServoCmd(idx) ' send the command, byte at a time
··· NEXT

ENDSUB

The expected servo never responds to the command , no matter what PW value is used.

Appreciate any help.


·

Comments

  • BeanBean Posts: 8,129
    edited 2008-12-07 13:49
    Wissam,
    · I can think of several things that might be the problem.

    ··Make sure you are NOT using the internal oscillator (OSC4MHZ on the DEVICE line), because the internal oscillator is not accurate enough for serial communications. Use a resonator.

    · Put the output pin into the correct idle state before sending the data. Use "HIGH PSC" "PAUSE 5" right after "Start:".

    ··Try to send a zero byte before the "!SC" command.

    · P.S. Please post the entire program. That will help us help you.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    "The welfare of the people in particular has always been the alibi of tyrants." ~ Camus
    www.iElectronicDesigns.com



    Post Edited (Bean (Hitt Consulting)) : 12/7/2008 2:02:11 PM GMT
  • Wissam Ch.Wissam Ch. Posts: 36
    edited 2008-12-07 15:55
    Hello Bean ,

    I did the changes you·suggested , but no results at all .

    Iam attaching the whole program code , and a photo for the conenctions.
    2048 x 1536 - 654K
  • BeanBean Posts: 8,129
    edited 2008-12-07 17:14
    Thanks, the whole program and picture are very helpful in assisting you.

    I assume you are using a 4MHz resonator ?

    The only thing I see that might help is to change OSCHS1 to OSCXT1.
    OSCHS1 is for higher frequencies (like 20MHz).

    Also if you are using the USB SX-Key, use Run->Clock to set the key to 4MHz. Usually you only have to do this once until you quick the SX-Key IDE.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    "The welfare of the people in particular has always been the alibi of tyrants." ~ Camus
    www.iElectronicDesigns.com

    ·
  • Wissam Ch.Wissam Ch. Posts: 36
    edited 2008-12-07 22:12
    Hello Bean ,

    I found the problem.

    Using an oscilloscope, I checked the serial output signal from both boards SX & BS2 and found that the signal from the SX board contains lots of noise , while the BS2 signal is almost perfect square signal.

    I traced the voltage supply and found it noisy on the SX and DC stable on the BS2.

    I added a 100 uf·capacitor on the output of the voltage regualtor , and checked the output signal from the SX board and the result was great , almost a perfect square signal.

    i connected the PSC and the motors roared· [noparse]:)[/noparse] .

    Thanks for your valuable tips.
  • Wissam Ch.Wissam Ch. Posts: 36
    edited 2008-12-08 00:07
    By the way.
    Whenever i try to change the clock speed from the Menu Run-Clock , i got a reading of 0.04 MHZ and an error :
    Communication error :154 .
    I was never able to change this clock setting.
    Any advise ?
Sign In or Register to comment.