18x input 6 & 7

alexmills

New Member
Hey all, please excuse my lack of knowledge, everyone has to start somewhere :).

On my 18x chip I have a mechanical switches conected to inputs 1, 2 and 0. My program will check if these pins are high or low and do the specified routine. High is perfect 5v and low is 0v. If I try doing this on inputs 6 and 7, it works around 15% of the time. The program will detect if the pins are high but it has trouble with low. I measured the pin at low (with and without the switches connected) and it never reaches 0v. In fact when I put the volt meter on these pins it will start at around 60mv and continue to rise, I'm led to believe that this because it's designed to be used with a keyboard?

If this is so, is there a basic command other than if input 7 = 0 then... That will call the pin low if it's less than 4v?

I don't think the chip is faulty because eveything else works perfectly.

Cheers in Advance
Alex Mills
 

nickpatts

Member
i think im right in thinking its best to have your input held low or high with a resistor and not free floating.

page 25 of manual 3 gives a great circuit diagram of this in action
 

Dippy

Moderator
Sounds about right.

Please... if you have a query like this, remember, a little circuit sketch can clear up mot ambiguities. Honest, it can save us all a lot of time :)

PS. Look at page 26 re debounce too.
 

alexmills

New Member
Ah right, so simple I missed it :)

thanks for the quick replies guys, it's really very much appreciated!

Cheers
Alex
 

Dippy

Moderator
Alex, i've just re-read.

This is important to remember, Inputs 6 & 7 are Schottky inputs, Inputs 0, 1 & 2 are TTL.

This is to do with the hardware of the actual PIC chip.

They have different voltage 'thresholds' and therefore see On/Off (Hi/Low 1/0) at different voltage levels.

This crops up so often that it really should get a mention in the Manuals.....

This is an example from a different PIC Data Sheet, but I reckon the values will be similar.
 

Attachments

hippy

Ex-Staff (retired)
When used with a switch input, correctly wired, whether TTL or ST input is an irrelevancy. Miss the pull-up or pull-down out and it will likely be unpredictable behaviour in both cases.
 

BeanieBots

Moderator
is there a basic command other than if input 7 = 0 then... That will call the pin low if it's less than 4v?

No, there is nothing that can regard 4v as low because... quite simply 4v is HIGH.
If you REALLY need to test for <4v, then you will either need to use extra hardware or use an analogue input with readADC.

Things are a little more complex with ST type inputs because ~3.5v is the switching point from low to high but 1.5v for high to low. What a 4v input will do depends on what state it is already in.
 
Last edited:

Dippy

Moderator
Without a drawing neither of us know exactly how it is connected. Or do we?

And further confused by "High is perfect 5v and low is 0v." - apparently not???

I was merely highlighting a difference btween ST and TTL that may explain the behaviour.
(- Something that should get a mention in the Manauls, but probably never will ;) )

With one accurate drawing provided it would have needed just one single precise answer :)
 

BeanieBots

Moderator
I am quite sure this is a very simple case of missing off pull-down resistor, I simply gave a literal answer to a literal question.

As you say Dippy, a diagram would have had this cleared up with one reply.
 

hippy

Ex-Staff (retired)
My interpretation is that it was a missing resistor, acknowledged in post #4 in reply to post #2.

I agree, a diagram would have revealed the problem, but the "Have you got it wired correctly as the manual shows?", was a natural follow up to the initial post and seems to have resolved the problem just as quickly.
 
Top