Shop OBEX P1 Docs P2 Docs Learn Events
Serial Servo Controller + Arduino HELP! — Parallax Forums

Serial Servo Controller + Arduino HELP!

pbohmpbohm Posts: 2
edited 2007-11-28 14:25 in General Discussion
I am trying to control the Parallax Servo Controller with an Arduinoboard, but those little guys won't obey my orders...

So far I got everything hocked-up (Servos are "twitching" every time I reset the controller, so I guess the hardware is set up correctly?!). When I send serial data from the Arduino the green LED on the controller is flashing, so that seems to be alright, too. My serial monitor shows this data to be sent: 53 43 01 00 00 03 0D (!SC ch1 ramp0 pw 300 CR).
The code looks the following:

Serial.print(33, BYTE); //!
Serial.print(83, BYTE); //S
Serial.print(67, BYTE); //C
Serial.print(1, BYTE); //channel 01
Serial.print(0, BYTE); //rampspeed 0
Serial.print(0, BYTE); //LSB for the pw 0
Serial.print(3, BYTE); //MSB fot the pw 3

Serial.print(13, BYTE); //CR

I am sending everything with 2400 Baud and I've tried it with a pull-up resistor and without.
... but the thing is not moving.
So if anybody has an idea why not please help me out!
Thank you very much

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-11-28 06:02
    Is the Arduino sending the data with "true" logic? In other words, the idle state of the line should be high, one bits should be high and zero bits should be low.
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2007-11-28 07:17
    pbohm -

    See if the following doesn't work a bit better:

    ··· Serial.print(33, BYTE);· //!
    ··· Serial.print(83, BYTE);· //S
    ··· Serial.print(67, BYTE);· //C
    ··· Serial.print(49, BYTE);· //channel 01
    ··· Serial.print(48, BYTE);· //rampspeed 0
    ··· Serial.print($00, BYTE);· //LSB for the pw 0
    ··· Serial.print($03, BYTE);· //MSB for the pw 3
    ·······
    ··· Serial.print(13, BYTE);· //CR<!--StartFragment -->

    I have used the "$" above to indicate a HEX number above, and below. That may need to be changed based on the particular computer·language you're using. All other numbers are DECIMAL.

    If that doesn't work, I would attempt to use the following:

    ··· Serial.print(33, BYTE);· //!
    ··· Serial.print(83, BYTE);· //S
    ··· Serial.print(67, BYTE);· //C
    ··· Serial.print($01, BYTE);· //channel 01
    ··· Serial.print($00, BYTE);· //rampspeed 0
    ··· Serial.print($00, BYTE);· //LSB for the pw 0
    ··· Serial.print($03, BYTE);· //MSB for the pw 3

    Regards,

    Bruce Bates
  • pbohmpbohm Posts: 2
    edited 2007-11-28 13:59
    @Mike: it runs on true logic, but would have been a nice solution

    @Bruce: for a moment I thought you had the right idea, but somehow (unless I remember wrong) this code only managed to set a "default" position for all channels to about mid. and this won't change no matter what ever I change in the code.

    oh btw, quick responses guys, thanx
    Any more ideas?
  • Shawn LoweShawn Lowe Posts: 635
    edited 2007-11-28 14:19
    So, have you tried commanding a second position to see if the servo moves?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Shawn Lowe


    Maybe I should have waited to do that......
  • JonnyMacJonnyMac Posts: 9,216
    edited 2007-11-28 14:25
    You should be able to make it work -- I've connected the Arduino to an RC-4 which is uses the same AppMod-style protocol as the PSC. Here's the RC-4 code, perhaps you can glean something from it:

    /*
     * RC-4 Demo
     * Jon Williams, EFX-TEK
     * jwilliams@efx-tek.com
     *
     * Interface for EFX-TEK RC-4 SSR Output Board
     * -- http://www.efx-tek.com/topics/rc-4.html
     */
    
    void setup()
    {
      Serial.begin(38400);                          // install RC-4 B/R jumper
    
      for (int idx = 0; idx < 4; idx++) {
        setRC4(idx, 0);
      }
    }
    
    void loop()
    {
      int idx, zigzag;
    
      for (idx = 0; idx <= 15; idx++) {             // counter demo
        setRC4(0, idx);
        delay(100);
      }
      setRC4(0, 0);
    
      for (zigzag = 1; zigzag < 6; zigzag++) {      // zig
        for (idx = 1; idx <= 8; idx *= 2) {
          setRC4(1, idx);
          delay(50);
        }
        for (idx = 8; idx >= 1; idx /= 2) {         // zag
          setRC4(1, idx);
          delay(50);
        }
      }
      setRC4(1, 0);
    }
    
    void setRC4(int addr, int relays)
    {
      Serial.print("!RC4");
      Serial.print(addr, BYTE);
      Serial.print("S");
      Serial.print(relays, BYTE);
    }
    
Sign In or Register to comment.