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.

16F88 PWM and A/D conversion

Status
Not open for further replies.
mrbogeyman said:
I am currently trying to use PWM to control a servo motor that requires approximately a 0.5-2ms pulse every 20ms. This would also require a resolution of at least 0.01ms.

Sorry, but the PWM is designed for power control (motor speed etc.), it's not really suitable for servo control - it's usually just done in software, as it's not a very critical item to do.
 
i wanted to do it this way so that i didnt tie up the PIC.

its a bit of a spanner in the works to be honest. its an honours project you see, so time is critical. doh!
 
Nigel Goodwin said:
mrbogeyman said:
I am currently trying to use PWM to control a servo motor that requires approximately a 0.5-2ms pulse every 20ms. This would also require a resolution of at least 0.01ms.

Sorry, but the PWM is designed for power control (motor speed etc.), it's not really suitable for servo control - it's usually just done in software, as it's not a very critical item to do.

I hate to disagree with you again Nigel but I think the PWM module is a perfect candidate anytime you need a pulse or signal with very low resolution, in this case 10-usecs...

In this application you won't get a 20.0-msec period directly from the PWM module but it would be relatively easy to produce a 1.0-msec PWM period with 1.0-usec resolution (use prescaler 4:1 and PR2 d'250') and use an Interrupt Service Routine that programs CCPR1L with a 500-usec (50%) to 2000-usec (200%) duty cycle spread between two 1.0-msec PWM periods and a 0.0-usec (00%) duty cycle for another eighteen 1.0-msec PWM periods... This would produce a "look no hands" 20-msec Interrupt driven Servo output on the CCP1 pin and Main would simply need to update one variable with a value of 500, 510, 520, up to 2000, to change the pulse width output...

Regards, Mike
 
hey mike !!
long time no talk !!
last time , i think you were working on tri color LEDs , how did that work out..??
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top