Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Need to Reduce Time Taken to PWM Servos from a PIC

Status
Not open for further replies.

out_of_my_depth

New Member
hi,

I'm currently using a PIC to generate pwm signals for 5 servos. i've managed to code it efficiently but i'd like to reduce the 'dead' time experienced while waiting the required 1-2ms with the output pin high.

What i'd like to be able to do is send out a much shorter pulse (say 0.1 - 0.2 ms) and have something between the pic and the servo that could lengthen the pulse 10 fold.

Any ideas :?:
 
wouldn't it be easier to do the pulses using interrupts, so you could do other things while you were waiting? adding external hardware to every pin would be a huge waste of hardware... especially considering that probably the easiest way to do it would be to use another PIC...

not to mention, you would get reduced accuracy by reducing the pulse width...
 
as the servos need to be pulsed 50 or so times a second, i'm using an interrupt to trigger the start of each pulse and then looping for between 1 and 2ms before returning from interrupt. Are you suggesting i can nest interrupts?

Using another pic is an option i've considered but space is at a premium and i was hoping to find something that resembled a transitor.
 
no, you won't find anything to multiply a delay. Especially not as small as a transistor. Instead of looping for 1-2 mS, you can set one of the hardware counters up with a starting value, and start it counting, and return to normal functions. when the counter overflows it can be set to trigger an interrupt so you can go back and set it up again for the next output. 1-2 mS is really quite a long time when it comes to a PIC, so you could easily be doing other stuff in between.

not to mention, you don't actually have to pulse a servo 50 times a second. a servo will hold its position even when no pulses are received, so you can easily get away with a reduced pulse rate... as long as the pulses themselves still remain 1-2mS.
 
thanks evandude. That's given me more food for thought. The last para sounds interesting as i suspected that the servos would become slack or unstable if the pulses weren't frequent enough. cheers.
 
Just in case is of any use for you...

Give a check on what Stewart suggested to my questions in the thread herebelow.
http://forum.microchip.com/tm.asp?m=59908&mpage=1&key=interrupt&anchor#60348

Just skip the initial posts. Look for those signed by him.

I tested the time base interrupt idea and with 8 LEDs blinking in non related time-frames, worked from the first try.

It will take some time but it is worht the effort.

I have the feeling that it will help to solve your problem.

Agustín Tomás
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top