NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Support Forum » Setting up dual servos in the ServoSquirter project
August 02, 2009 by Kelp |
Ok, I've been working at it for hours now and I can't seem to set up the code to work with two servos. I'm not even really sure which pin the second one needs to be connected to. I've tried deciphering the datasheet, but I'm pretty sure that did more harm than good. Any help or guidance at all would be greatly appreciated. Thanks, C&D |
---|---|
August 02, 2009 by mrobbins (NerdKits Staff) |
Hi there, Let me help try to get you started. You can activate the second output of Timer/Counter #1. Right now in the Servo Squirter code, the OCR1A register is used to set the "TOP" value of the counter, but if you instead use the ICR1 register for TOP, this will free up OCR1A to be another independent PWM output. Here's what you need to do:
Now, you should be able to set OCR1A to some value, just as you set OCR1B in the pwm_set function, and this should provide PWM output on PB1. Please give that a try and see if it works! Look at pages 131-133 in the ATmega168 datasheet if you want more details. Best, Mike |
August 03, 2009 by Kelp |
Yes! Thank you! I knew I had to open up a new PWM output, but I couldn't figure out how. Once I stored the TOP value in ICR1, the rest of the code worked perfectly Thanks again! |
April 01, 2011 by hariharan |
What is the relation ship between OCR1A register and frequency? that is, what would i set the register to in order to output a specific frequency? I am a ametuer in programming and electronics, so i might need some 'extra' help. THANKS IN ADVANCE! |
April 01, 2011 by mongo |
I did it for dual servos a while back and posted it in use on youtube. I'll look up the code this weekend and try to get it posted. It is designed to run from either a scripted batch file or directly from a keyboard through a terminal program. |
Please log in to post a reply.
Did you know that any circuit of voltage sources and resistors can be simplified to a "Thevenin" equivalent circuit? Learn more...
|