On Fri, Sep 9, 2011 at 2:45 AM, Josh Koffman wrote: > Hi Tamas, > > I've spent a bunch of time searching but haven't found much that's > enlightening. My problem with projects like the one you linked to is > that because their only purpose is to drive the servo, they aren't > written to do much else, and they don't take advantage of the > peripherals present in the chip. I guess I'm being picky! > Hi Josh, If you need only 1 servo to drive then you have pretty much like 18ms to do something else, then 1ms from the time you put the signal high, and only from then you need to worry about the length of the signal. The only thing is that you need to be very precise with the width of the pulse otherwise the servo will shaking and make noise, consuming more power etc. If you have a timer interrupt you are better off, or with the CCP/PWM module. With a free running PWM is the only problem is that you have 1%-2% duty cycle all the time, therefore if you have a 10 bit PWM, you will then have an 1024 resolution for the entire 20ms period, therefore you will have a 10.24 (~10 steps) resolution for the entire servo movement, which is way too low. So what you would need is a PWM set up to 2-2.5 ms periods and to make sure it will fire only once at every 20ms (or just it puts output to low when en= d of duty cycle if you have that kind of functionality on the silicon). You can also do this by by software using a timer interrupt, but things are getting tricky when you need to work with more than one servo at a time. Also you have to make sure no other interrupts will occur otherwise will affect your timings (for example you are serving another interrupt while timer fires, so it will causing you an unwanted delay till timer ISR been served, which then affects the pulse width). The most easy is when you handle one servo at a time and then switch to the next servo one by one. Yo= u can handle 8-10 servos like this to fit each to the 20ms period. Most analogue radio system works like this. And once you use 18F you use high priority for the timer and low for other stuff so you will have no problem serving those. Tamas > > I am going to try just writing my own, hopefully it won't go too badly :) > > Josh > -- > A common mistake that people make when trying to design something > completely foolproof is to underestimate the ingenuity of complete > fools. > -Douglas Adams > > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > --=20 int main() { char *a,*s,*q; printf(s=3D"int main() { char *a,*s,*q; printf(s=3D%s%s%s, q=3D%s%s%s%s,s,q,q,a=3D%s%s%s%s,q,q,q,a,a,q); }", q=3D"\"",s,q,q,a=3D"\\",q,q,q,a,a,q); } --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .