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

Example for PIC18FXX31 PWM
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
stoyanoff



Joined: 20 Jul 2011
Posts: 375

View user's profile Send private message

Example for PIC18FXX31 PWM
PostPosted: Thu Mar 15, 2012 11:20 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Mar 15, 2012 11:25 am     Reply with quote

You can find examples by using the forum's search page:
http://www.ccsinfo.com/forum/search.php

Search for this: 18F*31 pwm

Set it to: Search for all terms
stoyanoff



Joined: 20 Jul 2011
Posts: 375

View user's profile Send private message

PostPosted: Fri Mar 16, 2012 9:21 am     Reply with quote

Thanks!
fkl



Joined: 20 Nov 2010
Posts: 44

View user's profile Send private message

PostPosted: Fri Mar 16, 2012 9:42 am     Reply with quote

stoyanoff wrote:
Thanks!

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

View user's profile Send private message

PostPosted: Fri Mar 16, 2012 12:34 pm     Reply with quote

Why don't you do the forum search that I suggested ?
Example of result:
http://www.ccsinfo.com/forum/viewtopic.php?t=37206
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Fri Mar 16, 2012 3:22 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Mar 18, 2012 10:08 am     Reply with quote

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

View user's profile Send private message

Power PWM
PostPosted: Sun Mar 18, 2012 12:40 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Mar 23, 2012 6:08 am     Reply with quote

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

View user's profile Send private message

complementary PWM
PostPosted: Fri Mar 23, 2012 8:55 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Mar 23, 2012 10:17 am     Reply with quote

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

View user's profile Send private message

Full Bridge Mode
PostPosted: Fri Mar 23, 2012 11:55 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Mar 23, 2012 12:00 pm     Reply with quote

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

View user's profile Send private message

3 phase half bridge.
PostPosted: Fri Mar 23, 2012 3:55 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Mar 24, 2012 2:23 am     Reply with quote

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!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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