# DC bias for AC measurement with an Arduino

I'm trying to make an AC and DC voltmeter with auto-ranging and auto-switch (between AC and DC.) The maximum input is 0~24VDC and -24V~24VAC. I've built a voltage divider with some optocouplers controlled by an Arduino so I can change with a proper algorithm between the ranges.

The problem now is: When I use AC I have negative voltages coming to the ADC input of Arduino, and this can't happen by obvious reasons. I've tried a couple of things to handle with this, like a positive bias. I'm struggling to create a useful bias so I'm asking your help now.

The voltage that I want to bias is regulated by the voltage divider so the range of AC voltage coming to Arduino is between -3.3V and +3.3V. I want to get the negative part of this input to positive, but I really don't know a proper method to do this.

The same with negative voltages, I want to be able to show a -24V to the user for example, just to clarify that the polarity is inverted.

I didn't get anything that works for this problem, so I'm not adding any circuits here. If there's any information missing please let me know.

• For AC measurements (and I'm completely ignoring the opto-aspect of your question), have you considered a series capacitor that goes to a voltage divider? Just as a simplifying view that may lead towards the actual solution you wind up with? Like what is done all the time with a simple CE BJT amplifier stage in classroom lessons? (You can also easily sum voltages with opamps and feedback and you can use bridge rectifiers, too.) What are your precision and accuracy specifications -- which you get to set -- for your ac and dc voltmeter? Have you opened up a simple voltmeter before?
– jonk
Commented Sep 1, 2021 at 21:16

Since you are not responding, I'll only offer a very simple concept that accepts both DC and AC. It provides a very simple answer to your question:

The max input is 0~24Vdc and -24V~24Vac. [...] The voltage that I want to bias is regulated by the voltage divider so the range of AC voltage coming to Arduino is between -3.3V and +3.3V. I want to get the negative part of this input to positive, but I really don't know a proper method to do this.

The following is mostly just a bridge rectifier, except that instead of diodes it uses BJTs (which can get a little closer to ideal than simple diodes may.)

Keep in mind that this does NOT take into account any reading of the datasheet information regarding your ADC. In fact, I'm almost certain that the following conceptual idea won't work well with your ADC. The source impedance needed by your ADC is probably much lower. (So it should be buffered or else the resistor values should be substantially reduced in magnitude.) Also, given the large resistor values it may be okay only up to $$\600\:\text{Hz}\$$ but not much beyond that (unless you get specialized BJTs or else change out the resistor values for smaller values.)

The only reason I'm offering it is because it's simple to understand why it works (it's just a bridge and a voltage divider.)

simulate this circuit – Schematic created using CircuitLab

There's also no opto-isolation here. Also, note that although I've labeled the leads as AC 1 and AC 2, they also work with DC input and you don't have to worry about polarity. That said, the above also won't work at all between $$\-650\:\text{mV}\$$ and $$\+650\:\text{mV}\$$ and will have some significant error until you reach a magnitude somewhat greater than a volt, or so. See this opamp full wave precision rectifier example for something a little better.

I can't tell you what's missing. Only you know what you want to achieve. But some suggestions might include the allowable input impedance (resistance and capacitance) of your voltmeter, if you will be wanting different ranges supported, the accuracy and precision of each range, frequency range and responses, and the operating temperature range over which all of the above is to be met, to name some thoughts.

The point of this exercise is to get you to think closely about and then discuss more details of what you hope to achieve. I'll delete this answer the moment you've provided better detail and others have decided to write a good answer for you.