Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

help for pic micro controller code 16f690

Status
Not open for further replies.
hi am beginner of pic programmer i need a code for pwm smooth start for my smbs ..here i am using pic 16f690 .i enabled eccp pwm ..i here i show the code is working halfbridge mode

so i need when i switch on the pulse to start from 0 to loaded duty cycle value ..this is my code using ccs c complier

#USE DELAY (CLOCK=8000000)
#byte PWM1CON=0x1C
#byte Eccpas = 0x1D
#define CCP_SHUTDOWN_MODE (CCP_SHUTDOWN_ON_INT0 | \
CCP_SHUTDOWN_AC_L | \
CCP_SHUTDOWN_BD_L | \
CCP_SHUTDOWN_RESTART)
#byte ccp1con=0x17
void main()
{
int i,j,k,n;
DISABLE_INTERRUPTS(GLOBAL);
setup_adc_ports(sAN10|sAN11|VSS_VDD);
setup_adc( ADC_CLOCK_INTERNAL );
SETUP_CCP1(CCP_PWM_HALF_BRIDGE|CCP_PWM_H_H|CCP_SHUTDOWN_MODE) ;

set_tris_c(0xc0);
while(1)
{


set_adc_channel( 10 );
delay_ms(10);
i=read_adc();
delay_ms(100);
j=i/42.50+(58.5);
k=(j/1.8);
delay_ms(10);
SETUP_TIMER_2(T2_DIV_BY_1,j,1);
Pwm1con=0x04;
set_pwm1_duty(k);

}

}

also thre is a shut down command one is interrupt and another one is comparator any help me the hardware connection for comparator which pin ref and which is input
help me
 
I don't fully understand your question but for proper startup of PWM, it is normal to have a pulldown on the PWM pin and only switch the pin to output when the PWM module is ready. Likewise, shutdown can be accomplished by switching the pin to input.

Mike.
 
am using analog input as a duty cycle value ..i need duty cycle starts from zero to adc value..like smooth start ..it mean for an examble analog out put is 60 % duty cycle so when suddenly switch on the board, the value not suddenly load to duty cycle register (i need linear )

0-1,1-2,2-3,3-4........60% with in 20 sec or 10 sec ...how the motor starts 0 -100 % like that

thank for your reply
 
Before your wait(1); do the following,

Calculate k,
have a for loop from 0 to k,
set the PWM
delay 10 seconds divided by k

This will ensure that it always takes 10 seconds to get up to speed.

A variation on the above would be a while loop that slowly increased the PWM value until k was reached.

Mike.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top