Hey now, I have the PIC18F458 and I'm using the CCS C compiler. My question is simple. I want to output a square wave at 50Hz and vary the duty cycle between 3% and 9%. Any ideas how to accomplish this? I know I should use "SETUP_TIMER", I'm just not sure how. Thanks, Shamoon |
|
CCP PWM
Started by ●July 7, 2004
Reply by ●July 8, 20042004-07-08
Any ideas? --- In , honamos@y... wrote: > Hey now, > I have the PIC18F458 and I'm using the CCS C compiler. My question > is simple. I want to output a square wave at 50Hz and vary the duty > cycle between 3% and 9%. Any ideas how to accomplish this? I know > I should use "SETUP_TIMER", I'm just not sure how. > > Thanks, > Shamoon |
|
Reply by ●July 8, 20042004-07-08
You want a pulse every 20ms and control the pulse width from 600us to 1800us. Is this correct? pr --- In , honamos@y... wrote: > Any ideas? > > --- In , honamos@y... wrote: > > Hey now, > > I have the PIC18F458 and I'm using the CCS C compiler. My > question > > is simple. I want to output a square wave at 50Hz and vary the > duty > > cycle between 3% and 9%. Any ideas how to accomplish this? I > know > > I should use "SETUP_TIMER", I'm just not sure how. > > > > Thanks, > > Shamoon |
|
Reply by ●July 8, 20042004-07-08
That's about right, yeah... Ideas? Shamoon --- In , "Patrick Reitelbach" <preitelbach@y...> wrote: > You want a pulse every 20ms and control the pulse width from 600us to > 1800us. Is this correct? > > pr > --- In , honamos@y... wrote: > > Any ideas? > > > > --- In , honamos@y... wrote: > > > Hey now, > > > I have the PIC18F458 and I'm using the CCS C compiler. My > > question > > > is simple. I want to output a square wave at 50Hz and vary the > > duty > > > cycle between 3% and 9%. Any ideas how to accomplish this? I > > know > > > I should use "SETUP_TIMER", I'm just not sure how. > > > > > > Thanks, > > > Shamoon |
|
Reply by ●July 8, 20042004-07-08
Is this the only thing the pic will be doing? What is the clock speed you want to use? pr --- In , honamos@y... wrote: > That's about right, yeah... Ideas? > > Shamoon > > --- In , "Patrick Reitelbach" > <preitelbach@y...> wrote: > > You want a pulse every 20ms and control the pulse width from 600us > to > > 1800us. Is this correct? > > > > pr > > --- In , honamos@y... wrote: > > > Any ideas? > > > > > > --- In , honamos@y... wrote: > > > > Hey now, > > > > I have the PIC18F458 and I'm using the CCS C compiler. My > > > question > > > > is simple. I want to output a square wave at 50Hz and vary > the > > > duty > > > > cycle between 3% and 9%. Any ideas how to accomplish this? I > > > know > > > > I should use "SETUP_TIMER", I'm just not sure how. > > > > > > > > Thanks, > > > > Shamoon |
|
Reply by ●July 8, 20042004-07-08
Nope, this is just one of the various things. The clock speed I have is 8Mhz. --- In , "Patrick Reitelbach" <preitelbach@y...> wrote: > Is this the only thing the pic will be doing? What is the clock > speed you want to use? > pr > > --- In , honamos@y... wrote: > > That's about right, yeah... Ideas? > > > > Shamoon > > > > --- In , "Patrick Reitelbach" > > <preitelbach@y...> wrote: > > > You want a pulse every 20ms and control the pulse width from > 600us > > to > > > 1800us. Is this correct? > > > > > > pr > > > --- In , honamos@y... wrote: > > > > Any ideas? > > > > > > > > --- In , honamos@y... wrote: > > > > > Hey now, > > > > > I have the PIC18F458 and I'm using the CCS C compiler. My > > > > question > > > > > is simple. I want to output a square wave at 50Hz and vary > > the > > > > duty > > > > > cycle between 3% and 9%. Any ideas how to accomplish this? > I > > > > know > > > > > I should use "SETUP_TIMER", I'm just not sure how. > > > > > > > > > > Thanks, > > > > > Shamoon |
|
Reply by ●July 8, 20042004-07-08
I do not think you will be able to get the numbers you want with a standard timer setup. The PWM cannot get that slow with a 8Mhz clock. I made a 60Hz source with a 16F628 using its internal 37Khz clock. Maybe you could setup a timer/interrupt for your required control step value (how fine of control do you want?) and count the interrupts in an isr to control your output(s). Like 100us resolution gives 12 steps between 600 and 1800us. Set a timer to overflow every 100us and do the counting. Is this by chance to be used for RC servo control? I have an assembly program for the 628 which controls 2 servos at 4Mhz clock. With 8 Mhz you could control 4. I process all servo outputs in parallel vs serially (one at a time). The serial methods I looked at were cpu time hogs. This means for 2 ms about 90% of cpu cycles are used for servo control. Other tasks have the cpu 100% for the remaining 18 ms. pr --- In , honamos@y... wrote: > Nope, this is just one of the various things. The clock speed I > have is 8Mhz. > > --- In , "Patrick Reitelbach" > <preitelbach@y...> wrote: > > Is this the only thing the pic will be doing? What is the clock > > speed you want to use? > > pr > > > > --- In , honamos@y... wrote: > > > That's about right, yeah... Ideas? > > > > > > Shamoon > > > > > > --- In , "Patrick Reitelbach" > > > <preitelbach@y...> wrote: > > > > You want a pulse every 20ms and control the pulse width from > > 600us > > > to > > > > 1800us. Is this correct? > > > > > > > > pr > > > > --- In , honamos@y... wrote: > > > > > Any ideas? > > > > > > > > > > --- In , honamos@y... wrote: > > > > > > Hey now, > > > > > > I have the PIC18F458 and I'm using the CCS C compiler. My > > > > > question > > > > > > is simple. I want to output a square wave at 50Hz and > vary > > > the > > > > > duty > > > > > > cycle between 3% and 9%. Any ideas how to accomplish > this? > > I > > > > > know > > > > > > I should use "SETUP_TIMER", I'm just not sure how. > > > > > > > > > > > > Thanks, > > > > > > Shamoon |
|
Reply by ●July 8, 20042004-07-08
This is indeed for RC Servo Control. Do you think you could pass along that code? Thanks, Shamoon --- In , "Patrick Reitelbach" <preitelbach@y...> wrote: > I do not think you will be able to get the numbers you want with a > standard timer setup. The PWM cannot get that slow with a 8Mhz > clock. I made a 60Hz source with a 16F628 using its internal 37Khz > clock. > > Maybe you could setup a timer/interrupt for your required control > step value (how fine of control do you want?) and count the > interrupts in an isr to control your output(s). Like 100us > resolution gives 12 steps between 600 and 1800us. Set a timer to > overflow every 100us and do the counting. > > Is this by chance to be used for RC servo control? > > I have an assembly program for the 628 which controls 2 servos at > 4Mhz clock. With 8 Mhz you could control 4. I process all servo > outputs in parallel vs serially (one at a time). The serial methods > I looked at were cpu time hogs. This means for 2 ms about 90% of cpu > cycles are used for servo control. Other tasks have the cpu 100% for > the remaining 18 ms. > > pr > --- In , honamos@y... wrote: > > Nope, this is just one of the various things. The clock speed I > > have is 8Mhz. > > > > --- In , "Patrick Reitelbach" > > <preitelbach@y...> wrote: > > > Is this the only thing the pic will be doing? What is the clock > > > speed you want to use? > > > pr > > > > > > --- In , honamos@y... wrote: > > > > That's about right, yeah... Ideas? > > > > > > > > Shamoon > > > > > > > > --- In , "Patrick Reitelbach" > > > > <preitelbach@y...> wrote: > > > > > You want a pulse every 20ms and control the pulse width from > > > 600us > > > > to > > > > > 1800us. Is this correct? > > > > > > > > > > pr > > > > > --- In , honamos@y... wrote: > > > > > > Any ideas? > > > > > > > > > > > > --- In , honamos@y... wrote: > > > > > > > Hey now, > > > > > > > I have the PIC18F458 and I'm using the CCS C compiler. > My > > > > > > question > > > > > > > is simple. I want to output a square wave at 50Hz and > > vary > > > > the > > > > > > duty > > > > > > > cycle between 3% and 9%. Any ideas how to accomplish > > this? > > > I > > > > > > know > > > > > > > I should use "SETUP_TIMER", I'm just not sure how. > > > > > > > > > > > > > > Thanks, > > > > > > > Shamoon |
|
Reply by ●July 8, 20042004-07-08
I think there was a discussion within the last month or so over on the MiniSumo Mark III group about using one of the times to generate servo timing. Looked like it would work very well. --- In , honamos@y... wrote: > This is indeed for RC Servo Control. Do you think you could pass > along that code? > > Thanks, > Shamoon > > --- In , "Patrick Reitelbach" > <preitelbach@y...> wrote: > > I do not think you will be able to get the numbers you want with a > > standard timer setup. The PWM cannot get that slow with a 8Mhz > > clock. I made a 60Hz source with a 16F628 using its internal > 37Khz > > clock. > > > > Maybe you could setup a timer/interrupt for your required control > > step value (how fine of control do you want?) and count the > > interrupts in an isr to control your output(s). Like 100us > > resolution gives 12 steps between 600 and 1800us. Set a timer to > > overflow every 100us and do the counting. > > > > Is this by chance to be used for RC servo control? > > > > I have an assembly program for the 628 which controls 2 servos at > > 4Mhz clock. With 8 Mhz you could control 4. I process all servo > > outputs in parallel vs serially (one at a time). The serial > methods > > I looked at were cpu time hogs. This means for 2 ms about 90% of > cpu > > cycles are used for servo control. Other tasks have the cpu 100% > for > > the remaining 18 ms. > > > > pr > > --- In , honamos@y... wrote: > > > Nope, this is just one of the various things. The clock speed I > > > have is 8Mhz. > > > > > > --- In , "Patrick Reitelbach" > > > <preitelbach@y...> wrote: > > > > Is this the only thing the pic will be doing? What is the > clock > > > > speed you want to use? > > > > pr > > > > > > > > --- In , honamos@y... wrote: > > > > > That's about right, yeah... Ideas? > > > > > > > > > > Shamoon > > > > > > > > > > --- In , "Patrick Reitelbach" > > > > > <preitelbach@y...> wrote: > > > > > > You want a pulse every 20ms and control the pulse width > from > > > > 600us > > > > > to > > > > > > 1800us. Is this correct? > > > > > > > > > > > > pr > > > > > > --- In , honamos@y... wrote: > > > > > > > Any ideas? > > > > > > > > > > > > > > --- In , honamos@y... wrote: > > > > > > > > Hey now, > > > > > > > > I have the PIC18F458 and I'm using the CCS C > compiler. > > My > > > > > > > question > > > > > > > > is simple. I want to output a square wave at 50Hz and > > > vary > > > > > the > > > > > > > duty > > > > > > > > cycle between 3% and 9%. Any ideas how to accomplish > > > this? > > > > I > > > > > > > know > > > > > > > > I should use "SETUP_TIMER", I'm just not sure how. > > > > > > > > > > > > > > > > Thanks, > > > > > > > > Shamoon |
Reply by ●July 9, 20042004-07-09
It can be found at www.polydevelopment.com/pd_code/servo. my_servo_2_channel.asm. pr --- In , honamos@y... wrote: > This is indeed for RC Servo Control. Do you think you could pass > along that code? > > Thanks, > Shamoon > > --- In , "Patrick Reitelbach" > <preitelbach@y...> wrote: > > I do not think you will be able to get the numbers you want with a > > standard timer setup. The PWM cannot get that slow with a 8Mhz > > clock. I made a 60Hz source with a 16F628 using its internal > 37Khz > > clock. > > > > Maybe you could setup a timer/interrupt for your required control > > step value (how fine of control do you want?) and count the > > interrupts in an isr to control your output(s). Like 100us > > resolution gives 12 steps between 600 and 1800us. Set a timer to > > overflow every 100us and do the counting. > > > > Is this by chance to be used for RC servo control? > > > > I have an assembly program for the 628 which controls 2 servos at > > 4Mhz clock. With 8 Mhz you could control 4. I process all servo > > outputs in parallel vs serially (one at a time). The serial > methods > > I looked at were cpu time hogs. This means for 2 ms about 90% of > cpu > > cycles are used for servo control. Other tasks have the cpu 100% > for > > the remaining 18 ms. > > > > pr > > --- In , honamos@y... wrote: > > > Nope, this is just one of the various things. The clock speed I > > > have is 8Mhz. > > > > > > --- In , "Patrick Reitelbach" > > > <preitelbach@y...> wrote: > > > > Is this the only thing the pic will be doing? What is the > clock > > > > speed you want to use? > > > > pr > > > > > > > > --- In , honamos@y... wrote: > > > > > That's about right, yeah... Ideas? > > > > > > > > > > Shamoon > > > > > > > > > > --- In , "Patrick Reitelbach" > > > > > <preitelbach@y...> wrote: > > > > > > You want a pulse every 20ms and control the pulse width > from > > > > 600us > > > > > to > > > > > > 1800us. Is this correct? > > > > > > > > > > > > pr > > > > > > --- In , honamos@y... wrote: > > > > > > > Any ideas? > > > > > > > > > > > > > > --- In , honamos@y... wrote: > > > > > > > > Hey now, > > > > > > > > I have the PIC18F458 and I'm using the CCS C > compiler. > > My > > > > > > > question > > > > > > > > is simple. I want to output a square wave at 50Hz and > > > vary > > > > > the > > > > > > > duty > > > > > > > > cycle between 3% and 9%. Any ideas how to accomplish > > > this? > > > > I > > > > > > > know > > > > > > > > I should use "SETUP_TIMER", I'm just not sure how. > > > > > > > > > > > > > > > > Thanks, > > > > > > > > Shamoon |
|