# Digital to analog resistive circuit

Joined Jan 18, 2024
16
Hi!
I am trying to create a variable resistance circuit to simulate a resistive sensor that outputs resistance 240-33ohm range. (240ohm = min, 33 ohm = max)
Would the following circuit fly? The idea is to digitally control the resistance by turning AO3400 N-channel MOSFETs on/off and thereby bypass/connect different resistors to acquire the wanted resistance value.
Sadly, have no previous experience with transistors, and even after watching numerous YouTube videos I don't feel a bit wiser. I'm not even sure if I have drawn the transistor pins correctly? Some help would be much appreciated!

#### MrChips

Joined Oct 2, 2009
30,925
You don't have to go to that much trouble. This will work (example showing 4-bit DAC).

Or you can buy a DAC in one IC such as DAC0800 or AD558.

#### crutschow

Joined Mar 14, 2008
34,679
What is the max voltage that is applied to the "Gauge" terminal?
The DOUT voltages will have to exceed that by the Vgs full turn-on voltage of the MOSFETs (at least 2.5V for AO3400 you show).

Otherwise the circuit should work to give you 256 binary resistance steps with a maximum of 255Ω and a minimum of near zero (combined resistance of all MOSFETs when ON).

#### crutschow

Joined Mar 14, 2008
34,679
This will work (example showing 4-bit DAC).
He wants a resistance, not a voltage.

#### ronsimpson

Joined Oct 7, 2019
3,131
digikey.com has 4000 different digital potentiometers. Here is a 1024 step part.
Many of the pots have 128 steps or 256 and some as little as 16.
They have too high a resistance for you but it is an idea.

For the MOSFETs in your design, I have used the CD4066, CD4051, 52 or 53. More ideas.
What is the current in the resistors?
What are you making?

#### Jerry-Hat-Trick

Joined Aug 31, 2022
574
You can get digital pots down to a value of 1.0 KOhm (maybe lower, I'm not aware) although at best they are +/- 20% accurate. Maybe try two in parallel, (maybe each in series with a different fixed resistor) which will give you a huge range to tweak/calibrate values you want by making them different values.

#### tonyStewart

Joined May 8, 2012
132
Output: 240ohm = min, 33 ohm = max
Resolution: 8 bits, Accuracy < 1 bit
Input: digital, parallel or maybe serial
Hardware: THT or SMT, likely THT in sockets.
Input Voltage: ?, Output Voltage: ?
Supply Voltage: 5? 12? or 11.5 to 14.5? or x?

#### crutschow

Joined Mar 14, 2008
34,679
You can get digital pots down to a value of 1.0 KOhm (maybe lower, I'm not aware) although at best they are +/- 20% accurate.
The one in post #5 states the tolerance is 1%.
But it does require a serial interface to control the resistance.

#### Jerry-Hat-Trick

Joined Aug 31, 2022
574
The one in post #5 states the tolerance is 1%.
But it does require a serial interface to control the resistance.
I saw that, but its minimum value is 20kΩ which is far higher than the TS is looking for. I think the wiper resistance in digital pots is an issue which I believe is why they are not available in low values - I'm not familiar with the internals. The digital pots I've used all had a serial interface to control the value - is there another way?

#### crutschow

Joined Mar 14, 2008
34,679
The digital pots I've used all had a serial interface to control the value - is there another way?
Don't know.
Just mentioned that so the TS would know that he has to generate a serial interface signal to control it.

Joined Jan 18, 2024
16
What is the max voltage that is applied to the "Gauge" terminal?
I'm not sure. I will have to measure the signal. Probably not very high voltage. A guess is something like 5V. The "Gauge" is actually a tank level input on a Victron Cerbo GX. The only thing the manual says is "The tank level inputs are resistive and should be connected to a resistive tank sender. Victron does not supply tank senders. The built-in tank sensor connections do not support mA or 0-5V type sensors, this type will require additional accessories or replacement with a resistive type sensor."

The DOUT voltages will have to exceed that by the Vgs full turn-on voltage of the MOSFETs (at least 2.5V for AO3400 you show).
Otherwise the circuit should work to give you 256 binary resistance steps with a maximum of 255Ω and a minimum of near zero (combined resistance of all MOSFETs when ON).
The MCU outputs 3.3V, so that is what the PCF8674 will output, unless I use a level converter to "ramp it up" to 5V.
I take it my idea is sound then?

#### ronsimpson

Joined Oct 7, 2019
3,131
Assuming the Gauge voltage is in the range of 0 to 5V. The Gate to Source voltage on the MOSFETs needs to be about 5V and not more than 10V. So I think the Gate voltage should be 0 and 10V. The 3.3V or 5V will not work.

#### crutschow

Joined Mar 14, 2008
34,679
I use a level converter to "ramp it up" to 5V.
I take it my idea is sound then?
As I stated, the output needs to be at least 2.5V above the voltage applied to the gauge connection.
If that's 5V, then the MOSFET gate voltage needs to be at least 7.5V.
If you do that, it should work.

Joined Jan 18, 2024
16
digikey.com has 4000 different digital potentiometers. Here is a 1024 step part.
Many of the pots have 128 steps or 256 and some as little as 16.
They have too high a resistance for you but it is an idea.

For the MOSFETs in your design, I have used the CD4066, CD4051, 52 or 53. More ideas.
What is the current in the resistors?
What are you making?

View attachment 317192
Thanks, but I have thought of that. The lowest resistance digipot I have found is 1KΩ, so a single digipot won't do it. I would have to use a couple in parallel, and in that case it would be cheaper and simpler to use mosfets and resistors.

Joined Jan 18, 2024
16
As I stated, the output needs to be at least 2.5V above the voltage applied to the gauge connection.
If that's 5V, then the MOSFET gate voltage needs to be at least 7.5V.
If you do that, it should work.
Oh.. So what are my options? Add some kind of 8 channel OP-Amp to amplify the voltages?

Joined Jan 18, 2024
16
Assuming the Gauge voltage is in the range of 0 to 5V. The Gate to Source voltage on the MOSFETs needs to be about 5V and not more than 10V. So I think the Gate voltage should be 0 and 10V. The 3.3V or 5V will not work.
I see. Of course it wouldn't work out that easy... Do you know of any other MOSFETs that would work with a 3.3-5V gate voltage?

#### ronsimpson

Joined Oct 7, 2019
3,131
Do you know of any other MOSFETs that would work with a 3.3-5V gate voltage?
The problem is that the Source of the MOSFET could be near 5V. With the S at 5V the Gate needs to be 5V above that. It is not the voltage from Gate to Ground but the voltage from Gate to Source that turns on a MOSFET.

I got some of these boards for \$9.00. They work directly connected to a micro (3.3 or 5.0). A relay does not have the problem the MOSFETs does. The relays are good for 10A and 500 volts which is over kill. There are several different kinds on the market.

There are also solid-state relays that are much smaller. I just picked one at random. You drive it like a LED then add a resistor. This one has 16 ohms of on resistance which is too much, but this is an idea.

You might look at G3VM-31HR1 .

#### crutschow

Joined Mar 14, 2008
34,679
So what are my options? Add some kind of 8 channel OP-Amp to amplify the voltages?
You could add a NPN buffer transistor at each output with the collector load resistor connected to a 7.5V or 10V power supply.

Joined Feb 20, 2016
4,493

As it is just a gauge, would something like this work?
I could be tested with a switch in place of the FET. The 39R will maybe need to be a 5W resistor.

Last edited:

#### Ian0

Joined Aug 7, 2020
10,001
Is the gauge an automotive gauge by any chance? One with a hot-wire meter?
If so, you can use PWM and a single resistor.