Using ssc-32 and Arduino together

Well just to make sure again:

I read this:
The Arduino Duemilanove has a number of facilities for communicating with a computer, another Arduino, or other microcontrollers. The ATmega168 provides UART TTL (5V) serial communication, which is available on digital pins 0 (RX) and 1 (TX)…

here:
arduino.cc/en/Main/ArduinoBoardDuemilanove

so that, I can connect the RX/TX from Arduino to TX/RX on SSC-32 right? :slight_smile:

ah sure. hmmm… that’s kind of an odd way to connect stuff (in the schematic of the arduino) as its sort of sharing the TTL serial lines between the USB adapter (FTDI FT232RL, FTW) and ports 0, 1. I see there is a 1K resistor between the connections but just keep in mind if you send something to the Arduino with the SSC-32 attached (and powered) then it is going to see the characters as well, and if the SSC-32 isn’t powered it might drag down those lines such that the PC can’t talk to the Arduino boot loader or whatever it’s using. Depending on how often you plan on re-programming the Arduino it might be worthwhile to put a two-pole switch in series with the TXD and RXD lines between the SSC-32 and Arduino. Something like a Radio Shack 275-407 or 275-403 would work fine.

Ok, well, first I tried and I was wrong in my programming and nothing worked! then I found this tutorial that helped to understand what you say better, so I put the link here may be helpful to others too :slight_smile:

learnhub.com/lesson/page/7448-mo … an-arduino

If here something is not right, please tell me:

void setup() {
  Serial.begin(9600);
}

void loop() {
  move(1, 2000, 100);
  move(1, 1000, 100);
}

void move(int servo, int position, int time) {
  Serial.print("#");
  Serial.print(servo);
  Serial.print(" P");
  Serial.print(position);
  Serial.print(" T");
  Serial.println(time);
  delay(time);
}

I have one more question:
Well my servo is continuous rotation. If I want it to go forward for 10 seconds, and then, say, backward for 15 seconds, how should I code it?

thank you :slight_smile:

generally speaking continuous rotation servos are normal servos where the feedback pot has been disconnected from the output shaft and replaced with a voltage divider that approximates 0 degrees position. what this means in english is sending 1500ms should be a stopped condition for the motor because the servo control board in the servo thinks the shaft is at 0 degrees. if you give the servo a slight longer or shorter pulse the servo control board will attempt to position the motor at the new angle, however becaue the voltage that represents that angle is a hard-wired constant the motor will just continue to turn. usually the range of 0rpm to full speed is fairly small in terms of change from 1500ms… I think I recall it being as low as +/- 100.

for your example, granted here I don’t know which adjustment direction is CW vs CCW, just pick CW to be +100 and CCW to be -100. Thus you would send 1400, delay for the 10 seconds, then send 1600, delay for 15 seconds, then send 1500 to stop moving.

The Hitec servo motors have a positive pule to direction relationship. ~1500 will stop the motor, shorter pulses will rotate CCW, longer pulses will rotate CW.

Lets assume “forward” is CW rotation, you would send this.

#0 P1500 cr #0 P2000 T10000 cr (pause for 10 seconds) #0 P1000 T15000 cr (pause for 15 seconds)

Actually Jim that code will accelerate for 10 seconds, then decelerate for 15 seconds. It will take well over a second for it to get moving at top speed, then it will take well over a second to decelerate back to 0 and another again well over a second to accelerate back up to full speed in the opposite direction. Maybe it was your intention to introduce ramp up / ramp down in your example by way of adding the T parameter to the string. It is an important difference though from what I posted which will just bang from stop to full CW to full CCW to stop. :wink:

Doh! That’s what I get for posting before I’m fully awake. lol

You’re right. :blush: Sorry for the confusion.

#0 P1500 cr (motor stopped waiting for command to move forward) #0 P2000 cr (pause for 10 seconds) #0 P1000 cr (pause for 15 seconds)

Hey Eddie, you’re starting a lot of posts with “actually Jim” lately :slight_smile: I need to pay better attention. lol

Sorry. No disrespect intended. :frowning:

Ah, none taken! I have just been burning the candle at both ends lately. lol

I really appreciate the help! :smiley:

well would you please explain for non-English people, what is:

…burning the candle at both ends lately
please? )

Um, well it’s an idiom for working long hours with little rest. Not sure of the origin.

it makes more sense in the non-abridged version of “burning the candle at both ends of the day”, which in the old days meant it was before dawn when you got up to go to work and after twilight by the time you got home. Of course this time of year the people living way north kind of experience that effect implicitly anyway. :wink:

Um, Eddie you forgot “actually Jim” lol :smiley:

That makes a lot more sense now, thanks. :wink:

“Actually jim”, LOL,
I tried to implement the code you recomended:

#0 P1500 cr
#0 P2000 T10000 cr
(pause for 10 seconds)
#0 P1000 T15000 cr
(pause for 15 seconds)

in this way with Arduino:

void setup() 
{ 
  Serial.begin(9600); 
} 

void loop() 
{ 
    Serial.println("#0 P1500"); 
    Serial.println("#0 P2000 T10000"); 
    delay(10000);
    Serial.println("#0 P1000 T15000");     
    delay(15000); 
}

But it does not work as I expect! the speed of motors in different turning in the loop are different, but my power source is not a battery to say that it falls down.

Well, all of my effort to lean ssc 32 is for my aim is to study Kalman filtering, where my KF code is ready, but I can’t command motors with ssc 32 so that the robot passes a square of 50cm, again and again.

considering the Arduino structure as I provided above, how do you code it? may be you know how to do it right?
Thank you!!!

Not you too! Doh!

Actually arash, that was my first incorrect code. This is the corrected code.

#0 P1500 cr
#0 P2000 cr
(pause for 10 seconds)
#0 P1000 cr
(pause for 15 seconds)

Well, I found out where I was wrong: for ssc 32 and arduino to work right, we have to set a common ground between them, what I did not set first!
no everything seems logical.

only, I still don’t know how I can command the ssc32, to stop a motor, say, in 0 position, can you code the command? )

Isn’t the “#0 P1500 cr”

command intented to say stop. More or less? You may have to fudge it a little to one side or the other if it is not exact. I don’t know what you mean by in the 0 position. If by this you want the motor to stop at a specific location, I don’t believe the servos have this capability.

If you want to turn the pulses off that are going to the servo, I believe you could issue the command “#0L”. I am not sure if this would stop your servo or not.

Now that you have some of the basics working, you should look through the SSC-32 and experiment. For example instead of going from full speed forward to full speed reverse, maybe you want to ramp up and down to the speed. You can do that with the Time parameter that Robot Dude had in his earlier code. Although Actually you may not want that slow of a ramp… You could also do it in your own code and output several descrete commands with different pulse values.

Good Luck.

Kurt

Well, when I issue “#0 P1500 cr”, the motor connected on the 0 position of the SSC 32 does not stop, and continue to turn very slow. I would like to stop the motor completely and don’t know the command. who knows? )