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

Dead-band delay PWM

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



Joined: 23 Sep 2009
Posts: 55
Location: Ukraine

View user's profile Send private message Visit poster's website

Dead-band delay PWM
PostPosted: Wed Apr 14, 2021 12:45 am     Reply with quote

In Half-Bridge mode, a digitally programmable dead-band delay is available to avoid shoot-through current from destroying the bridge power switches.
What command can I use to set this time?
Ttelmah



Joined: 11 Mar 2010
Posts: 19538

View user's profile Send private message

PostPosted: Wed Apr 14, 2021 3:29 am     Reply with quote

You need to say 'what chip'.
There are about seven different actual PWM implementations on different
PIC's (some even have two different ones in a single chip), and the
settings for each are different.
temtronic



Joined: 01 Jul 2010
Posts: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Apr 14, 2021 4:47 am     Reply with quote

Seven ? just seven ??
sigh...PICs are too complicated today !
Can we reset the clock back to the EASY days of the 16C84 please ? Very Happy

Bet uchip will announce an 8th PWM before this gets posted Laughing
Eddy71ua



Joined: 23 Sep 2009
Posts: 55
Location: Ukraine

View user's profile Send private message Visit poster's website

PostPosted: Wed Apr 14, 2021 5:31 am     Reply with quote

Ttelmah wrote:
You need to say 'what chip'.


Sorry. PIC16F1823
Register PWM1CON

I couldn't find the command, so I used this combination:

#byte PWM1CON = 0x294

...

PWM1CON = xx;
temtronic



Joined: 01 Jul 2010
Posts: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Apr 14, 2021 6:40 am     Reply with quote

PWM1CON is an 8 bit register, so you can't actually, phyiscally make it 0x294.....
Ttelmah



Joined: 11 Mar 2010
Posts: 19538

View user's profile Send private message

PostPosted: Wed Apr 14, 2021 7:40 am     Reply with quote

In which case this has the basic ECCP module.

Very simple. If you look at the manual, you will see that the setup_ccp1
function allows you to specify setup_ccp1(mode) or, setup_ccp1(mode, pwm).
The 'pwm' parameter here is the deadband time.

He is not setting PWM1CON to 0x294, that is it's address. However I would
say to always use the name instead of a physical address.

#byte PWM1CON = getenv("SFR:PWM1CON")

is safer, and much more informative than manually putting in addresses.

setup_ccp1(CCP_PWM_HALF_BRIDGE, 1);

Gives you one clock cycle of deadband delay.

Assembles as:
Code:

....................    setup_ccp1(CCP_PWM_HALF_BRIDGE, 1);   while(TRUE)
000B:  MOVLB  01
000C:  BSF    TRISC.5
000D:  MOVLB  05
000E:  CLRF   CCP1CON
000F:  MOVLW  80
0010:  MOVWF  CCP1CON
0011:  MOVLW  01
0012:  MOVWF  PWM1CON //you see the '1' put in here
0013:  CLRF   CCP1AS
0014:  MOVWF  PSTR1CON


The manual does tell you this:
Quote:

pwm parameter - is an optional parameter for chips that includes ECCP module. This parameter allows setting the shutdown time. The value may be 0-255.


Though they for some reason call it shutdown time, rather than deadband.
Eddy71ua



Joined: 23 Sep 2009
Posts: 55
Location: Ukraine

View user's profile Send private message Visit poster's website

PostPosted: Wed Apr 14, 2021 8:04 am     Reply with quote

Thank you Ttelmah.

I'll be experimenting.

Code:
setup_ccp1(CCP_PWM_HALF_BRIDGE, 1);


The command does not work - the PWM output is zero.

Code:
setup_ccp1(CCP_PWM|CCP_PWM_HALF_BRIDGE, 1);


This design works fine.

Smile
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