Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

interrupt for reacting on PWM duty cycle

Status
Not open for further replies.

john120

Banned
Full Member level 5
Joined
Aug 13, 2011
Messages
257
Helped
11
Reputation
22
Reaction score
10
Trophy points
1,298
Visit site
Activity points
0
Hello there,I would like to control a TRIAC through MOC3020 for that I am generaating a PWM signal which has a duty cycle corresponding to the increase or decrease of variable resistor in right or left direction.

can you please help me to do that me I am now using an adc but it is not working perfectly,see my codes with adc module:
PHP:
#include "16f877a.h"
#device adc=10
#fuses NOWDT,HS,NODEBUG,NOLVP,NOCPD
#use delay(clock=4M)
#include "lcd.c"

int value;

unsigned long valeur;
int value1;
unsigned int value2;


void main()
{
set_tris_c(0x00);
set_tris_b(0x00);
set_tris_a(0xff);
set_tris_d(0x00);

lcd_init();

setup_comparator(NC_NC_NC_NC);   
setup_adc(ADC_clock_DIV_32);
setup_adc_ports(AN0);
set_adc_channel(0);
setup_vref(FALSE);   


setup_ccp1(CCP_PWM);
setup_timer_2(T2_DIV_BY_4, 255, 1);

while(1)
{

lcd_gotoxy(1,1);
delay_us(100);
read_adc(ADC_start_only); 
delay_us(100);
value=read_adc(ADC_read_only);
valeur=value;


value1=(valeur*500)/1023;
delay_us(100);
set_pwm1_duty(value1); 

printf(lcd_putc,"\f%d",value1);
delay_ms(1500);


}

}
I want the one who can help to do so with interrupr on RBO of PIC16F877A in ccs c compiler.

Thanks.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top