2024-04-24 02:05 AM
Hi,
I'm designing a PCB that can get 8 digital inputs and 4 analog inputs. But these inputs can be range from 3.3v to 24v. For the digital inputs I have used universal logic shifter method using comparator where I can give any voltage range of digital inputs and I get 3.3v digital output for the stm32 controller. Likewise, is there any method to get analog inputs with that flexibility. I have tried op amp with attenuating method but each time I have to change the resistor values according to the voltage I'm giving. Is there a method to get analog inputs to stm32 ADC pin with the flexibility to use 0-24V voltage range analog inputs without changing any hardware like the digital input circuit?
2024-04-25 03:25 AM - edited 2024-04-25 03:59 AM
@jsw2000 wrote:For the digital inputs I have used universal logic shifter method using comparator[...]
First off all I would not use a simple comparator as a digital input. I would use a Schmitt trigger, which is a comparator with hysteresis. You can select a fixed threshold, but it might be better to give each comparator 2 selectable ranges. You can use mosfets to switch in different resistors in your circuit in software.
@jsw2000 wrote:I have tried op amp with attenuating method but each time I have to change the resistor values according to the voltage I'm giving. Is there a method to get analog inputs to stm32 ADC pin with the flexibility to use 0-24V voltage range analog inputs without changing any hardware like the digital input circuit?
I don't know what you mean by "without changing any hardware", but you need some circuit between your input and your ADC pin. You can make it universal so it supports multiple ranges without changing components your board.
Just use an attenuation circuit where you switch voltage divider resistors using mosfets. Sometimes the ADC itself has selectable ranges. Otherwise use the maximum range and just accept you will have a lower resolution for smaller input signals.
2024-04-26 07:46 AM
@jsw2000 wrote:I have tried op amp with attenuating method but each time I have to change the resistor values according to the voltage I'm giving.
Use a digital potentiometer ?
2024-04-26 10:17 AM - edited 2024-04-29 01:22 AM
A digital potentiometer seems overkill to switch between a few ranges to save about 2 bits in otherwise lost ADC precision. With 2 mosfets and a few precision resistors you can select 4 ranges with a voltage divider.
2024-04-26 02:31 PM
"Universal" solution is an Instrumentation amplifier. It does all work, voltage level translation /conversion and amplification. There are IC with integrated PGA - programmable gain amps, effectively extending adc bits resolution up on 7-8 bits. PGA280 as an example.