Arduino and Parallax Servo Controller
Hey all,
I'm trying to get my arduino board to communicate with the parallax servo controller, I've read an older topic concerning the same issue, yet it seemed unsolved in the forum. The servo controller accepts a header ("!SC"), followed by a binary number for the servo channel, a binary number for the ramping speed, a 16-bit word for the servo position (250-1250), and a CR as a terminator.
This is the code I'm using for my arduino:
I'm trying to get my arduino board to communicate with the parallax servo controller, I've read an older topic concerning the same issue, yet it seemed unsolved in the forum. The servo controller accepts a header ("!SC"), followed by a binary number for the servo channel, a binary number for the ramping speed, a 16-bit word for the servo position (250-1250), and a CR as a terminator.
This is the code I'm using for my arduino:
// include the SoftwareSerial library so you can use its functions: #include <SoftwareSerial.h> #define rxPin 6 #define txPin 7 byte chan = 1 + '0'; byte ramp = 7 + '0'; int pw = 1250; byte lsb = pw & 0xFF; byte msb = pw >> 8; // set up a new serial port SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin); void setup() { // define pin modes for tx, rx: pinMode(rxPin, INPUT); pinMode(txPin, OUTPUT); // set the data rate for the SoftwareSerial port mySerial.begin(2400); // debug led digitalWrite(13, HIGH); mySerial.print("!SC"); mySerial.print(chan); mySerial.print(ramp); mySerial.print(lsb, BYTE); mySerial.print(msb, BYTE); mySerial.print(13, BYTE); } void loop() { // ... }
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
When I send it to the serial monitor it outputs !SC1003, which is correct. When I send it to the PSC, the (rx) led on the board lights up for a moment, that's the feedback I'm getting, is there any other way to debug it, a way that gives you more insight?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
I've declared the vars as follows:
Post Edited (nition) : 1/24/2008 12:08:50 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support