Let's Make Robots!

Controlling servos using processing and standard firmata

I am working on a biped robot that I am running using Processing and servo firmata on an arduino uno.  This works fine and I have a decent walking gait.  I would like to include an accelerometer into the robot to give the robot more stability.  So I decided to switch over to standard firmata on the arduino so I can use the i/o.  The problem is that with the standard firmata none of the servos work eventhough the servo library is still included in the standard firmata.  

I did not change the processing code between the servo firmata and standard firmata trials. I'm stumped on what to try next.  Has anyone used the standard firmata to control servos through processing?  Has anyone had this same problem?  Any ideas are welcome.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Thanks for the post.  Sorry about the lack of information.  I thought I had searched google a lot but I guess I had missed that one. That link actually answered my initial problem. When using Processing and standard firmata the initialization for the servos has to be

arduino.pinMode(servopin, 5);

instead of

arduino.pinMode(servopin, 4);

Anyways that got the servos to move with the standard firmata.  Now I have noticed another problem.  When using standard firmata, a servo control program on Processing moves the servo from 0 to 90 degrees.  I loaded the servo firmata onto the arduino uno and ran that same program and the servo moved from 0 to 180 degrees.  Here is the code for that simple program.

 

import processing.serial.*;

import cc.arduino.*;

Arduino arduino;

int pos=0; //servo position in degrees (0..180)

 

void setup()

{

  size(360, 200);

 

  arduino = new Arduino(this, Arduino.list()[4], 57600); //your offset may vary

  arduino.pinMode(9,5);

}

 

void draw()

{

// read mouseX coordinate

  int newPos = constrain(mouseX/2,0,180); // update bg & servo position if mouseX changed

 

  if(newPos != pos)

  {

    background(newPos);

    arduino.analogWrite(9, newPos);

    println (" newPos = " + newPos );

    pos=newPos; //update servo position storage variable

  }

}  

I added +90 to the output of the servo.  This made the sweep reach from about 0 to 180, but the motor gave up its torque at each end probably because the input value went over what the servo will accept as a value?  (I'm speculating)  This trick didn't fix the problem because I added it to the biped control and the motion was not  similar to that of the servo firmata tests.

 

bdk6's picture

You haven't posted any code or any details. "Help!  It doesn't work!"  doesn't help anyone know what the problem is.  I didn't know what firmata was, but 3 minutes on Google got me this link:

http://arduino.cc/forum/index.php/topic,22574.0.html

and quite a few others that look like they might have your answer.