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

How can i use this command "CCP_delay" ?

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



Joined: 31 May 2009
Posts: 79

View user's profile Send private message

How can i use this command "CCP_delay" ?
PostPosted: Fri Aug 28, 2009 2:13 am     Reply with quote

I want to set the "death band delay" and I have seen this command "CCP delay" on CCSC help, but I couldn't use it in my program.

These are my source codes:
Code:

#include <16F684.h>
#fuses XT,NOWDT,BROWNOUT,PUT,INTRC
#use delay (clock=4000000)

void main()
{
setup_ccp1(CCP_PWM_FULL_BRIDGE | CCP_PWM_H_H);
set_tris_c(0x00); // Set pins C2-C5 as outputs
setup_timer_2(T2_DIV_BY_1, 255, 1);
set_pwm1_duty(127);

while(true)

setup_ccp1(CCP_PWM_FULL_BRIDGE | CCP_PWM_H_H); ///////I want death band delay here////////////////
set_tris_c(0x00); // Set pins C2-C5 as outputs
setup_ccp1(CCP_PWM_FULL_BRIDGE_REV | CCP_PWM_H_H); ///////I want death band delay here////////////////
set_tris_c(0x00); // Set pins C2-C5 as outputs
}
}
Guest








PostPosted: Fri Aug 28, 2009 12:38 pm     Reply with quote

is there anyone to answer my question?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Aug 28, 2009 1:05 pm     Reply with quote

It's not "death" band. It's dead band. This is in the PIC data sheet.

I agree that CCP_DELAY is in the compiler manual, but I can't find it
listed in any of the .h files for the PICs, so I don't think CCS implemented
it yet.

There is no CCS routine to set the dead band, so you can write one to
do it. In the program below, the set_pwm_dead_band() routine is
called after the setup_ccp1() routine. This will set the dead band time.

Also, see this post for an explanation of how to calculate the dead band
time period.
http://www.ccsinfo.com/forum/viewtopic.php?t=23896&start=1

Code:

#include <16F684.h>
#fuses XT,NOWDT,BROWNOUT,PUT
#use delay (clock=4000000)

void set_pwm_dead_band(int8 value)
{
int8 temp;
#byte PWM1CON = 0x16

// Put 'value' into the lower 7 bits of PWM1CON
// but don't change the top bit of PWM1CON.
value &= 0x7F;     
temp = PWM1CON; 
temp &= 0x80;   
temp |= value; 
PWM1CON = temp;

}

//=================================
void main()
{
setup_ccp1(CCP_PWM_FULL_BRIDGE  | CCP_PWM_H_H);

set_pwm_dead_band(0x1F);


// Put other PWM setup code here.


while(1);
}
Ttelmah
Guest







PostPosted: Sat Aug 29, 2009 9:38 am     Reply with quote

I think the reason it didn't appear in the setup, was that on the ECCP, it is done 'differently' from what CCS expected.

If you look at the setup commands they are all 'on/off' commands to enable a feature. The deadband delay on the ECCP, does not work like this. It is automatically enabled, when you select the half bridge mode, and not available otherwise. Hence having a 'flag' to enable it, made no sense.
What they then omitted, was a routine to program the value, when it was available....

Now, PCM, has programmed a nice routine to program the deadband, but it won't work for what the original poster wants, since he is selecting 'full bridge' operation, and the deadband is not available in this mode (and is not needed anyway, since there is no 'crossover' in the drives....

Best Wishes
theasus



Joined: 31 May 2009
Posts: 79

View user's profile Send private message

PostPosted: Mon Aug 31, 2009 1:49 am     Reply with quote

I understand from these answer for these applications (half bridge, full bridge operations..) the best way is using the associated register directly.
Ttelmah
Guest







PostPosted: Mon Aug 31, 2009 2:17 am     Reply with quote

Yes, but it won't do anything in full bridge mode. Look at the data sheet. The dead band is _only_ available 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