CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

sowing down the PWM frequency

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
William
Guest







sowing down the PWM frequency
PostPosted: Thu Mar 20, 2003 11:11 am     Reply with quote

I am an undergraduate student working with the CCS compiler. We are tring to use the PWM to control and R/C servo motor. The problem is that the frequency is too high. The PIC we have chosen is the PIC16C774 becasue we need the 12 bit ADC, for an analog gyro.

We are thinking about using a 4.9512 MHz crystal, but the PWM will still operate at 300 Hz. We have also tried to "trick" the software by disabling timer2 and delaying 20 ms. Then turning it back on. I am not sure how this will work. We are using the ICE and PICMASTER for testing. When using the emulator we have to use the PIC16C73.

I have also thought about using timer interrupts, to get a 20 ms interval.

Any comments would greatly help
___________________________
This message was ported from CCS's old forum
Original Post ID: 12881
William
Guest







Re: sowing down the PWM frequency
PostPosted: Thu Mar 20, 2003 11:12 am     Reply with quote

Sorry about that I meant to say slowing down the PWM frequency.

:=I am an undergraduate student working with the CCS compiler. We are tring to use the PWM to control and R/C servo motor. The problem is that the frequency is too high. The PIC we have chosen is the PIC16C774 becasue we need the 12 bit ADC, for an analog gyro.
:=
:=We are thinking about using a 4.9512 MHz crystal, but the PWM will still operate at 300 Hz. We have also tried to "trick" the software by disabling timer2 and delaying 20 ms. Then turning it back on. I am not sure how this will work. We are using the ICE and PICMASTER for testing. When using the emulator we have to use the PIC16C73.
:=
:=I have also thought about using timer interrupts, to get a 20 ms interval.
:=
:=Any comments would greatly help
___________________________
This message was ported from CCS's old forum
Original Post ID: 12882
R.J.Hamlett
Guest







Re: sowing down the PWM frequency
PostPosted: Thu Mar 20, 2003 11:47 am     Reply with quote

:=I am an undergraduate student working with the CCS compiler. We are tring to use the PWM to control and R/C servo motor. The problem is that the frequency is too high. The PIC we have chosen is the PIC16C774 becasue we need the 12 bit ADC, for an analog gyro.
:=
:=We are thinking about using a 4.9512 MHz crystal, but the PWM will still operate at 300 Hz. We have also tried to "trick" the software by disabling timer2 and delaying 20 ms. Then turning it back on. I am not sure how this will work. We are using the ICE and PICMASTER for testing. When using the emulator we have to use the PIC16C73.
:=
:=I have also thought about using timer interrupts, to get a 20 ms interval.
:=
:=Any comments would greatly help
Generally on servos, the repeat frequency, is not that critical, it is the pulse width that has high importance. Even if you could set the PWM, to a low rate like 50Hz, the accuracy you would then get on the width adjustments would be poor. The normal solution, is to use the compare mode instead. You have another interval event (either a software timer, or using a hardware counter), and reset the registers, and set the output pulse (RC2) high, and then use the compare mode to turn the bit off after the required interval. Fortunately, in this mode, TIMER1 is used as the source for the comparison, and if you run this on the 1:1 prescaler, it will overflow every 0.052 seconds, and you can generate pulse widths with resolutions to the uSec level on the output pulse. If at the interrupt from the timer1 overflow, you set the timer1 counter to (say) about 40800, then the next interrupt will be close to 20mSec latter, allowing the same counter to be used for both requirements. If you clear the output bit, and set the compare value to about 42037, and have the compare programmed to drop the output, this will give a 1mSec pulse. Conversely a value of 43275 will give a 2mSec pulse, and you can adjust the value to give the required pulse width.

Best Wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 12884
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group