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!
 
mrbogeyman said:
i wanted to do it this way so that i didnt tie up the PIC.

You could use interrupts to do it? - or use a slave PIC (8 pin one would be enough) that takes a serial input and generates servo pulses.
 

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.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…