cancel
Showing results for 
Search instead for 
Did you mean: 

How to design universal analog input circuit

jsw2000
Associate II

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?

 

jsw2000_0-1713949440598.png

 

4 REPLIES 4

@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.

Kudo posts if you have the same problem and kudo replies if the solution works.
Click "Accept as Solution" if a reply solved your problem. If no solution was posted please answer with your own.
Andrew Neil
Evangelist III

@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 ?

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.

Kudo posts if you have the same problem and kudo replies if the solution works.
Click "Accept as Solution" if a reply solved your problem. If no solution was posted please answer with your own.
MasterT
Lead

"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.