so if......
cyplesma
Posts: 76
I have pins 0-7 set to be inputs
If I put a 5 volt (through the pullup resistor as noted on page 76 of the "What's a Microcontroller book) on any of these pins then I get a one back on all of them.
is the inputs on the stamp fried.
if i set one up as an output then just that pin goes high not the rest.
If I put a 5 volt (through the pullup resistor as noted on page 76 of the "What's a Microcontroller book) on any of these pins then I get a one back on all of them.
is the inputs on the stamp fried.
if i set one up as an output then just that pin goes high not the rest.
Comments
When input pins are not being driven or pulled HIGH/LOW they are floating and are easily influenced by the signals around them. Floating lines are not reliable to read so you should just read the lines you’re connected to unless you plan to pull-up/down the remaining lines. Take care.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
That's why on reset all pins are assigned as inputs -- that's the safe default value. And yes, you as a programmer need to learn that "reading an unassigned input" gives you garbage -- but that's MUCH better than accidentally burning out a pin.
I'm trying to use pins 0-7
I would like to use pins 2,3,5 as outputs or is intermixing pins like this a problem.
If I set say pin 1 to 4vdc then I get a reading of 11111111 when I do the INL statement
' 7, 6, 5, 4, 3, 2, 1, 0
' o, o, i, o, i, i, o, o
'
So, your input should be like: MyVal = INL & %00101100
If you really don't have anything tied to pins 5,3, and 2, then they're "unused", and you can't depend on the value you read from them.
So no, intermixing pins like this is not a problem, and if you DID have something tied to 5,3,2 you'd read that value, not the output value from pin 4.
pins 5,3,2 are outputs, I turn them one one at a time.
when 2 is on 5,3 are off.
I then read all 7
I get "100" which is good.
I then place 4vdc on pin 1
I get "11111111" with pull up resistors which is not good. I should only get "110", right?
I have tried it with pull down resistors (which gives me "100" constantly)
As for the question about making unused pins output…there are two schools of though on this. One is that the unused pins should be made outputs and set low. This is fine as long as you don’t connect an input device. Of course, catastrophes can happen in accidentally connecting an output pin if you change your hardware before changing your program too so I don’t see an issue with this. Just be careful and know those pins are outputs.
The other school of thought says the pins should be weakly pulled-up or down. This is fine as well. You can get SIP resistor networks that are bussed and make it very easy to add pull-ups/downs to eight pins at once. Of course, you should really be reading a pin not connected to anything, but on the other hand oscillating open input pins can cause the microcontroller to use slightly more current when running. I hope this helps. Take care.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
In a working circuit if·certain·pins are not going to be used period then what's wrong with saving on component count and extra circuitry by assigning them as outputs?
It's a foolish person that alters the software without checking what implications it has on the hardware connected or indeed leaving the hardware connected up or not altering it accordingly when changing the code
What's confusing is that cyplesma first states that 0-7 are inputs then later states 5,3,2 are outputs? Maybe this is where things have gone wrong and they should be assigned outputs from the start that get turned on or off dependant of the state on pin 1?
·
similar to a key matrix, but I was trying to do it without the RC circuit.
I have 3 sets of 5 switches.
granted the pin layout could be less confusing (for program, not for the wiring), but...
I only have one bank of switches active at a time. So I figured I could just send a 1 from an output (pin 2) to it's 5 switches and collect the switch pressed by reading the INL but maybe I just need to read the IN bits instead. I was saving the value of INL to a byte and sending that to the debug window to verify that I have the switches wired the way I want them, but I get "11111111" on all 8 bits. when I press a switch.
if I don't have a switch pressed, I get "00000100" which tells me the switches for pin 2 are active.
Post Edited (cyplesma) : 9/12/2007 5:18:16 PM GMT
Am I right in thinking·the problem is as stated before by mixing inputs and outputs together and then trying to read the·pin values with an INL you are trying to read·states of·a low byte of pins of which some have been assigned as outputs therefore isn't this confusing the outcome?
It must be better to seperate the inputs from outputs then you can read them without confusion.
Post Edited (skylight) : 9/12/2007 5:35:16 PM GMT
when I did this the first time a few months back I didn't notice if the other pins were doing anything or not I got the "1" when I wanted it too and didn't bother to check the other pins.
but now that I have a need to check/use the pins this is when I find out what is happening.
Now I do have my own resistor pack. I wired it up on a perf board it's basically 8 resistor networks where all the 10K resistors are tied to a common lead that can be plugged into vss or vdd and the connection between the resistors are connected by a wire that can be plugged into the breadboard, same for the other end of the 220 resistor. FYI: I also have a switch and a pot soldered onto this board, their pins connect to individual wires as well does not connect to the resistor network.
but using just 5 of these PU/PD networks (for the 5 inputs) I either get 1.04v or when I get the 4.5v all the pins go high when I press any switch of the activated bank of switches.