![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
Tomi2 Guest
|
pwm |
Posted: Mon Nov 06, 2006 6:35 am |
|
|
hello everyone
is there anyone who knows how to activate the 4 channel pwm in the component that i use?
using the instruction setup_ccp1 (CCP_PWM);
activate one channel while with the instruction setup_ccp2 (CCP_PWM i activate the second.
how will i activate the four channels (the component has the four channels) |
|
![](templates/subSilver/images/spacer.gif) |
Neckruin
Joined: 17 Jan 2006 Posts: 66
|
|
Posted: Mon Nov 06, 2006 6:37 am |
|
|
If the device you are using is supported by the compiler, there should be something similar to "setup_ccp3()" and "setup_ccp4()" or similar. Isn't it???
It's very strange.... |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Nov 06, 2006 12:18 pm |
|
|
You didn't post your PIC. However, this may help:
Look at the CCS example file: EX_POWER_PWM.C
It's in this folder:
c:\Program Files\PICC\Examples |
|
![](templates/subSilver/images/spacer.gif) |
tomi2 Guest
|
pwm |
Posted: Tue Nov 07, 2006 5:05 am |
|
|
PCM programmer wrote: | You didn't post your PIC. However, this may help:
Look at the CCS example file: EX_POWER_PWM.C
It's in this folder:
c:\Program Files\PICC\Examples |
i use the 18f450 component.i try to write the code
setup_power_pwm (pwm_clock_div_4 | pwm_free_run, 1, 1000, 1000, 0, 1, 0);
setup_power_pwm_pins (PWM_ODD_ON, PWM_ODD_ON, PWM_ODD_ON, PWM_ODD_ON);
but i have the message from compiler that
Undefined identifier setup_power_pwm |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Tue Nov 07, 2006 5:28 am |
|
|
What device?. There is no '18F450', so you presumably mean either the 4450, or the 4550?. The 4450, only has a normal PWM. The 4550, has the ECCP module, but not the power PWM module.
Only the xx31 chips currently have the power_pwm module. This is why the power PWM functions don't work on your chip.
Now, the ECCP, on the 4550, is controlled by the normal PWM functions, but does _not_ give four completely separate channels. This is a common misunderstanding of what the data sheet says. The device has _two_PWM generators, which can operate four outputs. Basically each PWM, can output either the normal pulse, or it's logical invert, on a pair of pins, to allow H bridge control. However there are still only two frequencies selectable at a time.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
Tomi2 Guest
|
pwm |
Posted: Tue Nov 07, 2006 8:05 am |
|
|
Ttelmah wrote: | What device?. There is no '18F450', so you presumably mean either the 4450, or the 4550?. The 4450, only has a normal PWM. The 4550, has the ECCP module, but not the power PWM module.
Only the xx31 chips currently have the power_pwm module. This is why the power PWM functions don't work on your chip.
Now, the ECCP, on the 4550, is controlled by the normal PWM functions, but does _not_ give four completely separate channels. This is a common misunderstanding of what the data sheet says. The device has _two_PWM generators, which can operate four outputs. Basically each PWM, can output either the normal pulse, or it's logical invert, on a pair of pins, to allow H bridge control. However there are still only two frequencies selectable at a time.
Best Wishes |
You are right is 18F4550.I try to create 4 channel pwm all have the same frequencies and i don't know how.(i can generate only two with ccp1,ccp2 but what about the others??) |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Tue Nov 07, 2006 8:50 am |
|
|
You can't.
The chip _only_has two PWM channels. CCP2, is a standard PWM, and CCP1, is an ECCP module. The latter can have up to four outputs (for H-bridge driving), but only one frequency can be used for all these outputs.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
tomi2 Guest
|
pwm |
Posted: Tue Nov 07, 2006 12:56 pm |
|
|
Ttelmah wrote: | You can't.
The chip _only_has two PWM channels. CCP2, is a standard PWM, and CCP1, is an ECCP module. The latter can have up to four outputs (for H-bridge driving), but only one frequency can be used for all these outputs.
Best Wishes |
This is not logical at all because the datasheet says that the
component has
4 channels (actually it shows 4 channel and says that it is 5. i
suppose it
means the 5th channel as multiplex) |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Nov 07, 2006 2:51 pm |
|
|
Compare the ECCP PWM block diagram in the 18F4550 data sheet to
the Power PWM block diagram in the 18F4431 data sheet.
In 18F4550, there's only one PWM module feeding the output control
section.
In the 18F4431, there are four independent PWM modules feeding the
output driver block.
If you really need the independent PWM's, you're going to have to
change to the other PIC. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
Re: pwm |
Posted: Tue Nov 07, 2006 3:41 pm |
|
|
tomi2 wrote: | Ttelmah wrote: | You can't.
The chip _only_has two PWM channels. CCP2, is a standard PWM, and CCP1, is an ECCP module. The latter can have up to four outputs (for H-bridge driving), but only one frequency can be used for all these outputs.
Best Wishes |
This is not logical at all because the datasheet says that the
component has
4 channels (actually it shows 4 channel and says that it is 5. i
suppose it
means the 5th channel as multiplex) |
You need to distinguish the idea of 'output channels', from the 'pwm channels'. The chip has just two pwm generators, with one able to drive four output channels (as I said, to give H bridge driving). These four channels according to the setup, can have a variety of different pulse layouts generated, but all four are fed from a single 'pwm channel', so can only have one frequency.
There are five possible PWM outputs (CCP2, is available as well), but only two pwm frequencies can be generated.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
Tomi2 Guest
|
Re: pwm |
Posted: Wed Nov 08, 2006 4:38 am |
|
|
Ttelmah wrote: | tomi2 wrote: | Ttelmah wrote: | You can't.
The chip _only_has two PWM channels. CCP2, is a standard PWM, and CCP1, is an ECCP module. The latter can have up to four outputs (for H-bridge driving), but only one frequency can be used for all these outputs.
Best Wishes |
This is not logical at all because the datasheet says that the
component has
4 channels (actually it shows 4 channel and says that it is 5. i
suppose it
means the 5th channel as multiplex) |
You need to distinguish the idea of 'output channels', from the 'pwm channels'. The chip has just two pwm generators, with one able to drive four output channels (as I said, to give H bridge driving). These four channels according to the setup, can have a variety of different pulse layouts generated, but all four are fed from a single 'pwm channel', so can only have one frequency.
There are five possible PWM outputs (CCP2, is available as well), but only two pwm frequencies can be generated.
Best Wishes |
My quenstion is how to to drive four output channels from the two generators(All have the same frequency) .Thanks a lot |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Wed Nov 08, 2006 5:42 am |
|
|
Look at the data sheet.
Look at the diagrams 16-2, & 16-3. These show the possible output patterns for the four signals available from the ECCP.
These are accessed using the setup_ccp function, and the constants defined in the .h file for the chip. Oring together these patterns:
CCP_PWM_H_H
CCP_PWM_H_L
CCP_PWM_L_H
CCP_PWM_L_L
CCP_PWM_FULL_BRIDGE
CCP_PWM_FULL_BRIDGE_REV
CCP_PWM_HALF_BRIDGE
There is no independant control of the signals though. You have to set the single PWM frequency/pulse width, and separately, what output pulse pattern your require from this.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
Tomi2 Guest
|
PWM |
Posted: Thu Nov 09, 2006 8:06 am |
|
|
Ttelmah wrote: | Look at the data sheet.
Look at the diagrams 16-2, & 16-3. These show the possible output patterns for the four signals available from the ECCP.
These are accessed using the setup_ccp function, and the constants defined in the .h file for the chip. Oring together these patterns:
CCP_PWM_H_H
CCP_PWM_H_L
CCP_PWM_L_H
CCP_PWM_L_L
CCP_PWM_FULL_BRIDGE
CCP_PWM_FULL_BRIDGE_REV
CCP_PWM_HALF_BRIDGE
There is no independant control of the signals though. You have to set the single PWM frequency/pulse width, and separately, what output pulse pattern your require from this.
Best Wishes |
I was wondering if you could give me some advice on how to use all that. (the manual doesnīt help and does not give enough explanations about that). If you have in mind some example or any site on the internet that explains all that, it would be really helpful
The code i write in has the form :
setup_adc_ports(ALL_ANALOG);
setup_adc(ADC_CLOCK_div_16);
setup_ccp1(CCP_PWM);
setup_timer_2(T2_DIV_BY_16, 255, 1);
CCP_PWM_H_H
CCP_PWM_H_L
CCP_PWM_L_H
CCP_PWM_L_L
i donīt know if i should each order use it for each channel of ADC |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Thu Nov 09, 2006 8:34 am |
|
|
Have you looked at the diagrams?.
You have three basic drive choices. The first is just to drive one pin (single output). The second, drives two pins with the signal, one having the basic signal, and the other the invert of this signal, with a short 'delay' between them. This delay, is separately programmable, and is to avoid having both drivers 'on' at the same time, when one comes on, and the other goes off (half bridge). The third is to drive two pins out of four, with one carrying the PWM signal, and the 'diagonally opposite' one, being turned on. This can then be swapped to operate the other pair out of the four (full bridge mode).
Now, no mode operates more than two pins _at a time_. And there is only ever one actual frequency/pulse width (with the exception of modulating the second versus the first, using the delay function, in half-bridge mode).
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|