Microcontroller › PIC › AC THREE PHASE ANALOG INPUTS DETECTOR C CODE
- This topic has 1 reply, 2 voices, and was last updated 9 years, 2 months ago by Prabakaran P M.
Viewing 2 posts - 1 through 2 (of 2 total)
-
AuthorPosts
-
July 11, 2015 at 1:52 pm #3758DhananjayaParticipantDear Sir/Madam please give any idea/concept for AC Phase detecting either Present/Absent (Logic 1/0)without converting DC volt to detect TTL PIC16F676 microcontroller someone already implemented this products but know i am also implementing this concept on same circuits but I have dont know the logic/ C code for this know I am tried as follows but still i cant able to detecting phasethree phase (RY & AC analog inputs directly connected microcontroller pin without converting DC volts / reduced the voltage by using resistor divider circuit series with of 2.2Mohm 0.5watt+5Mohm 0.25watt connected to microcontroller(PIC16F676 pins RA0,RA1 & RA2). and internal oscillator like#define _XTAl_FREQ 4000000__CONFIG(0x3FF4)#define R_phase RA0#define Y_phase RA1#define B_phase RA2#define Three_phase_LED RC0#define Two_phase_LED RC1#define Single_phase_LED RC2#define NO_phase_LED RC3char phaseRflag = 0; // flag variables for each phasechar phaseYflag = 0;char phaseBflag = 0;char single_phase_flag = 0; // used for single phase detection testunsigned int sample = 0; // used to set "for loop" durationvoid main(){CMCON=0x07;ANSEL=0x00;TRISA =0b001111;PORTA=0b001111;TRISC=0b000000;PORTC=0b00000;while(1) // while loop to test phases continously{phaseRflag = 0; // phase flags are set to zerophaseYflag = 0;phaseBflag = 0;// a "for loop" tests the inputs for 20 milliseconds, setting a flag if a logic 1 is readfor(sample = 16000; sample > 0; sample–) // test all phases for at least 20 milliseconds{if(R_phase) // if a 1 is detected on a phase set a flag to 1;phaseRflag = 1;if(Y_phase)phaseYflag = 1;if(B_phase)phaseBflag = 1;} // end of the for loop// phase tests running as before, except now looking at the flag settings// test for all phases on
if(phaseRflag && phaseYflag && phaseBflag)Three_phase_LED = 1; // RC0 pin connected(Three_phase) LED will Glow ONelseThree_phase_LED = 0;// test for phase R and B on
if(phaseRflag && phaseBflag && !phaseYflag)Two_phase_LED = 1; // RC1 pin connected(Two_phase) LED will Glow ONelseTwo_phase_LED = 0;// test for a single phase on
single_phase_flag = 0; // set if only a single phase was detectedif(phaseRflag || !phaseYflag || !phaseBflag) // only R_phase is onsingle_phase_flag = 1;if(!phaseRflag || phaseYflag || !phaseBflag) // only Y_phase is onsingle_phase_flag = 1;if(!phaseRflag || !phaseYflag || phaseBflag) // only B_phase is onsingle_phase_flag = 1;if(single_phase_flag == 1) // if a single phase was detectedSingle_phase_LED = 1; // RC2 pin connected(Single_phase) LED will Glow ONelseSingle_phase_LED = 0; // single phase LED off// test for no phases on
if(!phaseRflag && !phaseYflag && !phaseBflag)NO_phase_LED = 1; // RC3 pin connected(No_phase) LED will Glow OnelseNO_phase_LED = 0;} // end of while loop} // end of mainIn this pregame onlyNO_phase_LED = 1; LED is On always….July 14, 2015 at 5:09 am #13068Prabakaran P MParticipantHi Dhananjaya,
For giving you idea in this topic i need the circuit diagram of the voltage divider circuit you used. coding logic is correct. Use diodes and voltage divider to ac voltage to dc voltage. Because Pic microcontroller can only read the dc voltage logics.
http://www.engineersgarage.com/contribution/transformerless-power-supply-circuit?page=1
you can refer to this page for transformerless ac to dc convertion.
Note: Ac live Voltage will be found all over the circuit so be safe while doing these type of projects.
-
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.