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 support@ccsinfo.com

pwm

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







pwm
PostPosted: Mon Nov 06, 2006 6:35 am     Reply with quote

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)
Neckruin



Joined: 17 Jan 2006
Posts: 66

View user's profile Send private message

PostPosted: Mon Nov 06, 2006 6:37 am     Reply with quote

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??? Confused
It's very strange....
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Nov 06, 2006 12:18 pm     Reply with quote

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
tomi2
Guest







pwm
PostPosted: Tue Nov 07, 2006 5:05 am     Reply with quote

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
Ttelmah
Guest







PostPosted: Tue Nov 07, 2006 5:28 am     Reply with quote

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
Tomi2
Guest







pwm
PostPosted: Tue Nov 07, 2006 8:05 am     Reply with quote

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??)
Ttelmah
Guest







PostPosted: Tue Nov 07, 2006 8:50 am     Reply with quote

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
tomi2
Guest







pwm
PostPosted: Tue Nov 07, 2006 12:56 pm     Reply with quote

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)
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Nov 07, 2006 2:51 pm     Reply with quote

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.
Ttelmah
Guest







Re: pwm
PostPosted: Tue Nov 07, 2006 3:41 pm     Reply with quote

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
Tomi2
Guest







Re: pwm
PostPosted: Wed Nov 08, 2006 4:38 am     Reply with quote

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
Ttelmah
Guest







PostPosted: Wed Nov 08, 2006 5:42 am     Reply with quote

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
Tomi2
Guest







PWM
PostPosted: Thu Nov 09, 2006 8:06 am     Reply with quote

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
Ttelmah
Guest







PostPosted: Thu Nov 09, 2006 8:34 am     Reply with quote

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
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