| Author |
Message |
khanna_gunjan
Joined: 18 Jul 2006 Posts: 27 Helped: 2
|
07 Aug 2006 10:40 auto Detection of the devices on the microcontroller |
|
|
|
|
Hello All,
I am working on a project where we need to detect automatically if there is any sensor conected to the Analog or digital Input ports of the microcontroller. (like Plug and Play devices). The voltage for the digital Input is 5V and it is normally high, when no input is there or if the contact for the device is open. And for the analog port the input range is 4 to 20 mA current.
Does anzone has a idea how this can be achived so that if the user conects something on this port it is detected automatically.
Thanks in advance.
|
|
| Back to top |
|
 |
VVV
Joined: 26 Nov 2004 Posts: 1514 Helped: 280
|
09 Aug 2006 23:49 Re: auto Detection of the devices on the microcontroller |
|
|
|
|
For the analog signals, it is easy: the 4-20mA range actually was designed especially to allow you to distinguish a loss of signal from a zero signal. Therefore, if you measure something that is much less than 4mA, you know there is no sensor present (or the wires are broken or shorted).
For the digital signals you are describing, things are not so easy. The only way I can think of is to use an additional connection on the connector, a pin which would be pulled either high or low only when the connector is plugged in. Not a very elegant solution, and possibly not feasible, since it requires doubling the number of inputs.
|
|
| Back to top |
|
 |
aland
Joined: 09 Sep 2006 Posts: 15
|
10 Sep 2006 3:57 Re: auto Detection of the devices on the microcontroller |
|
|
|
|
As VVV says puting your 4-20mA across a 250Ω resistor wil give you 1 to 5 V, anything less than say .5V means not connected.
The Digital signal has several solutions depending on whether its a data stream or a digital on/off signal, and whether you wish to add more hardware or software.
Because your still in the project phase Id look at either the spare input if you can, or converting the digital signal to a four state analog (Open circuit, High, Low, Short circuit) - if its *not* a data stream and you have a spare analog input.
I've used this on some 2 wire remote sensors when I needed to know the circuit is operational.
|
|
| Back to top |
|
 |