Page 1 of 1

Multi voltage input with custom level detection

Posted: Thu Jun 27, 2019 6:27 pm
by touro1981
Hello,

I'm try to made a system with some custom requirements for the inputs but my solutions needs too many components, are expensive or don't adjust to all my requirements.

Let me explain what are the custom requirements for the inputs:
I need minimun 12 digital inputs but every input needs to be detected as LOW if the voltage are lower than 10V and detected as HIGH when the voltage is higher than this value.
I need that every input support 40v maximum and can work on very noise environment.
The output must be 3,3v to be connected on a ESP32 input.

After many days of searching I found the HVS882, a 8 digital input serializer from TI. Yes, the voltage levels have some differences but I'm flexible in this point. This component have 5v outputs and I need 3,3v for my ESP32, so I need a level shifter from 5v to 3,3v. The inputs don't support schmitt trigger and maybe in a very noise environment can be insufficient. The same for the debounce time, 3ms for a noise environment I don't know if will work well. I cannot buy this component in my country and if I buy it from Internet it will be very expensive to me.

I tried this solution but I think it's very clumsy:
Sch.png
Sch.png (11.81 KiB) Viewed 6984 times
The 10v Zenner in serial is used to detect the LOW and the HIGH level. When the input is more than 10,7v, the Q1 saturates and the RC circuit (R2 + C1) do a simple debounce with a schmitt trigger inverter. It's simple, it's cheap, but I don't know if is the best solution for the problem. Opinions?

Analog inputs I think that is not a option.

Do you have any idea that can help me?

Any help will be welcome. Thanks.

Re: Multi voltage input with custom level detection

Posted: Fri Jun 28, 2019 4:44 am
by ESP_Sprite
How critical is the 10V threshold? If the signal is pretty digital in nature (0V when low, 40V when high) you may be able to get away with something simple as a resistive divider and software debouncing. Although, depending on the industrial-ness of the thing, you may want to go for opto-isolated inputs, to make sure your circuit doesn't blow when you get some weird high voltage on the input lines.

Re: Multi voltage input with custom level detection

Posted: Fri Jun 28, 2019 11:48 am
by touro1981
Hello ESP_Sprite,

The threshold it's critical because it very old machinery with floating GND, large wires and a lot of noise. Having a perfect 0v in this environment is very hard.

Many thanks for your reply.

Re: Multi voltage input with custom level detection

Posted: Sat Jun 29, 2019 2:01 am
by ESP_Sprite
Ah, that's not what I was asking, I can imagine you have a few volts of jitter. The issue is that the ESP32 sees a guaranteed low at anything below 0.8V, and a guaranteed high at anything above 2.5V. If you use a series resistor to scale the 40V down to 3.3V, this would translate to a 0 for anything below 10V and an 1 for anything above 30V. So you wouldn't have the exact threshold at 10V anymore, but there's still a fair amount of noise resistance before the ESP32 detects an 1.

Re: Multi voltage input with custom level detection

Posted: Wed Jul 03, 2019 5:52 pm
by touro1981
First of all, thanks for your quick responses and dedication to this post.

Maybe I don't understand well your point of view. Sorry if is the case.

If I use a voltage divider to get 3.3v when the input have 40v (my max), to get a guaranteed high I need something higher 30v and to get a guaranteed low I need something lower than 10v. This is not valid to me.

You:
LOW: 0v -> 10V (< 0,8v on ESP32)
HIGH: 30v -> 40v (> 2,5v on ESP32)

I need:
LOW: 0v -> 10V
HIGH: 10v -> 40v

If schmitt trigger applied (values as a example):
LOW: 0v -> 8V
HIGH: 12v -> 40v


Voltage Divider used:
R1 -> 100KR
R2 -> 9KR
Factor: 0,08257

Thanks in advance.

Re: Multi voltage input with custom level detection

Posted: Mon Aug 05, 2019 10:35 pm
by Tranzmetro
Are you not able to do this in software on the esp32? Using your scaled down voltage, if the input is below reading*the multiplier * lower threshold treat it as 0 and if it above reading*the multiplier * higher threshold treat it as 1. Using a resistor divider and calculating it in software is much easier.