1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

Need help with a simple logic switch...

Discussion in 'Microcontrollers' started by EvilGenius, Aug 13, 2017.

  1. EvilGenius

    EvilGenius Member

    Joined:
    Jan 8, 2008
    Messages:
    323
    Likes:
    6
    Location:
    Florida
    Hi Mike
    In your code you wrote:
    btfsc swnew,0 ; RA0 on? no, skip, else |00
    call off_mode ; |00

    btfsc swnew,1 ; RA1 on? no, skip, else |00
    call man_mode ; |00

    btfsc swnew,2 ; RA2 on? no, skip, else |00
    call auto_mode ; |00

    goto loop ; |00
    ----------
    Don't we want to Test for High and Branch out on LOW?
    btfss .....
    call Off_Mode


    Edit: for common anode configuration that is...
     
  2. Mike - K8LH

    Mike - K8LH Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    3,637
    Likes:
    109
    Location:
    Michigan, USA
    Hi Rom.

    Hope you and family are well, Sir.

    I apologize for my fancy example. I just threw it together quickly to test the "active low switch/active high LED" circuitry.

    May I ask what your Off_Mode, Man_Mode, and Auto_Mode sub-routines do, please?

    Cheerful regards, Mike McLaren (Michigan, USA)
     
    Last edited: Aug 15, 2017
  3. EvilGenius

    EvilGenius Member

    Joined:
    Jan 8, 2008
    Messages:
    323
    Likes:
    6
    Location:
    Florida
    Hi Mike
    Family and I are fine. Thank you for asking. Hope all is well with you.
    All 3 modes implement a specific sequence of ON, OFF, and Flashing of LED's on PORTB (all Outputs).
    Man_Mode and Aut_Mode also utilize PORTA: 6,7 for Outputs, and A0-3 as Inputs for Switch reads with LED attached. In this case Common Anode configuration if the logic works.
    1 Switch is sliding 3 position:SP3T
    And the other Switch is sliding 2 Position: SPDT (On/Off)

    Regards,
    Rom
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. EvilGenius

    EvilGenius Member

    Joined:
    Jan 8, 2008
    Messages:
    323
    Likes:
    6
    Location:
    Florida

    I think I am going to try your suggestion before tearing my proto board apart. It is rather simple add-on fix. If I get logic zero in common cathode, I am good to go. Thanks John.
    I will post again once I had a chance to test it.
     
  6. EvilGenius

    EvilGenius Member

    Joined:
    Jan 8, 2008
    Messages:
    323
    Likes:
    6
    Location:
    Florida
    Success. I added 3, 10k resistors between each pic port and ground in the common cathode configuration. No problems.
    It works perfectly. In this manner, I don't need to modify my pcb much. I just add a 5pin resistor network bus to ground (in parallel to LED's) and I am good to go. I also added a 20ms delay code in my SW-Test routine to avoid any possible switch bouncing. Thanks everyone for your assist as always.
    Cheers, Rom
     

Share This Page