SPI to 0-10V signal , need checkkup


I'm trying to do a converter that do 0-10V industrial signal from SPI.

before say anything, I've seen the post about level booster on PWM, But it did fit fine to my need. I want better definition and predictability.

So I took the hard road.

-first I took a 10K digipot With SPI interface, hook it from 3.3 to 0.

-Secondo, I make a level booster to generate +12Vdc.

-thirst, I take an op amp with rail to rail 0 to 12V. I took reference from this document:


To remove the near rail fault I add a 1n4004 diode to the output amp and Bias the input with the Vin+ refference.

So I convert 0-3.3 from digipot to 0-10V.

share you the schematic with some formula I used. I've basic understanding on electronic there is much chance I have done a mistake. So I need some advice. And I know I chose the hard way... :stuck_out_tongue:



I would use a DAC, like this one and a suitable amplifier. There is probably an SPI bus equivalent, and most certainly, similar chips with 0-10V output.

I want better definition and predictability.

Do you think an 8-bit pot has a better definition than 8-bit PWM.

It all hangs on VCC, that zener, the non-linearity of a digital pot, and maybe more.

What is that 1N4004 doing there.
That makes reaching 10volt worse.
0volt also can't be reached with that opamp.

Check the feedback part of the boost converter.
The circuit doesn't work the way it's drawn.

I've seen the post about level booster on PWM, But it did fit fine to my need. I want better definition and predictability.

I am sure you are misunderstanding something fundamental. Predictability? Only a badly designed circuit is not predictable. Definition - simply the wrong word to use, it conveys nothing.

So I convert 0-3.3 from digipot to 0-10V.

That is a very very strange "round the houses" way of doing this. I would have used simply a SN7406 open collector inverting buffer. Two in series if you don't want the voltage inversion.

I'm trying to do a converter that do 0-10V industrial signal from SPI.

I got a bit confused with all the talk of digital pots and diodes and opamps, do you just want an SPI signal at 10v levels?

Use a transistor as Mike said, or an open-collector buffer that can handle 10v on the output.

I understand OP wants to convert 0-3.3volt analogue to 0-10volt analogue.
An industrial 0-10volt analogue control voltage.

I append a suitable 3 times amplifier - if you want EXACTLY 3.3 ... 10 v, add a 1k variable.resistor in series with R2

Note I've included a low pass input filter from the presumably 3.3v PWM input to greatly reduce ripple.

Note also a 100 ohm in the amplifier's output to improve stability and protect from noise and excessive capacitance on the output line.

the opamp will have an input offset of a few mV - this will result in a further error of up to 0.1% worst case - but since the resolution of the PWM signal is only about 0.4% it shouldn't be a worry.

And if the 3.3v is derived from arduino, I doubt if it's regulator will be better than +/-5% if you're lucky.



Whoops! forgot the circuit…

here it is


3opa.pdf (17.4 KB)

Circuits like this are fine, and frequently posted on this site.
You can improve reaction speed by using a smaller cap and pin 5 or 6 (~1kHz PWM).
Or code for a higher PWM frequency.

Thank. Allan.

To simple to not so it.. :stuck_out_tongue_winking_eye:

This should be include with the other with voltage boost as an alternative..

For the rail to rail amp, I found AD820.pdf

Is that suitable? and It is a bit expensive... Someone have sugestion ?

Wawa, Is the Arduino Due have different frequency of pwm on different pins ?

Wawa, Is the Arduino Due have different frequency of pwm on different pins ?

The Due has a true DAC.
You don't have to filter that, like you have to with PWM.
Just amplify the DAC output voltage.

Try a cheap LM358. It might just do what you want on a 12volt supply.


Last question. What's the gain relation of this amp... it is not Rf/Rin in that case...

Noninverting opamp.
Second circuit.

The LM358 world be fine - but not with just a single +ve supply - it's not rail to rail
on it's output - and can't be with that emitter follower PNP pull-down. (look at it's outline schematic on the datasheet).

Nitrof - if you can arrange a negative supply for your opamp your choice becomes huge and
cheap. Everything else remains the same. Only a few volts is necessary. - 5 would be plenty

You're limited both by a single supply, and (presumably) a DIP - ie non-surface mount package.

The AD820 would be an excellent choice... it's a matter of which is cheaper - that or a -ve supply.

The gain is (1+ R2/R3). bog standard.



Thanks Allan.

I take you're advise. Ad820 is not expensive enough to Justify a negative supply. And it will make schematic more simple.

About it.. In the +12V supply boost, I find a big error in wiring... I correct it with recommendation from datasheet. But if you don't mind to retake a look in case I missed something...

Also, I add a jumper to select another value for Rin (R3), making the output 0-5V or 0-10V.

Now this is the final schematic:

If you’re worried about the output swing of the LM358.
The opamp doesn’t have to sink (load is grounded).
From the TI datasheet:
Low voltage output <0.01volt in that case. About the same as a rail2rail opamp.
High output is > VCC-1.2volt at those feedback resistor values (load will be 1Megohm).
So no problem to get 10volt out on a 12volt supply.

Supply seems to be ok now. Didn't calculate the R values though.

I would use 18k for R5, and a 4k7 (5k) pot.
You also have the problem that 3.3volt is not always 3.3volt, so a bit more adjustment range is good.

Thanks Leo.

To be shure a recalculate the resistor.. :stuck_out_tongue: look good so that will be. I chose the closes value available at digikey in 0805.

I will change value of resistor. Seem a good range of adjustment (around +-0.8V@0-10V, +-0.2V@0-5V math checked).

I tough I was over with new question and finally a got one more.. :stuck_out_tongue: What could be the best approach to protect the output from device connected on it. it will be mostly 24Vac actuator. So it should be from both hi and reverse voltage if possible...

So it should be from both hi and reverse voltage if possible...

That circuit is called a H-bridge, you could make one yourself but the deceptively simple schematics you find on line are not as good as they might seem. I would recommend you get a H-bridge chip. There are plenty about.

I think OP means protecting the opamp circuit from accidently 24volt (both polarities) on the opamp output.
Not easy.
Maybe a 12volt TVS diode across the 12volt supply.
And two 1N4004 clamping diodes from output to ground and 12volt.
Too much current could still release the magic smoke and send parts to silicon heaven.