Is it ok to create a virtual ground for MCU - Page 1
Forum section: electronics / beginners

author: Connoiseur
author_rank: Regular Contributor
timestamp: August 12, 2016, 02:39:17 pm
content: Hi,I am designing a circuit which extensively uses Op-amps to do functions like precision rectification, filtering, summing etc. The entire circuit is supposed to be powered from a single 24V power supply. Since these functions can only be satisfactorily carried out with a dual supply, I'm splitting the rail to +12_0_-12V using a uA741 with 2n3904 on the output to get more current.So far so good, however, the output from the analog circuit needs to be fed to the adc pin of microcontroller (mega 32U4).Is it desirable to power the mcu with a similar split supply or I've to change the entire design such that all the component's ground is THE GROUND and not some high impedance node hanging in the air?How is a mixed signal circuit designed in real life? (I mean with relation to power supply rails)Thanks

author: Ian.M
author_rank: Super Contributor
timestamp: August 12, 2016, 02:55:36 pm
content: It depends:- Are there any external connections that expose the split rail 'ground'?- Are you certain that neither the 24V supply nor any device it powers are ground referenced?- Can the rail splitter sink enough current to reliably power the MCU if its fed from a simple linear 5V regulator from the +ve rail?If the answer to any of those questions is NO, you are probably going to need a switching supply that provides both a -ve rail for the analog circuits and 5V for the MCU.

author: rstofer
author_rank: Super Contributor
timestamp: August 12, 2016, 03:29:02 pm
content: Just before you stuff the analog signals into the uC ADC, you do a bit of level shifting and offset such that all the signals are within the range of the ADC. That way you can have a solid ground on your analog supplies and a solid ground for the digital side. They should probably be kept separate until they are joined at one specific location but there's probably a lot of info re: analog/digital grounds on Google.See chapter 4 of Op Amps For Everyone to see how they implement the offset and scaling with 4 resistors and a single supply op amp.http://www.siongboon.com/projects/2008-04-27_analog_electronics/op%20amps%20for%20everyone%20third%20edition%202009%20(Texas%20Instrument).pdfThe nice thing about having an op amp just ahead of the ADC is that it can provide the low source impedance that the ADC expects.

author: danadak
author_rank: Super Contributor
timestamp: August 12, 2016, 03:36:22 pm
content: Either offset and scale into ADC as suggested prior, or develop a - supplyto run OpAmps.For that latter some approaches, attached.Regards, Dana.

author: Brutte
author_rank: Frequent Contributor
timestamp: August 16, 2016, 08:46:06 am
content: Quote from: Connoiseur on August 12, 2016, 02:39:17 pmI do not want to be picky but op-ampalwaysexposes two pins (reference + signal) and ADCalwaysexposes two pins (reference + signal). So you have to tiebothtogether respectively (mind impedance).The absolute voltage does not matter. Could be near +24V or could be near 0V or bounce up and down (mind common mode ripple rejection). What is important is that both (op-amp and uC) have limited input voltages range (w.r.t. their own Vcc and GND). But op-amp does not care about GND of uC and uC does not care about GND of Op-amp.I would not play with making some virtual GND in between 24V and 0V just for the fun of splitting rails. It could be important if you want to drive some bipolar output (P-MOS + N-MOS pair, DC motor, etc) but otherwise I do not see the point.

author: mikerj
author_rank: Super Contributor
timestamp: August 16, 2016, 11:18:40 am
content: Quote from: Brutte on August 16, 2016, 08:46:06 amADCs do not always expose a separate reference pin.

author: Brutte
author_rank: Frequent Contributor
timestamp: August 16, 2016, 11:34:44 am
content: Quote from: mikerj on August 16, 2016, 11:18:40 amThen the reference must be wired internally to somethingUsually to AGND. Now you say that not all ADCs have separate AGND. Well then this must be wired to GND that is shared with digital part. With dedicated pin or not - it is somewhere there, just keep looking.

