View previous topic :: View next topic |
Author |
Message |
Eddy71ua
Joined: 23 Sep 2009 Posts: 55 Location: Ukraine
|
Dead-band delay PWM |
Posted: Wed Apr 14, 2021 12:45 am |
|
|
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: 19358
|
|
Posted: Wed Apr 14, 2021 3:29 am |
|
|
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: 9168 Location: Greensville,Ontario
|
|
Posted: Wed Apr 14, 2021 4:47 am |
|
|
Seven ? just seven ??
sigh...PICs are too complicated today !
Can we reset the clock back to the EASY days of the 16C84 please ?
Bet uchip will announce an 8th PWM before this gets posted |
|
|
Eddy71ua
Joined: 23 Sep 2009 Posts: 55 Location: Ukraine
|
|
Posted: Wed Apr 14, 2021 5:31 am |
|
|
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: 9168 Location: Greensville,Ontario
|
|
Posted: Wed Apr 14, 2021 6:40 am |
|
|
PWM1CON is an 8 bit register, so you can't actually, phyiscally make it 0x294..... |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19358
|
|
Posted: Wed Apr 14, 2021 7:40 am |
|
|
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
|
|
Posted: Wed Apr 14, 2021 8:04 am |
|
|
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.
|
|
|
|