24 optocoupled input to 5V micro debounced - Page 1
Forum section: electronics / projects

author: hozone
author_rank: Regular Contributor
timestamp: April 03, 2019, 08:48:38 pm
content: Hi all,I'm here to ask you an help for a circuit I'm building. I'm an IT guy, with the passion for electronic, so I'm more on the embedded side rather then the analog.I'm building a board to drive a machine. This machine has buttons and inductive proximity sensors, all powered at 24V. My board has to read that sensors.For most of them I will use software debounce, but for 2 proximity sensor I'd rather use hardware debounce.At first I was thinking about an RC filter, but I've notice something "strange" to my eyes doing experiments.Please find the attached images. One is the sample circuit I've build. The other the output catched with my 50MHz oscilloscope while pressing the button. 2 channels are connected, one to the 24V side, the other to the 5V side.The snapshot is taken pressing the momentary button - not a particular one, just one I've around, I mean that I've not choose one with a bad debounce behavior. The optocoupler is a cheapy PC817C.I thought that even on the 5V side I get the "debouncy" curve, but it seems it was not so!This are my question:1)Does anyone can explain this to me?2)If i use this circuit, do I also need RC filter? It seems to me that i don't.3)Are debounce needed for inductive proximity sensors?Hope I was clear enough.Thank you all!

author: jackbob
author_rank: Regular Contributor
timestamp: April 03, 2019, 10:14:44 pm
content: The operation you see on your scope seems perfectly normal. Let me explain what is going on in the scope waveform. Your input, the yellow trace is bouncing when you push the button. This can clearly be seen in the unstable random pulsing behavior on the yellow waveform. Meanwhile, the output blue trace remains stable at a high value then slopes down to a low value. The output is pulled high by the pull-up resistor and is pulled down by the transistor when you push the button. The output does not change with the bouncing pulses at the input because the optocoupler takes time to respond and does not react fast enough. Optocouplers are not the fastest switching devices, particularly cheap ones not made for fast switching. When the button input pulse becomes stable for long enough, the optocoupler transistor turns on and pulls the output low. This looks to be a downward slope because the optocoupler has a rise time it takes to transition. According to the datasheet for the optocoupler you mentioned, it is anywhere from 4us to 18us for the rise time. If you look at the time scale we are looking at 500ns per division and I would say this rise time seems to be within the specification listed on the datasheet.Yes, in a way the delay of the optocoupler is acting as a rudimentary debouncer on its own, whether this delay is enough or reliable every time need some experimenting to see how much margin you have. An additional RC delay could add extra margin if you need it, however, it seems here it may not be needed.As far as inductive proximity sensors, usually sensors have debouncing circuitry built in them, what sensor are you using?

author: hozone
author_rank: Regular Contributor
timestamp: April 04, 2019, 02:54:09 pm
content: Thank you @jackbob, keypoint (that I completely miss) is "the optocoupler takes time to respond and does not react fast enough", like 4..18us.Machine I'm working with uses E2A Omron series proximity sensors, most of the new one are e2a-m12ks04-wp-b1.The machine I'm talking about are wrapping machine, so they also have an inductive 220V AC motor.Said this, do you think I also need RC? Maybe for voltage spikes due to interference? I've not notices in my experiments spikes.