Continue to Site

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.

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

Need help with a simple logic switch...

Status
Not open for further replies.
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...
 
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:
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)

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
 
I believe that Port A is all Schmitt Trigger. The microchip switching levels are 0.2 and 0.8 x VDD .

Have you considered putting a relatively high value resistor (10 k to 50 k) in parallel with the diode or diode/resistor. That will ensure a positive pull-down without the diode drop without greatly affecting the on current available..

John
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.
 
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
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top