Skip to main content
Topic: Computer controlled PS/function gen/multimeter (Read 244135 times) previous topic - next topic

Re: Computer controlled PS/function gen/multimeter

Reply #105
[quote author="tayken"]I'm planning to drive the reference pin with an analog signal instead of connecting it directly to output voltage with a voltage divider. There will be a dynamic voltage divider inside the dsPIC, it'll adjust itself according to user settings (voltage or current required, voltage or current source) and the output voltage.[/quote]The key to regulation is feedback.  The question then becomes whether a dsPIC can possibly be as fast as an op-amp.  The A/D and DAC each have latency, plus the process is not continuous but must be scheduled on a periodic basic, which adds to the latency as well.

Is there a way to combine the feedback and the dsPIC control voltage so that the feedback it still instantaneous?

One answer may be expensive: A digital controlled potentiometer like the AD5204 at $3.42 for the AD5204BRZ10.  These have 256 taps.

Another option would be to literally sum the two, feedback and control voltage, but that would require negative voltages from the dsPIC DAC.  You might be able to fake that with a virtual ground above 0V.

Re: Computer controlled PS/function gen/multimeter

Reply #106
Of course there is the latency problem. And because of that I want to test my idea first. I ordered the board from Sure, plus some other stuff for future projects, when they arrive, I'll try to implement my suggestion with constant voltage setting.

I checked out digital potentiometers, they are expensive. Maybe the latency will be so small that the effects will not be important, but again, we have to do trial runs first.

[quote author="rsdio"]
Another option would be to literally sum the two, feedback and control voltage, but that would require negative voltages from the dsPIC DAC.  You might be able to fake that with a virtual ground above 0V.
[/quote]

DAC has a negative output, positive output and a middle value pins. Maybe we can use them to implement something like this. This way we would chance the control voltage but the feedback is directly to op-amp, which decreases latency significantly. One thing to look out for might be a possible oscillation of this system. Again, we need trials.

Re: Computer controlled PS/function gen/multimeter

Reply #107
[quote author="tayken"]
[quote author="rsdio"]
Another option would be to literally sum the two, feedback and control voltage, but that would require negative voltages from the dsPIC DAC.  You might be able to fake that with a virtual ground above 0V.
[/quote]DAC has a negative output, positive output and a middle value pins. Maybe we can use them to implement something like this. This way we would chance the control voltage but the feedback is directly to op-amp, which decreases latency significantly.[/quote]Nice, I hadn't looked at that part of the dsPIC data sheet yet.  The two signed outputs could be sent to the + and - inputs of an op-amp that has a bipolar supply, and then the output of that op-amp would go negative.  This would also expand the +3.3V dsPIC DAC output to twice the range, as +/-3.3V (I think that the 3rd DAC output would not be used at the same time)

Re: Computer controlled PS/function gen/multimeter

Reply #108
I don't have an idea to how to use that! :) I'm just giving some key information so that you "experts" may give the best advice to me. I will check DAC reference manual to see some examples and how it can be used etc.

Re: Computer controlled PS/function gen/multimeter

Reply #109
You can set up an op-amp in a differential configuration, where the output is basically the voltage on the + input minus the voltage on the - input (there will be precision resistors ahead of each actual input pin).  The DAC in the dsPIC can only put out positive voltages from 0V to 3.3V, but the DAC is configured to basically send the positive half to one output and the negative half to the other output.

When you send the maximum positive value to the signed DAC, the positive output is at full 3.3V and the negative output is at 0V.  The output of the op-amp will be A-B=C, or +3.3V - +0V = +3.3V.

When you send the maximum negative value to the signed DAC, the positive output is at 0V and the negative output is at +3.3V.  The output of the op-amp will still be A-B=C, but this time +0V - +3.3V = -3.3V!

At mid scale on the signed DAC, both the positive and negative outputs will be at 1.65V, and the op-amp will output 0V because +1.65V - +1.65V = 0V

At values between these interesting points, the outputs remain complementary to each other - basically a fully balanced signal.  A nice side effect of this is that much of the DAC switching and power supply noise can be cancelled out by a proper balanced design like this.

In order for this to work, the op-amp needs at least +/-3.3V on its power if it is capable of rail-to-rail outputs, or hopefully substantially more.  If you put +/-5V on the op-amp power, then it will certainly be able to output negative voltages down to -3.3V, even though it's inputs from dsPIC are always positive.

One thing to keep in mind is that both DAC outputs will never be +3.3V at the same time, nor will they ever both be 0V at the same time.  If you look at the implementation of the DAC, it actually uses each bit to direct current to either the negative output or the positive output, making the DAC actually run faster because current is always flowing no matter what the bit value is.  The trick is that this sort of DAC is actually current output internally, so there needs to be a current-to-voltage conversion in there somewhere.  Thankfully, Microchip seems to have handled this for you.  I've used a Texas Instruments DAC, the THS5671A, where you have to deal with the current output directly.  Makes things even faster, I suppose, but the circuitry is even trickier, especially if you don't have a negative supply.

