How would one detect if a line is tristate or floating without a status line?
One can easily tell if a line is high or low, simply by reading it, but what if the line is in tristate? What about floating?
One technique i was thinking of was connecting an io pin to the line in series with a resistor, and apply a voltage. If the line changes with the input, then it is tristate/floating. if the line does not change, then it is being held in a state. So basically a configurable pull up/down resistor. Would this work? I don't see why it wouldn't, however i really don't see it being the "right" way to do things
Place two large (say 100K ohm) resistors in series between the +5V and ground. Connect the junction of the resistors to the tri-state output. If the output is in the tri-state mode, then the output will be about +2.5V. Otherwise the output will be high or low depending upon its output logic level.
This app note shows how it's done mostly in software. Excellent article and could apply to any microcontroller.
**broken link removed** **broken link removed** https://en.wikipedia.org/wiki/Voja_Antonić
Place two large (say 100K ohm) resistors in series between the +5V and ground. Connect the junction of the resistors to the tri-state output. If the output is in the tri-state mode, then the output will be about +2.5V. Otherwise the output will be high or low depending upon its output logic level.
As the day progressed i began to wonder about this technique as well. I think this will be the first thing i will try, If it works i'm going to have to find a way to easily read 28 analog inputs
One technique i was thinking of was connecting an io pin to the line in series with a resistor, and apply a voltage. If the line changes with the input, then it is tristate/floating. if the line does not change, then it is being held in a state.
You are nearly there. You just need to add an extra capacitor of about 47pF to ground at the junction of the resistor and the line to be detected.
What you do is to see if the capacitor can "keep the voltage" you have assigned to it. If it does, the line is floating. If it doesn't, the line is not floating.
You do it like this. The I/O pin is in input mode to start with.
1. If you read the pin as logic LOW, change I/O pin mode into output and applies a HIGH. Wait a few instruction cycles.
2. Change the pin mode back into input and READ the logic state. If it is HIGH, the line is floating.
3. If read level in (1) above is HIGH, change pin mode into output and apply a LOW. Wait a few instruction cycles.
4. Change back into input mode and read the logic level. If it is LOW, the line is floating.
A while back I made a 8bit wide 2x5 to 1x10 for connecting a ribbon cable from a target board to a solderless BB. It has red and green LEDs to tell the state of the line. The LEDs were driven by a 74HC245 so as not to load the line.
I want to build one that would indicated a floating line. Eric has told us how.
Place two large (say 100K ohm) resistors in series between the +5V and ground. Connect the junction of the resistors to the tri-state output. If the output is in the tri-state mode, then the output will be about +2.5V. Otherwise the output will be high or low depending upon its output logic level.
You are nearly there. You just need to add an extra capacitor of about 47pF to ground at the junction of the resistor and the line to be detected.
What you do is to see if the capacitor can "keep the voltage" you have assigned to it. If it does, the line is floating. If it doesn't, the line is not floating.
You do it like this. The I/O pin is in input mode to start with.
1. If you read the pin as logic LOW, change I/O pin mode into output and applies a HIGH. Wait a few instruction cycles.
2. Change the pin mode back into input and READ the logic state. If it is HIGH, the line is floating.
3. If read level in (1) above is HIGH, change pin mode into output and apply a LOW. Wait a few instruction cycles.
4. Change back into input mode and read the logic level. If it is LOW, the line is floating.
A while back I made a 8bit wide 2x5 to 1x10 for connecting a ribbon cable from a target board to a solderless BB. It has red and green LEDs to tell the state of the line. The LEDs were driven by a 74HC245 so as not to load the line.
I want to build one that would indicated a floating line. Eric has told us how.
I think this is the technique i will use. I need to be able to read analogue anyway, so this technique will save on parts, and make the system much simpler.
Yeah! Sorry about that! I understand it now. I think this may be what i will do. But won't that capacitor distort the signal? Say if the input signal isn't a status line, it is a data line or something similar, and is changing very rapidly? Also, how fast would this method be? I need to be able to read these lines very fast. No slower than 2MHz.