author: bobaruni
author_rank: Regular Contributor
timestamp: August 16, 2016, 01:18:54 pm
content: The Reference pin is NOT tied to AGND nor should it be. This is the + reference voltage for the ADC inside the 32U4.If you run the 32U4 from +3.3v and GND - the GND being common to all circuits including the op-amps, the output of the op-amp and therefore the input of the ADC must never go below GND and never above what the internal reference voltage for the 32U4 is and definately not above the 32U4's +3.3v rail, please read the 32U4 absolute maximum ratings to determine the actual values.Yo can do this by setting up an offset on the op-amp or by using a resistor divider between the op-amp and ADC, the latter offers a higher degree of protection against damage/misuse.

author: Brutte
author_rank: Frequent Contributor
timestamp: August 16, 2016, 01:48:35 pm
content: Quote from: bobaruni on August 16, 2016, 01:18:54 pmYou are right, that is not precise enough, by "reference" I meant "the reference of the input signal".Sorry for the confusion, "reference of input signal" and "ADC voltage reference == AREF pin on ATMegas" are two completely different animals. Anyway, the op-amp arrangement reference must be tied to the former.

author: bobaruni
author_rank: Regular Contributor
timestamp: August 16, 2016, 02:50:44 pm
content: QuoteGenerally, best practice is sometimes very low impedance common GND when mixing digital and analog but sometimes it can be separated by a few ohms to reduce digital noise and reduce eddy currents, especially in audio.It's whatever you can think of and works well for your application.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: August 16, 2016, 02:56:34 pm
content: The MCU doesn't care, as long as its supply is nominal.You might care, though. That puts digital currents into the analog rail. Which is still okay as long as all digital signals are referenced to the same ground (as they must be), but, any current leaving that domain (level shifters to +/-12V?) will be kind of a problem.Better to think of it this way: GND is GND, and the "virtual ground" op-amp is pulling the "+12" down, or the "-12" up, so as to keep the 12's balanced around GND.Don't forget to use GND planes or pour (stitched), if this gets to a PCB.Tim

author: C
author_rank: Super Contributor
timestamp: August 17, 2016, 12:16:43 am
content: Quote from: Connoiseur on August 12, 2016, 02:39:17 pmThink of what you have here. The uA741 output can source or sink current. When you add one transistor to output you have changed bidirectional correction of uA741to unidirectional correction.A 2n3904 would act like a LM7812. while a 2N3906 would act like a LM7912LM7812 a positive regulator can cause a positive change of voltage across the load.The load is what makes a negative change of voltage.LM7912 a negative regulator can cause a negative change of voltage across the load.The load is what makes a positive change of voltage.With the 2N3904 you are increasing the load on 0 to +12 to correct for a load change on the -12 to 0. The -12 to 0 needs to be the largest load.If this is not true you could have +4, 0, -20 and the 2N3904 not be able to correct it.

