Resistors + zener diodes can be compact, but are not suitable for varying voltages.
Transistors are the same
Voltage Regulator can maybe work, but that would be kinda wasteful and require caps to smooth out the output.
Measuring 5 to 30V dc is easy to do with resistors. You can design the voltage dividers to source 200 uA to the ADC for analog input measurements, but you only have 6 analog inputs. How many inputs do you want ? If all you care about is reading digital HIGH/LOW then opto isolators would be a good solution, although voltage dividers will still work with digital inputs if it designed to source 1 mA to the input.
to be universal use optocoupler to keep strange gnd out.
the diode in the coupler will need 10 mA to light up.
you can use a current limiter with a transistor in the diode line, a zener is also possible howwever it needs to be able to run 60 mA
Resistors and diodes. 47k resistor - current at 30V limited to 550 µA, is within the specified tolerance of the on-chip protective diodes, but add a 1N914/ 1N4148 diode to Vcc (and perhaps to ground as well to protect against negative voltages) as well.
Thanks! I hooked the above circuit and the output was 5.68v at 20v (as high as my current psu will go) Any chance of that damaging the chip? How would I work out what the voltage would be at 30v?
For the products I have designed I have implemented both opto-isolated and non isolated inputs designed to work across 5 - 24VDC. 5 - 30 should be not problem as well.
For the opto's I like the MOCD223M. It is a darlington output so not very fast but it works across a large range of currents and has a very high transfer ratio so that and a resistor is all that is needed to limit input current across the full voltage range. And it comes in DIP package for prototyping.
For non isolated inputs I use a voltage divider/zener design. The resistor divider should be specified so that 5V still triggers a high on the input and the input resistor limits current to a 4.7V zener. If this feeds a LVC family buffer chip the result is very robust and protects the Arduino, and can be used for either 3.3 or 5V chips.
A capacitor/schmit trigger combination works well if you are feeding interrupts and noise is an issue.
These are networked I/O devices for use in laboratories. Low is about 1V.
Often the equipment we interface with is powered by 24VDC. Some manufacturers use PNP logic and some use NPN logic on the digital interfaces. We used to ship devices that expected 5V input but we have found more than a few customers using 24V SS relays to invert the signal logic, where required, and rather than adding a 5VDC supply for the output signal they instead use some combination of 24VDC and resistors with varying degrees of success or (catastrophic) failure. Rather than try to educate them, or argue about replacement costs I just implemented an input that is 24V tolerant and treats anything over 1V as high.
I come across lots of motion controlers and automation devices that are 30V tolerant so I don't think we are alone in this. The cost of a few components compared to trying to diagnose the problem or a service call....