PIC16F676 Analog AC inputs Detecting Problem

Status
Not open for further replies.

dcnivas

Newbie level 5
Joined
Jun 15, 2016
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
90
Hi i am having a problem with pic16f676 controller for detecting a analog input to RA0, RA1 & RA2 are connected to three analog AC inputs 50 hz frequenncy, three phase voltages 440 volts i reduced ac voltages by connecting series resistors. i ust i want its i/p coming or not (yes/No)

i have declare the following steps if have any further steps please let me know...


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include<htc.h>
#define_XTAL_FREQ 4000000
__CONFIG(0x3FF4)
#define Rmain RA0;
#define Ymain RA1;
#define Bmain RA2;
#define RphaseLed RC0;
#define YphaseLed RC1;
#define BphaseLed R2
char RphaseFlag=0;
char YphaseFlag=0;
char BphaseFlag=0;
void main()
{
INTCON =0x00;
CMCON=0x07;
ANSEL=0x00;
TRISA=0b001111;
PORTA=0b001111;
TRISC=0b000000;
PORTC=0b000000; 
RphaseFlag=0;YphaseFlag=0;BphaseFlag=0;
while(1)
{
  if(Rmain ==1)
      RphaseFlag=1;
  
if(Ymain ==1)
      YphaseFlag=1;
 
if(Bmain ==1)
      BhaseFlag=1;
  
     if(RphaseFlag==1) RphaseLed=1;
 if(YphaseFlag==1) YphaseLed=1;
 if(BphaseFlag==1) BphaseLed=1;
}
}


its working good in only RA0 and RA1 like R phase and Y phase input detecting but not working RA2 pin(B Phase ) i think its comparator out put pin itd not detecting input AC voltage is there any other declaration please let me know...
 
Last edited by a moderator:

If that's working at all it is because there may be a logic level change at the inputs. The ADC doesn't seem to be used though and simply adding series resistors risks damage to the PIC inputs. It appears all it may do is turn all the LEDs on as soon as the first positve voltage appears on each input. Is that what you want?

Please show your schematic and confirm you have a neutral connection as well as the three phases.

Brian.
 

can you show the code?

Hi i am having a problem with pic16f676 controller for detecting a analog input to RA0, RA1 & RA2 are connected to three analog AC inputs 50 hz frequenncy, three phase voltages 440 volts i reduced ac voltages by connecting series resistors. i ust i want its i/p coming or not (yes/No)

i have declare the following steps if have any further steps please let me know...


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include<htc.h>
#define_XTAL_FREQ 4000000
__CONFIG(0x3FF4)
#define Rmain RA0;
#define Ymain RA1;
#define Bmain RA2;
#define RphaseLed RC0;
#define YphaseLed RC1;
#define BphaseLed RC2
char RphaseFlag=0;
char YphaseFlag=0;
char BphaseFlag=0;
void main()
{
INTCON =0x00;
CMCON=0x07;
ANSEL=0x00;
TRISA=0b001111;
PORTA=0b001111;
TRISC=0b000000;
PORTC=0b000000; 
RphaseFlag=0;YphaseFlag=0;BphaseFlag=0;
while(1)
{
  if(Rmain ==1)
      RphaseFlag=1;
  
if(Ymain ==1)
      YphaseFlag=1;
 
if(Bmain ==1)
      BhaseFlag=1;
  
     if(RphaseFlag==1) RphaseLed=1;
 if(YphaseFlag==1) YphaseLed=1;
 if(BphaseFlag==1) BphaseLed=1;
}
}



its working good in only RA0 and RA1 but not working RA2 pin i think its comparator out put pin itd not detecting input AC voltage is there any other declaration please let me know...
 
Last edited by a moderator:

Re: PIC16F676 Analog AC inputs Detecting Problem

yes sir its its detect only +ve half cycle its detect both RA0 and RA1 inputs these two are comparator inputs but RA2 pin is only comparator out pin thats why its not detecting input AC +ve voltage is there any declaration

can you show the code?
Sir how to detect these three phase inputs are same or different phase because i have given same phase voltages to RA0 and RA1 pins but its shows logic 1 otherwise is there any comparison config register these are same phase or different phase input voltages
 

CMCON=0x07; turns the comparator off, RA2 works as a normal digital input or output pin. You have it configured as an input which is correct.

I suspect you are only using the pins as normal digital inputs and the comparator has nothing to do with your problem. More likely it has something to do with the voltage at the RA2 pin which is why I asked if you have a neutral wire in the circuit. If you only have three phase wires it is difficult to tell if they are all 'live' unless you have some reference point to measure them from. Each phase wire may have ~230V relative to neutral but if there is no neutral, you have to use one of the phases as a reference to measure the other two against.

