Microcontroller › PIC › controller for detecting a digital input to RA0, RA1 & RA2
- This topic has 1 reply, 2 voices, and was last updated 9 years, 9 months ago by
Prabakaran P M.
-
AuthorPosts
-
June 15, 2016 at 1:24 pm #4488
Dhananjaya
ParticipantHi 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…#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 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 digital how to 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 and RA2 to be digital inputs, – what value should I put in CMCONHi 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…June 26, 2016 at 7:28 am #14003Prabakaran P M
ParticipantIf your aim is to check the input only, you can use transformer less AC to DC circuit and then a optocoupler to detect the input.
-
AuthorPosts
- You must be logged in to reply to this topic.