I am using my Microcontroller to read a status of digital input, but when I put long wire to read the status, my MC can not read a clear value, sometimes it ON and sometimes it is OFF, when I measure the value by the oscilloscope, I can see a square wave from 0V to 2.5V, with 60 HZ.
Help me guys to eliminate this? (You can see the design in the attachment)
I am using my Microcontroller to read a status of digital input, but when I put long wire to read the status, my MC can not read a clear value, sometimes it ON and sometimes it is OFF, when I measure the value by the oscilloscope, I can see a square wave from 0V to 2.5V, with 60 HZ.
Help me guys to eliminate this? (You can see the design in the attachment)
I am using my Microcontroller to read a status of digital input, but when I put long wire to read the status, my MC can not read a clear value, sometimes it ON and sometimes it is OFF, when I measure the value by the oscilloscope, I can see a square wave from 0V to 2.5V, with 60 HZ.
Help me guys to eliminate this? (You can see the design in the attachment)
why not use an opto isolator and the transistor would be on the Microcontroler as emitter follower. the LED and additional resistor can be on the Diode path of opto coupler.
Problem is that you will still have losses in wire and induced noise on a single wire. Differential pair is best way to overcome noise induced into the wire. Single wire transmission has inherent problems, and other modes of long distance signal transmission must be used, eg. RS422.
Problem is that you will still have losses in wire and induced noise on a single wire. Differential pair is best way to overcome noise induced into the wire. Single wire transmission has inherent problems, and other modes of long distance signal transmission must be used, eg. RS422.
Opto sees a lower impedance and the noise won't be there.
I had an occasion to solve such problem, where an FET's gate was facing 5.5KM of Underground cable and was never working. after inclusion of Opto with 10mAs current , the issue was sorted and around 50 such telecom signaling circuits were stablized, Mikebits.
Thank you guys for these answers, I posted it only three hours ago, and I got all these replies, I really appreciate it.
Leftyretro:
I will do what you suggested in your post, but the problem is where the square wave comes from?
House0Fwax
The wire is 3 to 5 meters long, and no I did not use shielded wire. I will use the a shielded wire, and I hope it solve the problem.
Mikebits
RS422 is used for serial communication, I am not sending any data. It is just like any DIP switch in any board, the difference is that the DIP switch is 5 meters far from the board.
mvs sarma
I could not visualize your design, could you please draw it and post here.
Nigel Goodwin
This design is found in most of the boards with DIP switches, and if you think this is bad!!, please let me know any better design.
Check my tutorials - you're feeding a long wire directly into a high impedance CMOS input - this is just asking for disaster.
As already suggested, a simple pull-down resistor should be used in all cases, or preferably a pull-up resistor, with the switch pulling the input low instead of high - that's the more normal way of doing it (there are various advantages in doing it that way).
I put a pull down resistor, but there was still some little sparks, but when I put 100nF across the resistor, all the sparks are gone and I have a clean signal.