Please post the schematic you are using so we can see which points you are checking voltages across.

Brian.
 

can you show the code?

i have declare the following steps if have any further steps please let me know...


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include<htc.h>
#define_XTAL_FREQ 4000000
__CONFIG(0x3FF4)
#define Rmain RA0;
#define Ymain RA1;
#define Bmain RA2;
#define RphaseLed RC0;
#define YphaseLed RC1;
#define BphaseLed RC2;
char RphaseFlag=0;
char YphaseFlag=0;
char BphaseFlag=0;
void main()
{
INTCON =0x00;
CMCON=0x07;
ANSEL=0x00;
TRISA=0b001111;
PORTA=0b001111;
TRISC=0b000000;
PORTC=0b000000; 
RphaseFlag=0;YphaseFlag=0;BphaseFlag=0;
while(1)
{
  if(Rmain ==1)
      RphaseFlag=1;
  
if(Ymain ==1)
      YphaseFlag=1;
 
if(Bmain ==1)
      BhaseFlag=1;
  
     if(RphaseFlag==1) RphaseLed=1;
 if(YphaseFlag==1) YphaseLed=1;
 if(BphaseFlag==1) BphaseLed=1;
}
}

its working good in only RA0 and RA1 but not working RA2 pin i think its comparator out put pin itd not detecting input AC voltage is there any other declaration please let me know...
I/O ports RA0/RA1/RA2 may be either digital or analog, as defined by the ANSEL register.
The CMCON register, on the other hand, has 8 operating modes, which ALSO define the analog or digital function of each port.
My problem is that if I don't use the comparator, what mode should I use?
For example, if I want RA0 & RA1 to be digital inputs, and RA2 analog input - what value should I put in CMCON
Sir how to detect these three phase inputs are same or different phase because i have given same phase voltages to RA0 and RA1 pins but its shows logic 1 otherwise is there any comparison config register these are same phase or different phase input voltages
 
Last edited by a moderator:

I repeat: Please post the schematic you are using so we can see which points you are checking voltages across.

This sounds like an electrical problem, not software or configuration but it is important first to establish whether you are measuring a "3-phase" network or a "3-phase and neutral" network. The method for measuring them is completely different but we don't know which you are using.

If you want to ensure the phase difference between them is 120 degrees, you need a time reference to work from, this would normally be one of the phases but until you can see a signal on all three inputs it would be pointless.

Brian.
 

sir RA0 & RA1 are not a schmitt trigger inputs but these are detected input connected phases but RA2 is a Schmitt trigger input. but i don't know how to declare /configure the pic16f676 microcontroller interrupts or any other register to detedt RA2 as a input but its comparotr output pin so please let me know..otherwise how to detect RA0, RA1 and RA2 connected phase are different are same phases please let me know the zero crossing, phase angle and power factor methods to detect the phase failure in three phases
 

At first glance, registers settings look correct.
Also, the code, simple as it is, should work.

If not physically interchanging either the A/C entries or LEDs you cannot determine if the problem is in hardware or logical, the next step from now on is to perform a functional simulation in software.
 

Sir , i am having a pic16f676 controller for detecting a analog input to RA0, RA1 & RA2 are connected to three analog AC inputs 50 hz frequenncy, three phase voltages 440 volts i reduced ac voltages by connecting series resistors. i just i want its i/p coming or not (yes/No) which phase phase failure /not...
 

Hi,

Do you need help? Then follow our guidelines.
I repeat: Please post the schematic you are using so we can see which points you are checking voltages across.

Your (repeated) textual description gives about no information. Without information we can´t help.
It only leads to guessing ... and long useless threads.


Klaus
 

Your last reply seemed like someone playing like a robot.
Unless being able to provide additional useful information, the thread will be closed.
 

I want measure 3 phase lines (Phase to Phase 380-440V) these three sine wave signals with same 50Hz frequency . zero crossing for these three lines like +ve as well as –ve half cycles. I want to measure phase shift between these three signals. phase angle i.e 0 degree for R phase , 120 degree for Y phase and 360 degree for B phase these three lines voltages reduced by resistors so i want measure particularly which phase failure or two phases are same and these three phase are different i.e for the purpose of 3 phase available , 2 phase available or single phase available so i want C code in MPlab in PIC 16F676 micro controller with internal 4 MHz oscillator.
 

you are repeatedly disregarding the answers and suggestions given so far.
As stated above, thread closed.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…