0-2 mAmp Power supply from arduino

Not sure if this is the best way or place to ask this, but I'm kind of paranoid I've made mistakes and just can't see them because I've no idea what I'm doing. I'm also not sure what the best way to share schematics is, but I've uploaded an image of the schematic.

Essentially, I wanted to make a source for 0-2mAmps, and hook it up to something to monitor exactly how much current it was producing and a display to select exactly what the output should be. While I'm certain there are much easier ways of accomplishing this, honestly I don't much care so long as it actually works.

Given I approached this with absolutely no idea what I was doing, and mostly designed it by just reading the datasheet of the parts that sort of seemed like they'd work, I'm not sure that any of it will work. I'm reasonably confident in subsections like the part producing 24v, given TI provides simulations to show it's results, but I'm less confident I haven't done something incredibly stupid trying to tie together these mostly prepackaged solutions.

So what I think I've done:

This's the display used, and despite the fact it claims to be for MEGA/Uno it seems to work just fine with the DUE, as it runs on 3.3v at logic; mostly you just have to use it like a shield, but given it uses the 11-13(Can't remember exactly atm) pins for SPI to SD card, that's why those pins are being redirected to the Due's SPI pins. I believe this should solve the problems in the Due (or MEGA) that keep the SD card reader in the display from actually working, and SS is kept as p10. This connection is also split to feed the SPI for the DAC, SS set to pin 16 for that. I think I understand SPI, and am confident I can sort out code problems in the display library, but am a little worried I've just bungled the connections somehow.

Top left is a voltage upconverter copied directly out of the parts datasheet, and TI power-supply calculator, that should supply 24V. Nothing about the recommended specifications for parts has been changed.

Otherwise, a high-voltage Differential Amplifier (AD8277) is used to supply the current; the current source design is directly from an AD precision current supply document. The current sink, which I understand to be totally unnecessary but harmless, is just me modifying the design of the source and what I thought would work (NPN BJT). This actual supply portion of the circuit is monitored at the high side by an INA266 to allow voltage/current to be monitored and to ensure the power never exceeds 2mA; To this end, the alert pin (pull to ground) is connected to the pin enabling the voltage source and a digital pin that can be set to use it's internal pull-up resistor and monitor for any problems. I don't even actually know enough to be certain this is safe for the arduino.