Re: Computer controlled PS/function gen/multimeter

Reply #110
I'll be digesting rsdio's post for the rest of the weekend. I'm starting to sketch some circuit ideas on paper, but I need to do a lot of reading before any of it is more than a guess.

For pots (I forget the context of the discussion, sorry if this is irrelevant) - Microchip has a 7bit I2C pot, and most PICs have an internal 64 step+ CVRref. I just found out the Bus Pirate PIC had it yesterday, didn't know...
Got a question? Please ask in the forum for the fastest answers.

Re: Computer controlled PS/function gen/multimeter

Reply #111
After that long description of how a typical differential DAC works, I read the fine print in the dsPIC data sheet:
Quote
The DAC module is designed specifically for audio applications and is not recommended for control type applications.

p.265

This makes total sense because the dsPIC DAC is delta sigma.  Therefore, you will want either an external DAC, which could be differential as described above and/or SPI, or you can change from dsPIC to a PIC with a standard DAC that is compatible with control type applications.  In other words, the differential output aspect of the dsPIC DAC is not a problem, but the delta sigma (∆∑) is a problem.

Re: Computer controlled PS/function gen/multimeter

Reply #112
I would definitely recommend against trying to route the feedback loop of a linear regulator through the PIC (i.e. ADC->processing->DAC). A DSP switching regulator is not as much of a problem because you're not relying on a precise operating point (perfect equlibrium of feedback input and control output), you're rather just controlling a switching element between two states, or in the case of a buck regulator simply the PWM ratio.
In contrast, if you're - for example - driving the base of transistor from a DAC output, the slightest discrete change in DAC value can change the output considerably. An op-amp will definitely do a better job at this since it's infinitely variable, and so much quicker than any software you can write.

Anyway, I hacked a bit at the problem and sketched up a simple linear regulator whose target voltage and current limit are controlled by any arbitrary DC voltage (DAC output, smoothed PWM output, etc.)

The circuit is heavily based on the E3620 topology, but I changed a couple of things to adapt to our context : no negative supplies, and voltage control instead of potentiometers.
Q1 is the pass transistor, and by default R2 tends to keep it conducting much more than necessary. Q3 is a kind of "choke driver" : the harder it's driven, the more it chokes the pass element, hence reducing the output voltage. This Q3 can be turned on by either the voltage control loop or the current limit loop.
Voltage regulating:
V2 could be a DAC output from a 3.3V PIC. Op-amp U3 multiplies its range to 0-13.2V, which will become the target voltage for U1, the voltage error amplifier. When the output voltage is higher than the control voltage, U1 increases its output, choking Q1.
Current limiting:
V3 is like V2 except it controls the maximum current. As it's configured , a 1V input will set the limit to 1000mA. This is simply I*R6. U4 is a type of difference amplifier : U4(output) = V(out) - V3
This shifted voltage is compared to the voltage drop accross the sense resistor. U2 accordingly chokes Q1 if the current is too high.

The circuit seems to simulate pretty well, but it would need to have a few things tweaked :
- op-amp selection. Rail-to-rail operation is essential, other characteristics will affect loop stability.
- pass transistor selection - many TO-220 or TO-3 devices will probably work, but some adjustment of R2 may be necessary.
- loop stability ! My pole / zero theory is very sketchy.
- current sensing -  to let the PIC read the actual current draw, there are two ways: measure voltages before and after R6 with voltage dividers and subtract the two in software, or add another op-amp (differential amplifier) which is more precise, but brings the total of op-amps to 5! So much for the quad.
One way of reducing number of op-amps would be to move the current sensing to the low side of the load, but then that complicates the ground configuration (power ground, sensing ground, chassis, etc..)
However, by taking each side of R6 and resistively dividing by 4, we get a sensitivity of 0.25mV / mA at the ADC input. I think this is plenty enough for the intended use, but some people might want more...

Re: Computer controlled PS/function gen/multimeter

Reply #113
Ah, I thought there had to be a way. I simplified the current limiting a lot, now it needs only one op-amp instead of 2. So, the fourth amp in a quad package could be use as a diff. amp to measure the load current !

Re: Computer controlled PS/function gen/multimeter

Reply #114
[quote author="fenugrec"]- current sensing -  to let the PIC read the actual current draw, there are two ways: measure voltages before and after R6 with voltage dividers and subtract the two in software, or add another op-amp (differential amplifier) which is more precise, but brings the total of op-amps to 5! So much for the quad.
One way of reducing number of op-amps would be to move the current sensing to the low side of the load, but then that complicates the ground configuration (power ground, sensing ground, chassis, etc..)
[/quote]That's a very good point.  However, I really like the Analog Devices AD8293G80/160 with built-in gain that tayken found for the differential current sensing.  Using an low-cost part like that means you're back to 4 op-amps for the remaining circuits.  Plus, you get the benefit of way more current-sensing accuracy without worrying so much about ADC bit depth, quantization noise, or digital clock noise causing problems.

Re: Computer controlled PS/function gen/multimeter

