+ Post New Thread
Results 1 to 3 of 3
  1. #1
    Newbie level 5
    Points: 695, Level: 5

    Join Date
    Apr 2011
    Posts
    10
    Helped
    0 / 0
    Points
    695
    Level
    5

    Phase angle control of thyristor w/ PIC18F

    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:


    Clean: Deleting intermediary and output files.
    Clean: Deleted file "p3.ESYM".
    Clean Warning: File "D:\mehmet projeler\p1\p3.o" doesn't exist.
    Clean: Deleted file "p3.ERR".
    Clean: Deleted file "D:\mehmet projeler\p1\p3.mcs".
    Clean: Done.
    Executing: "C:\Program files\PICC\CCSC.exe" +FH "p3.c" +DF +LN +T +A +M +Z +Y=9 +EA
    *** Error 48 "p3.c" Line 6(6,10): Expecting a (
    *** Error 48 "p3.c" Line 6(12,14): Expecting a (
    *** Error 43 "p3.c" Line 6(19,20): Expecting a declaration
    *** Error 48 "p3.c" Line 6(20,22): Expecting a (
    *** Error 12 "p3.c" Line 9(10,16): Undefined identifier INTCON
    *** Error 12 "p3.c" Line 10(12,14): Undefined identifier ZC
    *** Error 12 "p3.c" Line 11(9,15): Undefined identifier INTCON
    *** Error 12 "p3.c" Line 16(12,17): Undefined identifier PORTB
    *** Error 12 "p3.c" Line 17(12,17): Undefined identifier TRISB
    *** Error 12 "p3.c" Line 18(12,17): Undefined identifier PORTA
    *** Error 12 "p3.c" Line 19(13,19): Undefined identifier ADCON1
    *** Error 12 "p3.c" Line 20(12,17): Undefined identifier TRISA
    *** Error 12 "p3.c" Line 21(12,17): Undefined identifier PORTD
    *** Error 12 "p3.c" Line 22(12,17): Undefined identifier TRISD
    *** Error 12 "p3.c" Line 23(6,16): Undefined identifier OPTION_REG
    *** Error 12 "p3.c" Line 24(6,12): Undefined identifier INTCON
    *** Error 12 "p3.c" Line 25(6,12): Undefined identifier INTCON
    *** Error 12 "p3.c" Line 26(6,12): Undefined identifier INTCON
    *** Error 12 "p3.c" Line 29(16,18): Undefined identifier ZC
    *** Error 12 "p3.c" Line 31(15,20): Undefined identifier PORTD
    *** Error 12 "p3.c" Line 33(15,20): Undefined identifier PORTD
    *** Error 12 "p3.c" Line 34(18,20): Undefined identifier ZC
    22 Errors, 0 Warnings.
    Build Failed.
    Halting build on first failure as requested.
    BUILD FAILED: Tue Sep 02 11:43:52 2014
    What's wrong above???

    •   AltAdvertisment

        
       

  2. #2
    Full Member level 5
    Points: 1,653, Level: 9
    udayan92's Avatar
    Join Date
    Mar 2014
    Location
    India
    Posts
    284
    Helped
    38 / 38
    Points
    1,653
    Level
    9

    Re: Phase angle control of thyristor w/ PIC18F

    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.



    •   AltAdvertisment

        
       

  3. #3
    Member level 1
    Points: 3,002, Level: 12
    necati's Avatar
    Join Date
    Mar 2003
    Location
    turkey
    Posts
    40
    Helped
    8 / 8
    Points
    3,002
    Level
    12

    Re: Phase angle control of thyristor w/ PIC18F

    #include <18F252.h>//3faz full control T0
    #device ADC=8
    #fuses HS,NOWDT,NOPUT,NOLVP,NOBROWNOUT,NOCPD,NOWRT,NODEBU G
    #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);outpu t_bit(PIN_B5,0);g1=0;}//trig R
    if(g2==1){output_bit(PIN_B6,1);delay_us(100);outpu t_bit(PIN_B6,0);g2=0;}//trig S
    if(g3==1){output_bit(PIN_B7,1);delay_us(100);outpu t_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;
    }
    }
    }



--[[ ]]--