Need help in controlling more than 4 servos in atmega 16

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi i want to control 15 servos in a robotics project using atmega 16. But here only 4 pins can be used as pwm pins. i.e, i can only control 4 servos as each servo requires a pwm pin. I have heard that other i/o pins of mega 16 can be configured as pwm pins using timer. i want to know that is it possible to generate pwm in other i/o pins in mega 16?

If possible please give me a sample code so that i can understand. I have knowledge on how to configure timer in CTC and PWM mode.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

i want to know that is it possible to generate pwm in other i/o pins in mega 16?

Yes.
Quote:

If possible please give me a sample code so that i can understand.

How far have you searched? There have been many many threads here about driving multiple servos. Say you want to drive 10 of them the trick is not to try and output all ten 1ms..2ms activity pulses at the same time but stagger them. So start servo 1's high output at time 0 then take it low some time between 1ms and 2ms (and keep low until 20ms). Take servo 2's output high at 1ms then low at 2ms..3ms (and keep low for a total of 20ms). Take servo 3's output high at 2ms and low at 3ms..4ms (and keep low for a total of 20ms) and so on. This saves you having to worry about ten lots of 1ms..2ms activity all at the same time.

As I say, many prior threads to be found about this.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Servos are slow; hardware PWM is not required. So various forms of software or hardware/software hybrid PWM work just as well. As clawson says, lots of examples available on the fora, just search... maybe even take a look in the projects section?

Martin Jay McKee

As with most things in engineering, the answer is an unabashed, "It depends."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I searched a lot but couldn't find any good tutorial or thread. Please give me some links so that i can get sample codes easily.
Thank you

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Suggest you expend a little more time learning to search.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I typed avr rc servo c source into google and it says there are 851000 articles to read. Start reading.

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

the keywords to search for are 'soft pwm' and 'bitbang pwm' etc..

AN AVR136 : Low-Jitter Multi Channel Software PWM
http://www.atmel.com/Images/doc8...

"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it"

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Does this help: http://www.flickr.com/photos/588...@N00/3927527999/in/set-72157601072004330/ ?
You can use a single timer (or two) to time the width of the pulses on each of the multiple output lines.