I have some kind of inputs that their states change periodically from these three states:
HIGH , LOW and OPEN
How can I recognize the input when it is in OPEN state?
I have some kind of inputs that their states change periodically from these three states:
HIGH , LOW and OPEN
How can I recognize the input when it is in OPEN state?
You have a floating pin by design? That's not something you should be doing.
But if you insist, you could try checking multiple times and if it changes erratically between high and low, you might assume it's floating. But you can't be sure.
What you should do is at least use an analog pin and have a double voltage divider that brings the value to something known when neither high nor low is present.
How can I recognize the input when it is in OPEN state?
There's no way to reliably do that.
When you read a digital input it will either read high or low... That's what "digital" means. If you enable the internal pull-up resistor on the Arduino, an open input will read high. Otherwise it might read high or low.
You could connect an analog input to check if you have a valid-high voltage or a valid-low voltage, or something in-between.* If it's in-between, the digital state will still read high or low, but it's undefined and unreliable. But, if analog voltage indicates a valid-high or valid low, the input could still be open-floating.
Below 1.5V is defined as low
Above 3V is defined as high
Anything in-between us undefined and may read high or low.
What is defining the states HIGH, LOW and OPEN?
If it is the 3-state output of another device, then that can be read using an Arduino analog input connected to a voltage divider (say, two 10K resistors) between Vcc and GND. The 3-state output will then define 3 voltages that can easily be distinguished.
The way to do this is to have a pull up and pull down resistor, say 10K. Then use an analogue input with an analogue read.
For LOW you will get 0 or something very low. For HIGH you will get something over 1000 and for open you will get around 512.
JohnLincoln:
You could connect your input through a high value resistor to another digital pin set to be an output.
Then if you toggle the output between high and low and check to see if the input follows it.If you can change the state of the input, then it is floating, if you can't then it will be being held high/low by the external circuit
Thanks, Seems this method and the methods dear Grumpy_Mike and Jremington offered are more practical in my project.
'Course it would make quite a lot more sense to explain just what these "floating inputs" actually are.
I explain the case.
There are 19 7-Segments and 9 pointer LEDs on a digital scale, which their ON and OFF state are controlled by 30 inputs, Some 5v and others GND.
The numbers that are shown on LEDs should be read by Arduino Mega 2560.
The number of total LEDs that are individually used is 153.
The 5V and GND lines are sometimes OPEN.
Each individual LED is ON when its GND and 5v wire is connected, for example wire 4 as GND and wire 28 as 5v.
Total LEDs are shown almost 50 times per a second.
So if I know which wires are 5v and GND in a period of time then numbers could be calculated.
These images show further details.
Right.
So you do not need in fact to distinguish three states on each input, only two.
For the cathodes, you need to distinguish between pulled LOW, and open - essentially defaulting HIGH.
Correspondingly for the anodes, you need to distinguish between pulled HIGH, and open - esentially defaulting LOW.
For the cathodes, you could use the INPUT_PULLUP function in the Arduino, and use 10k pull-downs for the anodes.
Your big problem will be in synchronising the reading of the inputs to the multiplexing.
Also, you will need to check the voltages actually applied to the LED displays, with a CRO, to determine whether you can simply connect the Arduino inputs, or need further interface components..
If you're trying to monitor the display status, then why not use the signals on the control side of the display driver? On the output side of the display driver, there could be some inherent ghosting issues, crosstalk and signal integrity issues making it impossible to reliably decode.
If for example, the display driver is the MAX7219, then there would only be 3 wires to monitor ... MOSI, CS and SCK.
Good idea.
There is a max202cdw IC on the main board of the scale. Is it the display driver?
And if it is, is it possible to read the output of an IC when it is working on a board?
Googled max202:
Overview: The MAX200–MAX209/MAX211/MAX213 transceivers are designed for RS-232 and V.28 communication interfaces where ±12V supplies are not ...
Nope, its not a display driver.
Do you have an oscilloscope? (If not - DSO Nano oscilloscope from ebay is a quite a decent little thing)
moham14:
Good idea.
There is a max202cdw IC on the main board of the scale. Is it the display driver?
No, unfortunately it is the W78E516xxx (can't quite read it all) custom microcontroller that is driving the display via all those transistors.
moham14:
And if it is, is it possible to read the output of an IC when it is working on a board?
Yes, but you need to be fast enough.
Now you said this was a digital scale. I gather that the MAX202 is the interface for the cable from the actual weighbridge part to this display. You would probably be better off decoding the serial datastream at that point, though you would have to figure out the format and the calibration.
If the display is driven directly from this MCU, please disregard my reply#11. Decoding the display signals could still be an option.