Society of Robots - Robot Forum

Software => Software => Topic started by: violinkid on July 17, 2009, 12:06:25 AM

Title: $50 robot, Servo modification
Post by: violinkid on July 17, 2009, 12:06:25 AM
Hi, I'm new to this forum. I was reading the tutorial on how to modify servos for $50 robots and was confused on the part where i have to put in some code to hold it at 0. Do I have to finish making the cpu of the robot before I can modify the servos? I didn't really understand the directions in the tutorial. Thanks   ???
Title: Re: $50 robot, Servo modification
Post by: SmAsH on July 17, 2009, 12:10:49 AM
yes, you must complete the board to modify the servos.
the board is what controls them, and makes them go to the right spot.
Title: Re: $50 robot, Servo modification
Post by: psic on August 22, 2009, 06:32:35 PM
Hello, I hope you don't mind me adding my question here, since it's a bit of a follow-up...

I'm also following the 50-dollar robot tutorial, I've already completed the board, which works fine (the code for centering the servos worked perfectly). I also modified the servos, and now I'd like to test them out with a PWM signal.

The problem is, I'm not sure how exactly to do that. I've been reading up on PWM but I'm not sure how exactly to use pins PD0 and/or PD1 as output for the PWM (since my 2 servos are hooked up to these 2 pins), as all of the tutorials I've come across use port B and the timer that it is associated with (if I understand correctly).

I realise this is somewhere in the final code for the 50 dollar robot, but I can't find it (still too new to all this).

Any help would be appreciated :)
Title: Re: $50 robot, Servo modification
Post by: SmAsH on August 22, 2009, 06:38:54 PM
im not an expert in programming but those pins are not pwm pins so i do not know if this is possible...
pins 5, 11, 12, 15 and 16 are all pwm pins so you can try hooking the servos up to them...
do you need any help with the code for pwm?
Title: Re: $50 robot, Servo modification
Post by: psic on August 22, 2009, 06:53:23 PM
Well, it has me a bit confused as well, since these are the pins which are used to control the servos in the 50 dollar tutorial here: http://www.societyofrobots.com/step_by_step_robot_step3C.shtml (http://www.societyofrobots.com/step_by_step_robot_step3C.shtml). Quote: "And if you haven't figured it out yet already, plug your servos into PD0 and PD1 (pin 2 and pin 3)."

I know I could try using PortB, but I've already got the entire board soldered.

As for the code for PWM, I was planning on trying out the code here: http://www.societyofrobots.com/member_tutorials/node/234 (http://www.societyofrobots.com/member_tutorials/node/234) (if I understand correctly, I'd add
Code: [Select]
  DDRB |= (1<<5); to set pin PB5 as output?)