Software > Software

Controlling 18 or more servos using AVR 8-bit in software

(1/2) > >>

madmax_707:
Hi all,
I am trying to make a hexapod with 18 servos(3 servos Per leg. So 3*6 legs). Would like to have an additional 2 just for sake of it, if I decide to add some sensor or even a camera. I have read some implementations and have only come across code snippets which control 8 servos using timer interrupts. I have also read (just very little.. and did not understand) on the Webbot lib. I would like to learn the process of creating one myself in software rather than use a ready made one. I have also come across a SSC32 board made by lynxmotion which uses atmega8 and shift registers to control 32 channel. But I think that getting 20 servos should not be difficult and can be done. For some reason I cant get my head around it and since I am a beginner in this field I would request you all to help me in any way possible.
Thanking you all in advance 

Gertlex:
I've generally seen robots with lots of hobby servos (e.g. hexapods) use the SSC32 or similar products.  These boards have the advantage of taking care of supplying power to the servos (You wouldn't want to run 18 servos directly from an Axon, for example), and maintaining the PWM pulsing without taking up processing cycles on your MCU.

I've not done more than 3 hobby servos with WebbotLib (because I moved to AX-12 digital servos), so I can't share any experience on that end, other than everything I've done with WebbotLib being awesome...

madmax_707:
Thanks for your reply Gertlex. I agree using the board like the ssc32 would be easier, but i have seen a particular hexapod video on youtube which was using webbot lib to drive all the servos and that is how I got to know about the the webbot lib. I would actually like to know how we can achieve this in software using e.g Atmega32.  may be some code snippets? I know if i download the webbot lib and get it setup successfully may be i will get ta robot working in a  couple of days but, i really want to understand how.  I have used the pwm modes for the timers in an Avr  however, if someone could explain me how we can achieve this (perhaps the creator the Webbot lib) then that would be awesome. I have also read the entire tutorial written by Webbot which was awesome by the way. However, the last sections which is about achieving pwm in software simply says use my library :(. Hence my reason for posting this question on the forum.
Thanks again !

Gertlex:
You should link to the vid you're referring to. Some of us might recognize it.

newInRobotics:

--- Quote from: madmax_707 on September 19, 2012, 06:28:32 AM ---[...] pwm in software [...]
--- End quote ---
PWM using timer works in the following way (simplified explanation):

* Set top value to say 100.
* Set compare value to 50
* Start timer (timer starts with current value equal to 0
* With every clock cycle current value gets incremented by 1
* When current value is equal to compare value, designated PWM pin is set to HIGH
* When current value is equal to top value, designated PWM pin is set to LOW
* Timer resets to 0, everything start all overBy changing compare value You set duty cycle (how long PWM pin stays HIGH).
By changing top value You set frequency (how many times per minute PWM cycle repeats).

All what's above can be done in software, only instead of timer counting from 0 to top value, You simply count that in Your main loop, use if() statements to check if current value is equal to compare value or top value and flick any IO pin if before mentioned conditions are met.

Problem with software PWM is that the more You have in Your main loop, the bigger error You get in Your PWM signal. This can be avoided if You're willing to program in ASM, take into consideration how many commands Your main loop has, how long they take to execute and manually compensate for cycles lost executing them. Also, there are interrupts that interrupt main loop, hence they also interrupt Your software PWM causing error in timing.

Hope that helps  :)

Navigation

[0] Message Index

[#] Next page

Go to full version