The current source that is to control the AD8277 is a 5V source (REF02BU)(I was under the impression the arduino's was probably not reliable enough to be trusted) feeding a 16-bit DAC (DAC8551); this is set up how I think the datasheet directed me too, but again, I have no idea what I do and don't know. This, according to the sheet, gives me the 0-5V source I need to select 0-2 mAmps according to the AD8277 current source sheet, using a 3kOhms resistor with the AD8277.

Just using 3.5mm jacks to source and sink the power, and a final 3.5mm jack to connect two digital pins with a pushbutton, so that the power supply can be toggled a second way without having to touch the tft.

So, if anyone's had the patience to read this, am I actually doing anything that I think I am?

Last thing, do I have to do something to protect the ground pin from the parts 5V supply using a 24V source and the current sink? I don't actually know if the pins labeled ground are safe from high voltages and don't really want to kill my Due.

Thanks for reading.

INA266 doesn't exist.

Seems you mean the INA226. That circuit is opaque as you've not drawn the symbols for the circuit components - far better to sketch the topology by hand of the crucial parts and take a photo. Use opamp, DAC and ADC symbols, not just rectangles, and make explicit the differential amp internals.

On an initial analysis you've nothing to define Vbus so it'll wander off to the rails and saturate I think. The transistor is all wrong. Feedback from the emitter, not the collector, it needs to just be an emitter follower in the loop.

If you have a current source using a sense resistor you just need to monitor the voltage across the same sense resistor, I think you've over-complicated this.

You are sure you only want to build a 0 to 2.0 mA (0.002 Amp) current source? Here is what I suggest. I suggest you start using the wiper off a simple potentiometer to drive a a simple (OP07) operational amplifier with 0 to 5 volts and have the operational amplifier drive a simple NPN (2N3904) transistor configured as a current source. Start with something simple like a 4 - 20 mA loop. Then move on to a better single supply rail to rail opamp.

Using a 16 bit DAC with a 5.0 volt ref (and you need a highly stable Vref) the output becomes 65,536 quantization levels or about 76 uV per step. You are not about to easily resolve that. I also still question are you sure you onl;y want 2.0 mA? I know that is what you wrote several times but that is pretty low.

Ron

MarkT:
Seems you mean the INA226. That circuit is opaque as you've not drawn the symbols for the circuit components - far better to sketch the topology by hand of the crucial parts and take a photo. Use opamp, DAC and ADC symbols, not just rectangles, and make explicit the differential amp internals.

On an initial analysis you've nothing to define Vbus so it'll wander off to the rails and saturate I think. The transistor is all wrong. Feedback from the emitter, not the collector, it needs to just be an emitter follower in the loop.

If you have a current source using a sense resistor you just need to monitor the voltage across the same sense resistor, I think you've over-complicated this.

Sorry about the typo.

I'll start drawing it up by hand.

Is the transistor wrong for a current sink? Pretty sure it's stupid and pointless, but I put a source and sink in it so that both would try to limit their ability to source or sink if I manage to cock something else up. The source is just straight out of the amp, as it's within it's specs. Both are set of off the same input, so they wouldn't be fighting each other, as best I understand it. If it's wrong for a sink I'll try to read more on the subject until I understand what I did wrong though.

I'm over complicating the voltage sensing because I'm trying to measure small amounts of current at high voltage, so I couldn't be sure I knew how to get real accuracy while still protecting the arduino from the voltage.

Ron_Blain:
You are sure you only want to build a 0 to 2.0 mA (0.002 Amp) current source? Here is what I suggest. I suggest you start using the wiper off a simple potentiometer to drive a a simple (OP07) operational amplifier with 0 to 5 volts and have the operational amplifier drive a simple NPN (2N3904) transistor configured as a current source. Start with something simple like a 4 - 20 mA loop. Then move on to a better single supply rail to rail opamp.

Using a 16 bit DAC with a 5.0 volt ref (and you need a highly stable Vref) the output becomes 65,536 quantization levels or about 76 uV per step. You are not about to easily resolve that. I also still question are you sure you onl;y want 2.0 mA? I know that is what you wrote several times but that is pretty low.

Ron

The resolution is silly, but I really do need 0-2 mA. A 16-bit resolution was what the datasheet recommended using, and while I know it's overkill, so long as it actually has a range from near 0V-5V I don't really care if it costs a bit more for something I'm only going to make once; I'd have just used the arduino's DAC, but obviously the range of that start at like 0.6V or something? I don't trust myself to come up with a clever solution so I'd rather just use overkill.

This is the data sheet for the AD8276 / AD8277 it's just a unity gain IA (Instrumentation Amplifier). Voltage in and voltage out. Looking at the linked data sheet take a look at page 17 figure 50. Not that transistor, a common little 2N3904 PNP is where the current happens. Right up to that point it's all about voltage. Pin 6 of the IA is driving the base of that transistor in its linear region. The values of R1 & R2 are critical and should be matched. That known the data sheet points out:

IO = 2.5V(1/40kΩ + 1/R1)
R1 = R2

That little formula is where we determine what Iout will be with respect to Vin. Everything right up to the base of that transistor is about voltage. All you need is a single DAC to drive the IA and the IA driving a transistor. Matter of fact since you only want 0 to 2 mA you likely don't need a transistor as long as your IA can source that much current into a load.You aren't looking at any current to speak of.

So your DAC needs a stable reference, your DAC drives an IA and that's about all there is to it.

Ron

AD8277 is an opamp with resistors, not an instrumentation amplifier - it doesn't have the 3-opamp configuration of a standard instrumentation amp, its designed to save you needing external precision resistors for a differential amp in high precision circuits.

To draw a meaningful circuit diagram using it you have to make the internal structure of the device explicit.

To provide 2mA there's no need for an external transistor, if you do use an external transistor it needs to be in emitter-follower configuration inside the feedback loop.

MarkT:
AD8277 is an opamp with resistors, not an instrumentation amplifier - it doesn't have the 3-opamp configuration of a standard instrumentation amp, its designed to save you needing external precision resistors for a differential amp in high precision circuits.

To draw a meaningful circuit diagram using it you have to make the internal structure of the device explicit.

To provide 2mA there's no need for an external transistor, if you do use an external transistor it needs to be in emitter-follower configuration inside the feedback loop.

Ah my real bad on that IA. I was sitting here looking at the data sheet and called it an IA which makes for worse.
Unity-Gain Difference Amplifier, should have been pretty easy to follow not to mention the internal drawings. :frowning:

Thanks
Ron

Sorry about it taking me so long to follow up on this, I got into the world's stupidest car accident just after posting and was distracted trying to deal with that. Hand drawn attempt at schematic.

So I'd seen this, so I'm not sure why I'd gotten so much of the current source wrong; I think I had it right in the KiCad file, so I'm not sure how transcribing it to Eagle went to very wrong. I think it's fixed now.

Given having a current sink in line with a source does nothing if they're set to the same current, as far as I know, I think I should probably just accept the second op amp in the AD8277 not being used and not needlessly complicate things. I'll remove the current sink and just connect the second jack to ground.

Is there anything obviously wrong with the design after those changes?

Hi,
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".
OR
http://forum.arduino.cc/index.php/topic,148850.0.html.

Ops Diagram.

Thanks.. Tom... :slight_smile: