# Arduino high voltage analog out

I am looking for the best way to provide an analog output from an Arduino to control the blend and mode doors in my truck's HVAC system.

They both take a straight "12V" signal from the control unit ("12V" because it is more like 12-14V depending on whether or not the truck is running.)

The control unit uses a simple 10k potentiometer for each of these, as a voltage divider, thus giving a variable voltage between 0 and "12V". The wiper of the blend door potentiometer goes through an 82k resistor, and the wiper of the mode door potentiometer goes through a 3k resistor (I'm not sure if that matters, but if possible, I'd like to match this setup.)

Things I have looked at:

• PWM using MOSFETs - These would have to be high side switches, and I admit I am not skilled enough to be able to pick out components for this. If there is a turnkey high side switching solution that will allow me to use PWM through an RC filter, that would be great. I think this would be the simplest answer, and use the cheapest components.

• Digital potentiometers - again, there is a wealth of these out there, all with different specs, most of which don't seem to support more than 5V. I think potentially this one might work: MCP41HV31-103E/ST-ND

So my question is:

I have an Arduino Nano, and I need it to output an analog signal between GND and a reference voltage (in this case 12V to 14V), what is the best way of doing that?

Edit: Additional information, I have found schematics for both the actuator, as well as the control interface:

Actuator information

Controls information

• You can PWM into an RC filter with an N-FET as a low side switch. The viability of that depends on how much current your load will draw. Oct 6 '20 at 17:41
• PWM output, filtering, op-amp circuit to increase voltage? Oct 6 '20 at 17:41
• as far as I know this cannot be a low side switch, how would something like that be configured? I have not tested the current draw (I certainly can, just havent yet) but I expect it to be small. Oct 6 '20 at 17:46
• would something like this circuit work? electronics.stackexchange.com/questions/169287/… Oct 6 '20 at 17:46
• If filtered PWM won't work plenty of classic current mode DACs are meant to be used with an op-amp in a way that can readily give a 12 volt output range. The series resistor makes it seem you need a signal not to be a power supply, but automotive electrical environments are notoriously nasty. Oct 6 '20 at 18:43

Jack Creasey definitely has a point, you don't know much about the input you are trying to drive. However, I think it is a safe bet to say the actuators are not current-driven; their input seems to have a 100 kOhm resistor in series, which would result in minimal currents and low reliability for current-controlled inputs.
That being said, two other approaches could very well be worth a try. Both were briefly discussed in the comments before:

## MOSFET as low side switch, RC-Filter

simulate this circuit – Schematic created using CircuitLab

The input marked with "Arduino PWM" can be birectly connected to any Arduino pin with PWM capabilities. The output ("to climate control") should either replace the middle pin of the potentiometer, or, if you are sure that the input is voltage-controlled, directly to the control input your actuators.

The left part of the shown circuit amplifies (and inverts) the PWM signal from your Arduino to 12V.
Thr right part is a simple RC low pass filter, which turns the fast-switching PWM signal into a mostly stable voltage. Basically, the part of the signal which consists of higher frequencies is rejected and only the low frequency is allowed to pass (therefore "low pass filter"). To learn more about how this works and how to calculate it exactly, have a look at this or any other tutorial.

The circuit is not perfect, though. If the output is loaded (e.g. by the climate control), the output voltage might drop significantly. However, this should not be the case due to small input current of your actuator's control input. Also, the two stages are not buffered, meaning the low pass filter will slightly load the left circuit part (therefore the resistor choice: R3 (10 kOhm) should be much larger than R2 (1 kOhm) to make the effect imperceptible).
As noted in the comments, a n-channel MOSFET should be used instead of a BJT, because the BJT will always have a Vce(sat) of around half a volt (which limits the minimal output voltage). The suggested IRLZ34n has a Rds(on) of 35 mOhm, which results in a minimal output voltage of practically zero.

## RC-Filter, Non-inverting amplifier

simulate this circuit

The external wiring of the second circuit is identical to the first one.

Even the idea behind the circuit is similar: here the PWM signal is transformed into an analog voltage first, then amplified. Since amplifying analog voltages with transistors only is quite tricky, we use an operational amplifier (op-amp) instead. The circuit is known as "non-inverting amplifier", since the output voltage follows the equation $V_{out} = \frac{R_2+R_3}{R_3}\cdot V_{in}$. Again, there are tons of tutorials available online, here's the first one I found.
The op-amp should be a rail-to-rail type (meaning the output voltage swing includes both the negative and positive supply rail, GND and 12V in this case) and needs to be suited for supply voltages of at least 12V, the more headroom the better.

This circuit overcomes the problems noted for the first one (the two stages are buffered and the output is low-impedance) at the cost of higher complexity.
If you need voltages higher than 12V, you can of course adjust the gain by choosing other resistors. For example, you can trim the circuit to output up to 14V, but keep in mind that in that case if the supply is only 12V, the output will clip and you will reach the maximum output voltage (12V) at ~4.3V input.

I'm quite confident that you can manage to solve your problem with the knowledge about the circuits shown above, especially if what you wrote in your comment to Jack Cearsey's answer holds true. In that case, you should connect the output of the shown circuits directly to the control input of the actuators.

Please let us know which solution worked for you, and which one didn't (and why), so that others can benefit from it as well.

• Neither of these seem like good solutions. The first can never get to 0V because of VCE(sat) and the second won't work over the full range because the inputs are NOT rail to rail....only the outputs. Oct 7 '20 at 3:19
• I agree that the first circuit is a "quick and dirty" solution, probably using a logic level n-MOSFET (e.g. IRLZ34n) would improve it a bit. However, I fail to see the problem you hinted at for the second one. Is there some number in the datasheet I missed? I even tried it in simulation (with the exact same opamp) and the results are alright - applying PWM signals gives me the full desired output range. Oct 7 '20 at 10:48
• I think I see the problem with the first solution, is it that even when Q1 is fully on, it will still have some resistance, and that allows some flow through R3? I also cannot see the problem with #2, if the lm6132 is a rail to rail op-amp, what is meant by "the inputs are not rail to rail"? Oct 7 '20 at 11:44
• @Patrick looking at the datasheet (ti.com/lit/ds/symlink/…), figure 8 shows the input characteristics. While it's shown at +/-5V you can clearly see that the inputs stop working at about 4V. Look at figure 30 to understand why. The LM6134 is almost rail to rail output, but definitely not rail-rail input. Most models miss these characteristics. Oct 7 '20 at 14:41
• That, however, should not pose a problem, because the input voltage will never exceed 5V, while the supply voltage is 12V. There is plenty of headroom here. meanwhile, the very same figure shows that the negative supply rail (GND here) is included in the input voltage range, as it is necessary for this application. Oct 7 '20 at 16:26

It appears that you don't know much about the input port used for your feature. Is it a reference voltage or a reference current being used to set the operating point? Trying to use a PWM may not work, and I'd suggest is unlikely to work, and too difficult to program if you are new to it.

Given that you 'know that the potentiometer used is a 10k (linear one assumes), then the best solution is to use an I2C digital potentiometer. They are many available and the DS3502 may be a worthwhile choice. You can get this as a low cost easily wired PCB such as here, which also has Arduino code shown in the example.

This DS3502 IS NOT suitable for direct connection to the 12V rail in your car (even with a 17v Absolute max rating). The 12V can easily have spikes in excess of 17-19V and could easily kill the device.

You should ensure that you include some form of supply limiting. Since the maximum current is just a few uA I'd suggest a series 100 Ohm resistor and a TL431 shunt regulator. Study this datasheet to understand the TL431. The shunt circuit is simple and you only need one regulator for both (or more) potentiometers you replace.

Set the shunt regulated to about 15V, which is above the maximum likely from the battery (13.8V) when not charging. This prevents the regulator sinking current on a fully charged battery and it will only conduct when the voltage is above 15V.

• I appreciate the very well explained answer, and the part suggestions and cautions. I do have a question though, you mention that the systems might work based on current, how would I test this? Also, pwm is trivial to implement on an arduino, and I'm a professional software developer, could you explain how that could be too difficult? Oct 7 '20 at 1:37
• I was just doing some more digging, and found a schematic of the actuator: web.archive.org/web/20131004160413/https://… the two are apparently identical parts, and are voltage controlled. Oct 7 '20 at 1:54
• @patrick PWM is easy to set ....generating a voltage over a large range (0-12 or 0-some variable upper supply) is more of a challenge. As shown in the other answer posted recently, there may be other solution ....but neither of those will work over a large range. Oct 7 '20 at 3:17

Use a buck boost converter that takes 5V as input and gives 0-12V, use that output to give feedback to microcontroller for voltage sensing and drive converters En(enable) pin using microcontroller.

Microcontroller will switch En pin on/off depending upon feedback voltage and required output voltage.

• PWM'ing the EN pin of a boost converter sounds like a pretty bad solution, especially for a beginner (all sorts of problems can arise and he will have a hard time diagnosing them). Especially considering that he already has a 12V source... Oct 6 '20 at 18:14
• Have you use UC3845, Please read the datasheet, we use its Comp pin, in the same way, I suggested to regulate the voltage. Oct 6 '20 at 18:48
• a comp (==comparator) input pin is absolutely not the same as an enable pin. Oct 6 '20 at 18:50
• use uc3845 comp pin then Oct 6 '20 at 18:51