Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Tools
Old 5th November 2003, 04:00 AM   #1
Default servo motor help!

I知 trying to control a R/C servo motor using a PIC16F877 and I知 trying to figure out what way is best using the built in PWM, Timer0 or writing a microsecond delay function that will allow me to pulse the output from 1ms-2ms...anyone have some tips on how I could do this, simple as possible
Thanks
show-boat is offline  
Old 5th November 2003, 04:23 AM   #2
Default

Though my project used an AVR, I chose to use a timer. The timer allowed me to control multiple servos by just scheduling (and rescheduling) timer interrupts at the appropriate intervals. The PWM would have worked for two servos in my case, but I needed more outputs.
crust is offline  
Old 7th November 2003, 04:33 AM   #3
Default

How come nobody has a good answer to my question?
does anyone else use FED C to program there PIC's?
show-boat is offline  
Old 8th November 2003, 05:05 PM   #4
Default

Quote:
Originally Posted by show-boat
How come nobody has a good answer to my question?
does anyone else use FED C to program there PIC's?
It's dead easy in Pic Basic.
MarkK is offline  
Old 10th November 2003, 02:58 PM   #5
Default

What compiler are you using?

You do realize that you are going to need a varying pulse between 1ms and 2ms to position the servo. Doing a 1.5ms pulse should positin the servo in the middle. Also this pulses have to be at least 18ms apart.

PWM is used to retain the same frequency and change the duty cycle. Your frequency would be anywhere (1/1ms+18ms) 52Hz and 50Hz. If you are using PICBASIC PRO and you want to use the HPWM command you run into the problem that the lowest frequency that you can use with a 4Mz crystal is 145Hz. THen you are wanting to vary the frequency and the dutycycle...... it's all just asking for trouble.....

What are you trying to do with the servo? Can you just do it by software

Ivancho
ivancho is offline  
Old 12th November 2003, 11:01 AM   #6
Default Re: servo motor help!

The best and efficient way to control a servo is to use a timer. If the servos you want to control is less, 1 or 2, it doesn't matter which method you use. You may use either a microsecond delay or a timer. But if the no. of servos is more, it's good not to use a microsecond delay. If you use a microsecond delay, it's a busy delay, means it executes a sequence of NOP statements for a definite no. of times. Processor will do no other job other than executing these NOPs. Instead if you use timer, you may set a pin high and then enable timer interrupt. The timer interrupt occures after the required delay and you can set the pin low to produce a pulse. The processor can do other jobs like cheching the senser status etc during the delay period.

happy_99

Quote:
Originally Posted by show-boat
I知 trying to control a R/C servo motor using a PIC16F877 and I知 trying to figure out what way is best using the built in PWM, Timer0 or writing a microsecond delay function that will allow me to pulse the output from 1ms-2ms...anyone have some tips on how I could do this, simple as possible
Thanks
happy_99 is offline  
Old 13th November 2003, 05:28 AM   #7
Default

All i want to be able to do is control 1 servo and be able to change the postion anytime i need i am currently using FED Pic C to wite my code
there is no built in microsecond delay
i want to find is the the best method to control a single servo, while it be using a timer or PWM or even writing a microsecond delay it dont matter to me just whats the easyest
Thanks
show-boat is offline  
Old 14th November 2003, 04:33 AM   #8
Default

You may use a microsecond delay. Set the timer0 int to occur every 18ms. Write these codes to the tmr0 int routine

TMR0 INT
output_high(PIN No.)
delay_us(REQ Delay)
output_low(PIN No.)

happy_99

Quote:
Originally Posted by show-boat
All i want to be able to do is control 1 servo and be able to change the postion anytime i need i am currently using FED Pic C to wite my code
there is no built in microsecond delay
i want to find is the the best method to control a single servo, while it be using a timer or PWM or even writing a microsecond delay it dont matter to me just whats the easyest
Thanks
happy_99 is offline  
Reply

Thread Tools
Display Modes




All times are GMT. The time now is 08:09 PM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker