[PIC] Phase angle control of thyristor w/ PIC18F

Status
Not open for further replies.

theredkid

Newbie level 5
Joined
Apr 21, 2011
Messages
10
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,353
Hello,

For the following code, I get some errors:


Code:
#include <18F452.h> 
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP 
#use delay(clock = 4000000) 

unsigned char FlagReg; 
sbit ZC at FlagReg.B0; 

void interrupt(){ 
if (INTCON.INTF){ //INTF flag raised, so external interrupt occured 
ZC = 1; 
INTCON.INTF = 0; 
} 
} 

void main() { 
PORTB = 0; 
TRISB = 0x01; //RB0 input for interrupt 
PORTA = 0; 
ADCON1 = 7; //Disable ADC 
TRISA = 0xFF; //Make all PORTA inputs 
PORTD = 0; 
TRISD = 0; //PORTD all output 
OPTION_REG.INTEDG = 0; //interrupt on falling edge 
INTCON.INTF = 0; //clear interrupt flag 
INTCON.INTE = 1; //enable external interrupt 
INTCON.GIE = 1; //enable global interrupt 

while (1){ 
if (ZC){ //zero crossing occurred 
delay_ms(2); 
PORTD.B0 = 1; //Send a pulse 
delay_us(250); 
PORTD.B0 = 0; 
ZC = 0; 
} 
} 
}


And error list is as follows:



What's wrong above???
 

While writing this code,did you select the correct microcontroller when you were creating this using the new project option?
The errors,you are experiencing,they have happened because the relevant microcontroller name has not been noticed correctly by the compiler....maybe.Write this code while going through new project option again.....might work out this time.
 

#include <18F252.h>//3faz full control T0
#device ADC=8
#fuses HS,NOWDT,NOPUT,NOLVP,NOBROWNOUT,NOCPD,NOWRT,NODEBUG
#use delay(clock=20000000)
/***entegreterbiyecisi@yahoo.com***/
#use fast_io(A)
#use fast_io(B)

#Byte Port_A = 0xF80
#Byte Port_B = 0xF81
#Byte Port_C = 0xF82

int16 tg1=0,tg2=0,tg3=0,set1=300,set=50;
int8 g1=0,g2=0,g3=0,i=0;
////////////////////////////////////////
#INT_TIMER0
void temp(){
set_timer0(170);
if(set1>tg1){tg1++;if(set==tg1){g1=1;}}
if(set1>tg2){tg2++;if(set==tg2){g2=1;}}
if(set1>tg3){tg3++;if(set==tg3){g3=1;}}

}
////////////////////////////////////////
#INT_EXT
void phase0(){//full wave R zerocros
tg1=0;
}
//////////////////////////////////
#INT_EXT1
void phase1(){//full wave S zerocros
tg2=0;
}
////////////////////////////////
#INT_EXT2
void phase2(){//full wave T zerocros
tg3=0;
}
/////////////////////////////////////////////////////////////
void main(){

set_tris_B(0b00001111);
set_tris_A(0b000111111);
setup_adc_ports(AN0);
setup_adc(ADC_CLOCK_INTERNAL);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_2|T0_8_BIT);
enable_interrupts(int_timer0);//.2*2*220*85=7840US+is=9ms
enable_interrupts(INT_EXT); //20mhz t0 adc st0
enable_interrupts(INT_EXT1);
enable_interrupts(INT_EXT2);
ext_int_edge(L_TO_H);
enable_interrupts(GLOBAL);


while(true){
if(g1==1){output_bit(PIN_B5,1);delay_us(100);output_bit(PIN_B5,0);g1=0;}//trig R
if(g2==1){output_bit(PIN_B6,1);delay_us(100);output_bit(PIN_B6,0);g2=0;}//trig S
if(g3==1){output_bit(PIN_B7,1);delay_us(100);output_bit(PIN_B7,0);g3=0;}//trig T

i++;
if(i>=100){
set_adc_channel(0); //pot oku
delay_us(10);
set=read_adc();
delay_us(10);
if(set<7){set=7;}
if(set>210){set=210;}
i=0;
}
}
}
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…