author: Connoiseur
author_rank: Regular Contributor
timestamp: August 18, 2016, 06:51:02 am
content: Thanks everyone for your valuable inputs.After going through all of your suggestions, I've revised my supply design as shown in the attachment.I'm building a pump controller for a small dyeing unit which was run manually. The MCU checks the levels of liquids in two tanks and some other parameters to turns ON the pumps based on some conditions. Since the initial signal conditioning is to be done by op-amps (including reading current from 100/5A CT), hence the dual supply. The time of turning ON and duration etc are to be logged on the SD card. The motors are to be turned ON/OFF by contactors whose coil is 24V operated.(I'll be using optos before the MOS that energises contactor coil)

author: T3sl4co1l
author_rank: Super Contributor
timestamp: August 18, 2016, 11:42:39 am
content: Beware that the 555 will make quite a lot of power supply noise, on both sides.Tim

author: Zero999
author_rank: Super Contributor
timestamp: August 19, 2016, 08:27:06 am
content: Please post the schematic of the circuit you need to power. Perhaps you may be able to modify it so it will work from a single supply?It's possible to make a precision rectifier which will work off a single supply. The datasheet for the CA3140 has an example on page 18 of the data sheet. The circuit will work with other op-amps.http://www.intersil.com/content/dam/Intersil/documents/ca31/ca3140-a.pdfTo make a split rail supply with an op-amp, two output transistors are required: one NPN and the other PNP.

author: Connoiseur
author_rank: Regular Contributor
timestamp: August 20, 2016, 07:36:17 am
content: Quote from: Hero999 on August 19, 2016, 08:27:06 amSure. I'll do it in a few hours, have to clean up a bit and name the nets properly for easy understanding. Thanks very much

author: Connoiseur
author_rank: Regular Contributor
timestamp: August 20, 2016, 10:23:24 am
content: Quote from: Hero999 on August 19, 2016, 08:27:06 amHere is the schematic. It's not complete as I'm wrestling to get the right footprint for the jacks and some other components. Anyway if I don't find them I might make it AutoCad and export the dxf or get from eagle by running ulp.I hope the schematic is understandable, if not any suggestions are welcome, being a inexperienced freshman I'm not very familiar with the actual stuff.NB: Don't worry, if it looks horrible, it will go for a review by my senior before implementation, so I'm not in a danger of screwing things up and blowing up anything expensive or important. It's has been assigned to basically test me (probation).

author: Zero999
author_rank: Super Contributor
timestamp: August 21, 2016, 12:23:59 am
content: I don't see how the level shifter is supposed to work. You do know you can use the 74HCT244 to shift 3V logic signals up to 5V? That would eliminate all those resistors and transistors.http://www.nxp.com/documents/data_sheet/74HC_HCT244.pdfI'm sure you don't need all of those op-amps. For example, for the temperature sensor, can't you just us a 150R resistor, which will give 0.6V to 3V and feed it straight into the ADC?The circuit I posted previously posted a link to can be used to rectify the output of those current transformers and only needs one voltage rail. Failing that, can't you bias one side of the current transformers to a potential divider on the 3.3V rail to bias it at half the supply and directly feed the ADCs? The burden resistor may have to be changed to give a maximum of 3.3V peak to peak but it should work.EDIT:Here's another precision full wave rectifier circuit, which will work of a single supply rail.n If you don't have the LT1078, it will work with the LM358 or LM324 but the offset will be higher, although you can null it using software.http://www.linear.com/solutions/1608

author: Connoiseur
author_rank: Regular Contributor
timestamp: August 21, 2016, 03:53:00 am
content: Quote from: Hero999 on August 21, 2016, 12:23:59 amThe level shifter does work (atleast in simulation!)I had totally forgotten about that chip. I usually use cheap ones off eBay that have a circuit like I've made.And thank you so much for your suggestions. It greatly simplified my design and improved reliability + performance.

author: Zero999
author_rank: Super Contributor
timestamp: August 21, 2016, 10:57:31 am
content: Quote from: Connoiseur on August 21, 2016, 03:53:00 amOh I see, now you've posted the complete circuit for the level shifter, I understand. The usual way is to use a MOSFET, normally the 2N7002 but it works with a BJT too and has the advantage of being bidirectional. The 74HCT244 is faster and doesn't take up so much space on the PCB but it's only unidirectional.

author: Ian.M
author_rank: Super Contributor
timestamp: August 21, 2016, 12:22:34 pm
content: Use a bidirectional level translator, e.g the74LVC2T45which is a dual level translating buffer with a direction input and two separate Vcc pins, each rated for operation 1.8V - 5.5V.You'd use two for the 4 bit data base with their DIR pin fed from an inverter fed fron the MCU side LCD RW signal. Two more handle RS RW and E with their DIR pin tied high to make them unidirectional. Its not recommended to let their inputs float, so pullups either side of the data bus ones should be used.During development, 220R resistors in series with the data bus between the MCU and the level shifters are advisable, in case you b-----r up the direction changing code and cause bus contention.

author: Zero999
author_rank: Super Contributor
timestamp: August 21, 2016, 09:04:57 pm
content: The advantage of the discrete logic level shifter, is there's no need to manually change the direction. It does that automatically.The 74HCT224 can also be made to be bidirectional but it isn't automatic and requires some resistors.

author: Ian.M
author_rank: Super Contributor
timestamp: August 21, 2016, 09:36:45 pm
content: Yes, but if you are using a 74HCT245 for a LED in 4 bit mode, you absolutely do NOT want to tristate RS, RW and E which means you cant use the '245 for them as it only has one /OE for all 8 data lines.If you use a74HCT241you can tristate each nibble independently,Use the nibble with the /OE pin for the data bus with /OE driven from RW, wit resistors across it as per your diagram. Use the other nibble for the control lines with its OE pin tied high to permanently enable them.