View previous topic :: View next topic |
Author |
Message |
stoyanoff
Joined: 20 Jul 2011 Posts: 375
|
Example for PIC18FXX31 PWM |
Posted: Thu Mar 15, 2012 11:20 am |
|
|
Can someone post an example for the comands which I can use for generating PWM pulses with PIC18FXX31. How can I do change "on fly"??
How can I change the dead time, aling of the pulses.....
Thanks! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
stoyanoff
Joined: 20 Jul 2011 Posts: 375
|
|
Posted: Fri Mar 16, 2012 9:21 am |
|
|
Thanks! |
|
|
fkl
Joined: 20 Nov 2010 Posts: 44
|
|
Posted: Fri Mar 16, 2012 9:42 am |
|
|
Hello
I am also interested in the topic.
You have got to make a working device?
Can you share? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Fri Mar 16, 2012 3:22 pm |
|
|
Lack of response to previous posts/topics does NOT help your cause!
OR
Am I being grump again?
Mike |
|
|
fkl
Joined: 20 Nov 2010 Posts: 44
|
|
Posted: Sun Mar 18, 2012 10:08 am |
|
|
Mike Walne wrote: | Lack of response to previous posts/topics does NOT help your cause!
OR
Am I being grump again?
Mike |
I need to run the motor BLDC.
And I do not know how to do it on CCS C.
You can help.
PIC18F2431 |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
Power PWM |
Posted: Sun Mar 18, 2012 12:40 pm |
|
|
To fkl,
My barb about lack of response was not directed at you.
CCS supplies an example program ex_power_pwm.c which should show, in general, how to set up the pwm.
If the mode you're after is not there, the microchip data sheet explains all the options, and the precautions needed to change on the fly.
The 18Fyourpic.h file has the exact syntax each configuration.
If your requirement is missing from the .h file, or if the configuration you want is faulty, either work on the registers directly, or get CCS to fix it.
Mike |
|
|
stoyanoff
Joined: 20 Jul 2011 Posts: 375
|
|
Posted: Fri Mar 23, 2012 6:08 am |
|
|
I have a question. I`m creating program for frequency invertor. So I have positive and negative output wave(the two channels of every pwm).
So I have to use this option:
Code: | setup_power_pwm_pins(PWM_COMPLEMENTARY ,PWM_COMPLEMENTARY, PWM_COMPLEMENTARY, PWM_OFF); |
The next step is update the duty cycle
Code: | set_power_pwmx_duty(duty)
|
I understood this too.
In complementary mode when the one channel is active the another one is inactive. So I need to know how to switch the output channels???
When I`ve generated for example 10 pusles on the one channel and I need 10 pusles on the another one. How can this be done??
Thanks! |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
complementary PWM |
Posted: Fri Mar 23, 2012 8:55 am |
|
|
I suggest you look VERY carefully at the power pwm section of the microchip data sheet, and see how it relates to your power topology.
When you've decided which pwm mode you want, look at the 18fxxxx.h file for the syntax.
I suspect you've got modes mixed.
In normal complementary mode you get:-
(1) A (mark - deadtime) pulse plus a space time on the even channel, followed by
(2) A (mark - deadtime) pulse plus a space time on the odd channel.
(3) automatically repeating.
You can count pwm pulses by getting the pwm clock source to generate interrupts.
Mike |
|
|
stoyanoff
Joined: 20 Jul 2011 Posts: 375
|
|
Posted: Fri Mar 23, 2012 10:17 am |
|
|
I want to drive full bridge with 18F4431. I need an advice on what mode to use.
I need to know how to change even and odd channel of each pwm.
I saw the .h file but I couldn't understand what command to use for setting this channels.
Thanks! |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
Full Bridge Mode |
Posted: Fri Mar 23, 2012 11:55 am |
|
|
Hi Stoyanoff,
First we need to establish EXACTLY what YOU mean by full bridge.
In my experience of switch mode supplies, this can mean different topologies and/or switching schemes.
I normally mean this arrangement:-
Code: |
V+ ____________________________________
| |
| |
| |
\ \
Switch \ \ Switch
A \ \ B
| |
| _________ |
| | | |
|___| LOAD |___|
| | | |
| |_______| |
| |
\ \
Switch \ \ Switch
C \ \ D
| |
| |
| |
V- ____________________|_______________|
|
Where the load is often the primary of an isolating transformer.
In this scheme:-
(1) Switches A & D turned on together, for PWM mark time.
(2) Switches A & D turned off together, for PWM space time.
(3) Switches B & C turned on together, for PWM mark time.
(4) Switches B & C turned off together, for PWM space time.
(5) Repeat from (1)
Power is regulated by controlling PWM duty ratio, taking care to keep below 100% or have built in dead time.
Are you using this topology or something else?
Mike
PS If the load is a resonant circuit, the duty ratio is fixed at close to 100% and frequency change regulates power. |
|
|
stoyanoff
Joined: 20 Jul 2011 Posts: 375
|
|
Posted: Fri Mar 23, 2012 12:00 pm |
|
|
Yes! I know all this, but I'll use it for 3 phase chart (with 6 transistors).
So to simulate 3 phase output I have to control all 6 pwm channels.
I want to know how to set duty time for every transistor (channel).
What setup configuration do I have to use and what command for loading the registers??? |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
3 phase half bridge. |
Posted: Fri Mar 23, 2012 3:55 pm |
|
|
Hi Stoyanoff,
I don't think you mean FULL BRIDGE.
This is what I would call 3 half bridges, (microchip calls it simply half bridge).
This is a crude version of the data sheet drawing 18-16 on page 190.
Code: |
V+ ____________________________________________________
| | |
| | |
| | |
| | |
\ \ \
Switch \ Switch \ Switch \
A \ B \ C \
| | | Three phase load
| | | __________
|_______________|_______________|__________| Phase 1 |______
| | | |__________| |
| | | |
| | | __________ |
| |_______________|__________| Phase 2 |______|
| | | |__________| |
| | | |
| | | __________ |
| | |__________| Phase 3 |______|
| | | |__________|
| | |
| | |
\ \ \
Switch \ Switch \ Switch \
D \ E \ F \
| | |
| | |
| | |
| | |
V- ____________________|_______________|_______________|
|
Is this the topology you intend using?
If it is, there are several ways to drive it.
The microchip data sheet explains which registers to use to get different methods.
Microchip are effectively telling you what's available/possible. CCS then convert to their way of doing things.
Sort out which one you want, then figure out the CCS syntax for that.
Like I said before, if CCS don't provide what you need, complain to them.
Mike |
|
|
stoyanoff
Joined: 20 Jul 2011 Posts: 375
|
|
Posted: Sat Mar 24, 2012 2:23 am |
|
|
Yes! This is what I want to do!
I have AN899. I need to know how to do the process in CCS. How to setup the channels according to the output wave I need.
I want to generate a sinusoidal voltage with pwm. So I have positive and negative half wave.
I every of them I have to use separately upper and lower transistor.
In the help of CCS I found only functions for setting the entire twin.
Is there a way to do this or CCS just doesn`t support it and I have to use the registers to do it???
Thanks! |
|
|
|