Reply #115
For current sensing I have used  the Hall Effect-Based Linear Current Sensor IC from Allegro.  It is isolated and has virtually zero voltage drop so you can place it on the highside or lowside.  I have also used the Amploc/ sensors. They are isolated but they are for wire current sensing.

There is the SentronHall CSA-1V Current Sensor
Quote
The CSA-1V current sensor is placed on a
PCB directly over the current track. The
current track can consist of one or several
loops, depending on the maximum current
to be measured. The sensor measures the
magnetic field emanating from the current
flowing through the tracks.

I have not used it other than samples.

I have used the Allegro and Amploc in military qualified products.  They run on 5v and output 0-5v so I had to use a voltage divider to drive the ADC on a TI DSP.  Zero current is 2.5v output.  I did not have to use a buffer/opamp.  The ACS712's measured phase current of a three phase servo motor.  The TI DSP's internal ADC sampled at 12Mhz and used the current measurements to sense the rotor position in a FOV motor controller driver.

With the Amploc sensor the currents were 100++A so besides feeding the output to the DSP I used the TSM102A to scale the output and compare the voltage to the reference.  I have attached the schematic.
"Too many projects, so little time"

Re: Computer controlled PS/function gen/multimeter

Reply #116
[quote author="rsdio"]
However, I really like the Analog Devices AD8293G80/160 with built-in gain that tayken found for the differential current sensing.  Using an low-cost part like that means you're back to 4 op-amps for the remaining circuits.
[/quote]
~ 2$ from Digikey
Quote
For current sensing I have used  the Hall Effect-Based Linear Current Sensor IC from Allegro.
~ 5$ from DK

Don't get me wrong,  they're nice devices, but they're a bit expensive ! I don't know the exact intent of this project, but I figure: if the goal is to have a multimeter section as well as a PSU, the current-measuring needs are different anyway. The current measurement from the power supply realistically doesn't need more resolution than 1 mA... Many, many lab PSUs don't measure current that precisely (or just have an analog gauge) either.
Also, since one quad op-amp would be enough to include a current sensing amp, we can use the whole ADC range. For example if Rs = 1 ohm, diff amp gain = 3 and max ADC = 3.3V, then a 10-bit sample will give almost exactly 1mA resolution while covering 0 - 1.1A. I know this is going to be affected by the precision of the resistors used in the diff amp stage, and the LSB of the sample is not very significative, but it's still a usable measure.

What I would suggest would be: to keep a simple current measurement directly off the current sense resistor to enable the PIC to determine the state of the linear regulator (current limiting is taking place, no load present, max power reached, etc.)  Then, as required, a better current bridge could be built in "multimeter" section and allow better flexibility, precision, electrical isolation, measurement range, etc..

Anyway, that's just my take on the project, I don't really intend to steer it either way.

Re: Computer controlled PS/function gen/multimeter

Reply #117
One thing you have to be careful of is parts cost vs labor.  Even if you are using a chip shooter,  each part counts as a labour cost.  Manually I can place and hand solder a 16 pin SOIC faster than I can 8x 805's.  On a chip shooter each part counts as a placement not the total number of pins.  A 16 pin part counts as one placement and the 805's count as 8 placements.  Eight times the duration of assembly.

I dont know Seeeds parts vs labour costs but any case it is a tradeoff.  In this case the 20+ discrete parts cost is probably very cheap in China so the labour is going to the big cost.

Another interesting area is reliablilty.  The more parts, the less the reliablity, obvious.  A 16 pin SOIC is more rugged than 8x 805's.
"Too many projects, so little time"

Re: Computer controlled PS/function gen/multimeter

Reply #118
Hmm, lots of ideas, lots to try. The multimeter part is not so necessary I think, the real idea is to produce a cheap computer controlled voltage/current supply/sink. Current sink will be a different section (Dave's schematic from Eevblog, maybe change it a little). Maybe we should get an idea from Ian about part selection as he did some job with Seeed. Also he can contact them about parts cost and manufacturing cost and other stuff and steer us in the right direction.

The only thing that I am having trouble with is getting a constant current output. That is not maximum current setting, will we able to get a constant current even if the load changes by adjusting V2?

I'm waiting for some parts to come and can probably try some ideas after they come.

Re: Computer controlled PS/function gen/multimeter

Reply #119
@fenugrec - this is fantastic and elegant, thank you for sharing. Would you be willing to attach the simulation file? In terms of the how-to article that goes with a design, it is a great teaching tool for so many concepts.

How many of the resistors need to be super precise? Can we compensate for any of them with calibration on the microcontroller?

In terms of cost - Last I heard our quotes are per pin. I do know that PCB complexity (size, holes, sides) does not figure in at all for the size things we do. I don't get a full breakdown of the quote basis though. I will ask, and make a wiki page with best practices to keep costs low. The placement time cost point is well taken, if only for the pareto efficiency. I've been trying to find a friendly (size, availability) multiple R package to use in general.
Got a question? Please ask in the forum for the fastest answers.