EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / controller for detecting a digital input to RA0, RA1 & RA2

controller for detecting a digital input to RA0, RA1 & RA2

|

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.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • June 15, 2016 at 1:24 pm #4488
    Dhananjaya
    Participant

    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…

     

    #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 CMCON

    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…

    June 26, 2016 at 7:28 am #14003
    Prabakaran P M
    Participant

    If 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.

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • AI algorithm for bots April 17, 2026
  • SDCC Array Access In Timer 0 Interrupt Handler April 16, 2026
  • EasyEda program has a major bug April 16, 2026
  • ANOTHER OLD PROJECT REDO April 16, 2026
  • How to set the OSCAL in a PIC 12F675 April 16, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise