Controlling 12v from 5v - Page 1
Forum section: electronics / beginners

author: shawty
author_rank: Regular Contributor
timestamp: January 10, 2023, 06:05:03 pm
content: (Upfront Disclaimer, this may not be a beginners question so do feel free to move it if you wish, I couldn't see anywhere more sensible to put it)----------------------------------------I have a 12v supply that I have to control via an R2R dac from a 5V microcontroller using digital pins.Essentially an R2R DAC, but instead of the output being a product of the voltage from the micro, it needs to be a percentage of the 12V signal.I did do a similar circuit once, a very long time ago, but it's been a long time since I did any real electronics work, and I confess I am a bit rusty (That and I've lost my original designs, and no amount of web searching seems to be turning up anything that triggers the grey matter)From what I can remember, I initially did something similar to this:but as I've realised building the circuit in Proteus, even though the DAC side voltage as 12v, I never get more than 5V on the output.can someone help clear up my grey matter here, or if I'm just being a muppet or not and completley missing the mark!cheersshawty

author: BillyO
author_rank: Super Contributor
timestamp: January 10, 2023, 06:12:42 pm
content: Put the R2R DAC completely on the 5V side, then feed it into 1/2 of an LM358 op-amp that is powered from the 12V side and adjust the gain to give you the output you want.

author: golden_labels
author_rank: Super Contributor
timestamp: January 10, 2023, 07:04:34 pm
content: In addition to what BillyO said, drive the 5V side directly from the micro or a buffer IC. R-2R ladders must be actively driven both high and low: the input must be able to both provide and suck current. In your circuit the transistors in thecommon collector configuration, so they only source current — there is nothing to pull ladder’s input to ground.That configuration is also why you are getting below 5V: the transistors act as voltage followers, “copying” input voltage (minus about 0.6V) to the output. If the input voltage is never above 5V, the output can’t go higher either.

author: shawty
author_rank: Regular Contributor
timestamp: January 10, 2023, 08:02:11 pm
content: Ah ok, I gotcha now, the reason that design stuck in my head was I was afraid of pulling to much amperage through the MCU on the 5V side.The 12V supply basically is coming from another device, which feeds into a separate subsystem, and I have no idea how many amps it's likely to pull.Basically what I'm tasked with doing is providing an automated system that can override a manual system, while still allowing the manual system to work as it did previously.Something like this ...ORIGINALManual Control -------------------------> Sub System Measuring Voltage and controlling device based on Voltage seen between 0v & 12vWHATS NEEDEDManual Control ---------> Automated System ---------> Sub System Measuring ..... (as above)------------------------------------------------------------------------------------------------------------------------------The sub system (as I'm lead to believe - I have no access to it) uses the voltage it sees on the 12v line to determine how hard to drive a pump of some description.The manual control, restricts the voltage between 0v and 12v depending on how hard the operator wants the pump to be driven, EG: the manual control set half way (Think of it like a giant potentiometer - that's how it was described to me anyway) will release 6volts and the sub system will take that as a signal to drive the pump at 50%The idea behind the automated system is to be injected in-between the Manual control and the sub-system, so that for example, someone can say "Program Automation to allow NO MORE than 75%", and if the manual control is pushed beyond 75%, the automated system ensures it never exceeds 75%There are a few other requirements too, such as being able to bring the % down under auto control too, irrespective of the manual control.----------------------------------------------------------------------------------------------------------------------------------------Would the LM Op-amp approach still work for that, preferably without toasting the 5v system controlling it?cheersshawty

author: james_s
author_rank: Super Contributor
timestamp: January 10, 2023, 09:32:11 pm
content: The current you pull from the MCU can be negligible provided you select the resistors appropriately. Most MCU IO pins can source and sink multiple tens of mA which is a LOT for a DAC anyway. If you really need more drive or want isolation, use an octal buffer IC, there are several good choices. You're going to need to buffer the output with an op amp to scale it anyway so that will give you the high impedance input to feed with the DAC.

author: Benta
author_rank: Super Contributor
timestamp: January 10, 2023, 09:51:50 pm
content: Your R2R network looks very strange and unlike anything I've seen before.Normally the 2R nodes are switched either to '+' or to '0'.Like this:

author: BillyO
author_rank: Super Contributor
timestamp: January 11, 2023, 12:20:02 am
content: Along the lines of what james_s and golden_labels said, here is a working schematic taken from a successful design. It uses an 8 bit D-Type flip-flop to not only buffer the data lines but also to hold a value while the data lines and MCU are busy with something else. Only theLatch Signalneeds to be unique to the DAC. The data on the data lines is latched on the rising edge of theLatch Signal. A 74ACT574 will give a full 5V swing and will respond to TTL level inputs.

author: Terry Bites
author_rank: Super Contributor
timestamp: January 11, 2023, 08:17:57 am
content: So just a scaling problem?Unless you go with a readymade DAC, you won't get 8 bits of repeatable resolution HC latches or not. I'd reconsider this interface. Its so easy to get good resolution PWM from micros. PWM to DC volts could't be simpler.

author: shawty
author_rank: Regular Contributor
timestamp: January 11, 2023, 12:44:20 pm
content: Thanks for all the suggestion's folks,I'm going to go and re-work my designs and see what I come up with.@Terry Bites - I wanted to use something like one of the I2C based MCP devices, but the people requesting this, said that approach had been tried, and was too slow to respond, to taking over control of the voltage on the 12v line, hence why we now have what is essentially a parallel DAC. They then looked at dedicated parallel DAC's off the shelf, and deemed them too expensive for the project.@BillyO - Good call, I didn't think about latching the signal, and I should have, because the MCU will be performing other calculations too.@Benta - Yes I realised I had my two resistors onto the ground, and the single taps on wrong end's of the network after my last reply's yesterday, I've since rectified that, Thanks.@james_s - From what I've been told (It's a start-up and they are doing all the super secret, gonna change the world top secret squirrel stuff) so I only know, what I know, and I get the impression this "Sub System" (That's what they call it) could quite possibly be pulling amps, so I'm erring on the side of caution, I have no idea exactly what the "Sub System" is or exactly what it does, just that it's fed a 12V voltage and that determines how hard it drives a pump of some kind.---------------------------------------------------------------I have some rail to Rail OP-Amps not LM358's, can't remember the part nums, but def rail to rail as I remember buying them for a different project that never materialized, so going to hunt those out and see what the score is.Right now I've got a working model in Proteus, that gets me from something like 10.2v down to about 3.5v so I think with the rest of the pointers I have above and a bit of tweaking, I may get what I need.Once again, Thanks all for the input, I'll update this when I've got anything else to add (Then at least in future I'll have somewhere to look next time I forget ... :-) )I'm too spoiled by Digital Stuff these days, don't do anywhere near the amount of Analogue I used too.

author: AndyBeez
author_rank: Frequent Contributor
timestamp: January 11, 2023, 01:03:45 pm
content: Could this be done with a ULN2003 seven channel darlington array?

author: ledtester
author_rank: Super Contributor
timestamp: January 11, 2023, 01:14:16 pm
content: Quote from: shawty on January 11, 2023, 12:44:20 pmHow fast does the DAC need to change? And what kind of power supply is it controlling?

author: BillyO
author_rank: Super Contributor
timestamp: January 11, 2023, 02:55:05 pm
content: Quote from: Terry Bites on January 11, 2023, 08:17:57 amI'll have to respectfully disagree. It's been done. Several times that I am 100% aware of. After all, 8 bits of resolution isn't all that precise to begin with.

author: shawty
author_rank: Regular Contributor
timestamp: January 11, 2023, 05:21:21 pm
content: Quote from: ledtester on January 11, 2023, 01:14:16 pmThat unfortunately is something I've not been able to get a straight answer too :-(

author: shawty
author_rank: Regular Contributor
timestamp: January 11, 2023, 05:22:23 pm
content: Quote from: AndyBeez on January 11, 2023, 01:03:45 pmNever thought of trying that approach, I have some of those IC's kicking about ... might be worth giving it some thought.