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

Computer controlled PS/function gen/multimeter

I love the bus pirate and other opensource tools. I think the next step is to replace all the expensive bench equipment needed for analog electronics with one device.

I've always wanted a programmable/tracking power supply but they are very expensive. Any one got any ideas on building an inexpensive digitally controllable power supply? I'm thinking of an output range of .7-12 volts at 1A+. Could we get clean DC using PWM? To keep cost low an external PS would take care of knocking the mains down to low voltage DC.

Lots of measurement inputs is a must(multimeter functionality). The ability to measure DC & AC signals to at least 40khz and up to 220v with good auto ranging. So we need a good A2D converter, I'm thinking at least 16 bits and 96khz sample rate. I'd like to target 1Mhz. Any one got any ideas on how to handle over voltage, get good isolation and how to do the auto ranging?

For a function generator we could use something like the DS1077 programmable oscillator and a series of OPAMP circuits(filters, integrator and differentiator) and  to produce various waveforms. That would produce signals from 16khz to 133Mhz. Lower frequencies could be done with a DAC maybe or the micro-controllers PWM output.

The applications I'm thinking of are like graphing the curve of a diode or transistor. Scripting events for testing the limits of components and circuits. General testing and troubleshooting.

A serial console interface like the bus pirate would work ok. I'd like to see similar binary mode features and scripting.

I'd like to target under $100 but still keep the specs up.

Re: Open source project idea: Computer controlled PS/function gen/multimeter

Reply #1
I love it. I've wanted to make a digitally controlled adjustable power supply for a while. I always thought using a digital potentiometer on a LM317 would be a way.

One thing I'm reticent to do is work with line voltage, that's a little too dangerous for me.

It sounds like there'd be lots of analog work on the measurement and signal generators.

Maybe a lot could be done with crystals and programming counters/PLLs for the generator. I bet an FPGA or CPLD would help a lot.

I bet there's some existing open source stuff out there we can build on too.
Got a question? Please ask in the forum for the fastest answers.

Re: Open source project idea: Computer controlled PS/function gen/multimeter

Reply #2
[quote author="ian"]
One thing I'm reticent to do is work with line voltage, that's a little too dangerous for me.
[/quote]

Probably lots of people would suggest this but I think an ATX power supply would be a good starting point.

Re: Open source project idea: Computer controlled PS/function gen/multimeter

Reply #3
[quote author="garak"]To keep cost low an external PS would take care of knocking the mains down to low voltage DC.[/quote]One thing to keep in mind as a possibility is an AC adaptor instead of DC.  They're rare, but I have seen some products which come with a wall-wart adaptor that outputs AC instead of the typical DC.  Something around 20 V AC or less.  For some circuits you can do more with AC, especially if you want to generate a wide range of voltages.  Basically, an AC adaptor saves you from obtaining a high-voltage transformer and soldering 120 V AC yourself, but you still retain a wide range of options.

I subscribe to the Maxim newsletter, where they have recently mentioned articles on power monitoring systems.  You might be able to get some ideas from the following link: Signal conditioning for a sigma-delta ADC in industrial multichannel data acquisition systems

Re: Open source project idea: Computer controlled PS/function gen/multimeter

Reply #4
[quote author="garak"]
Lots of measurement inputs is a must(multimeter functionality). The ability to measure DC & AC signals to at least 40khz and up to 220v with good auto ranging.
[/quote]

Some parts of the world exceed 220v (our line voltage downunder is officially 240v - in reality it is closer to 260v most of the time to account for peak load). See http://www.controlledpwr.com/help-inter ... ltages.php for a good summary of official line voltages. A number of grey-market 220v rated computer peripherals have gone up in smoke round these parts :)

Re: Open source project idea: Computer controlled PS/function gen/multimeter

Reply #5
[quote author="Trev"]Some parts of the world exceed 220v (our line voltage downunder is officially 240v - in reality it is closer to 260v most of the time to account for peak load). See http://www.controlledpwr.com/help-inter ... ltages.php for a good summary of official line voltages. A number of grey-market 220v rated computer peripherals have gone up in smoke round these parts :)[/quote]Good point.  There's also the fact that even 120 VAC is an RMS measurement, not a peak measurement.  Circuits must handle peak voltages, so 170 V is the positive peak, and 340 V is the peak-to-peak total!

So, for 240 VAC, the peak-to-peak is 680 V !!  You might want to plan on 736 V if that 260 VAC is really RMS.

Re: Open source project idea: Computer controlled PS/function gen/multimeter

Reply #6
I think we can use a transformer to decrease the mains voltage to a more suitable level, like 110VAC->20VAC (which makes 110VAC->20VAC, manageable IMO)and then use that to obtain the output voltages. This way we can output AC or DC and any voltage we like if we throw in a dsPIC, we can interface it with a PC to update the firmware, control the power supply etc. I think it was a good decision to bring my power electronics book with me when I moved to Japan. :)

Re: Open source project idea: Computer controlled PS/function gen/multimeter

Reply #7
[quote author="tayken"]
I think we can use a transformer to decrease the mains voltage to a more suitable level, like 110VAC->20VAC (which makes 110VAC->20VAC, manageable IMO)and then use that to obtain the output voltages. This way we can output AC or DC and any voltage we like if we throw in a dsPIC, we can interface it with a PC to update the firmware, control the power supply etc.[/quote]I'm not sure I understand what you're saying when you jump from high-power transformer to mentioning DC, unless you're talking about the power supply function separately from the function generator.  DC does not translate through a transformer.  But if you limit the transformer to stepping down the AC mains, and use separate technology for medium voltage DC function generation, that works.

dsPIC is probably a good choice, or at least some kind of DSP.  I've not used the dsPIC yet (I have more experience with the TMS320).

Re: Open source project idea: Computer controlled PS/function gen/multimeter

Reply #8
My thoughts about the primary power supply is that it should be user supplied 12-24v. Most everyone has a few left over wallwarts and other power supplies from broken devices. Laptop PSU  are typically in the range of 18-24v and supply up to 5A. Also by the user supplying it them selfs there are no issues of the different voltages/line frequencies/connectors used world wide. Another plus is that it could be run of batteries for off grid hacking. With good A2D this device could be also used to monitor a solar or wind install.

I'm thinking the regulator should be a switching regular to keep heat dissipation and waste down. I my mind it seems really simple, PWM driving the input of a fairly fast MOSFET, a few caps to filter the output and then feed the output back into an A2D converter and have a software feedback loop adjust the PWM to get the desired voltage or current. But power control electronics are not my strong area. I have no idea what PWM frequency would be suitable nor what its going to take to make that chopped waveform nice steady DC. While at the same time keeping a reasonably low output impedance.

Another application that just pop'd in my head is battery charging. If this thing can do constant current output and has extra inputs that can monitor cell voltage and temperature (using say LM35) it would make a great battery charger. Maybe it could have different loadable profiles for different types of batteries.

The more I think about this thing, I think the function generator part could be a separate project, its more related to a scope anyway. I'm thinking the goal should be maybe a computer controlled current/voltage supply(maybe 2 independent outputs) and maybe 8 channels of high impedance, high resolution analog inputs.

It would be nice if 2 of the analog inputs could handle AC mains voltages and the rest be 0-12v DC. Sampling speed would be variable depending on the number of inputs used.

Just created a wiki page with a temporary name http://dangerousprototypes.com/docs/Potential_Pirate

Re: Open source project idea: Computer controlled PS/function gen/multimeter

Reply #9
[quote author="rsdio"]
I'm not sure I understand what you're saying when you jump from high-power transformer to mentioning DC, unless you're talking about the power supply function separately from the function generator.  DC does not translate through a transformer.  But if you limit the transformer to stepping down the AC mains, and use separate technology for medium voltage DC function generation, that works.
[/quote]

I was just talking about the power supply function. Of course I know a transformer is no good for DC, my logic was Mains -transformer-> ~20VAC -SMPS circuit-> DC output.

[quote author="rsdio"]
dsPIC is probably a good choice, or at least some kind of DSP.  I've not used the dsPIC yet (I have more experience with the TMS320).
[/quote]

We need some sort of DSP as these guys can handle the calculations needed pretty well. I remember my professor saying that one needs a 32bit controller for driving motors (which is similar to SMPS) but I think we can handle this pretty well with a 16bit controller. I said dsPIC as I am familiar with them (I use mostly 24F and they share a lot in common) and also it was used in the Web Platform so Ian knows them.

[quote author="garak"]
My thoughts about the primary power supply is that it should be user supplied 12-24v. Most everyone has a few left over wallwarts and other power supplies from broken devices. Laptop PSU  are typically in the range of 18-24v and supply up to 5A. Also by the user supplying it them selfs there are no issues of the different voltages/line frequencies/connectors used world wide. Another plus is that it could be run of batteries for off grid hacking. With good A2D this device could be also used to monitor a solar or wind install.
[/quote]

That passed through my mind but if we make the input connector an IEC-C5 one can buy an input cable from their own country to connect to the mains. Also a laptop PSU is a SMPS (specs of mine are Input: 100-240VAC 1.5A 50-60 Hz Output: 19VDC 3.42A) and we are connecting two SMPS in series which will decrease efficiency.

[quote author="garak"]
I'm thinking the regulator should be a switching regular to keep heat dissipation and waste down. I my mind it seems really simple, PWM driving the input of a fairly fast MOSFET, a few caps to filter the output and then feed the output back into an A2D converter and have a software feedback loop adjust the PWM to get the desired voltage or current. But power control electronics are not my strong area. I have no idea what PWM frequency would be suitable nor what its going to take to make that chopped waveform nice steady DC. While at the same time keeping a reasonably low output impedance.
[/quote]

A switch mode regulator is a good idea as with a linear regulator the efficiency decreases as the difference between input and output voltage increases. Generally 100kHz is used as far as I can remember but that depends on the inductor and FET you are using. I am no power electronics engineer too but I am a grad student in robotics and control and some of the motor drivers I use are just variable voltage sources.

[quote author="garak"]
The more I think about this thing, I think the function generator part could be a separate project, its more related to a scope anyway. I'm thinking the goal should be maybe a computer controlled current/voltage supply(maybe 2 independent outputs) and maybe 8 channels of high impedance, high resolution analog inputs.
[/quote]

I think we should stick to this too. I don't know if Ian can spare some time and maybe turn this into a Dangerous Prototypes project but I will be happy to contribute.

Re: Open source project idea: Computer controlled PS/function gen/multimeter

Reply #10
I'm even more excited, thanks for adding it to the wiki. I have to stuff some boards today and order parts, but after that I'll try to put some ink on paper for this project.

If we use a dsPIC we get high resolution ADC/DAC with some extra math crunching algos if we need them. The Bus Pirate firmware framework could be ported to a dsPIC if you wanted similar features.

How fast does the PC connection need to be? If you want to push lots of data live an integrated USB chip could be in order. If not, I think a UART with opto-isolation to a FTDI232 chip could provide a modicum of isolation for the PC.

If we keep the scope of the prototype and v1 at the minimum specs (with a wiki wishlist), we could get something out quite quickly.

My concern with the SMPS is getting a smooth supply. Joe at the Yahoo Switchmode list could point us in the right way. Here's a simple spreadsheet that can calculate the idea rise and fall time for a given inductor:
http://www.instructables.com/id/High-Vo ... teristics/

Here are some issues I don't know about (yet):
*Autoranging from high voltage to low voltage without killing the ADC input
*Constant current supply/load?? (recent EEVblog is helpful here: http://www.eevblog.com/2010/08/01/eevbl ... y-testing/ )
Got a question? Please ask in the forum for the fastest answers.

Re: Open source project idea: Computer controlled PS/function gen/multimeter

Reply #11
Just peaking at some PICs:

http://www.microchip.com/ParamChartSear ... &pageId=75

dspic: 24 x 10-bit @ 4000 (ksps) 4-D/A; 1 x 10-bit @ 640 (ksps) 2-A/D; 4 -Std. PWM 16-bit PWM resolution; 4 x 16-bit, 1 x 32-bit timers

If we're looking for 16bit DA or ADC then this isn't enough. Pretty impressive though. External parallel or SPI ADC/DAC options are possible too. The timers are nice, and the 16bit PWM x 4 is really handy.

http://www.microchip.com/wwwproducts/De ... e=en532303
9 x 10-bit @ 1100 (ksps) 1-D/A; 2 x 16-bit @ 100 (ksps) 1-A/D; 4 -Std. PWM 16-bit PWM resolution; 5 x 16-bit, 2 x 32-bit timers.

Fast 10bit DA, 16bit ADC is faster than your minimum, but only 2 of them. 4 16bit PWM, lots of timers.

I don't know if 1MSPS ADC is realistic without going to some parallel interface external ADC. Even a 1MSPS serial interface ADC with 16bits resolution will have to go 16Mhz+ SPI for the PIC to get the data at 1MSPS. And that's just for one ADC. I'm reticent to do that on a new design because the routing and sourcing gets so difficult that it's no fun to work on anymore. I'll try to find some PICs with multiple 16bit ADCs.

Anyone know of any ARM options? I don't want to get locked into PIC prematurely.
Got a question? Please ask in the forum for the fastest answers.

Re: Open source project idea: Computer controlled PS/function gen/multimeter

Reply #12
ADCs by PIC family:
24FJ family has 10+ 10bit @ 500ksps
24H has 10+ 12bit @ 500ksps
30F 12bit @200ksps, 10bit@1000ksps (1Msps)
33F 12bit @ 500ksps, 10bit @ 1Msps (some with DAC, some with 1-2 16bit ADCs @ 100ksps)

Also... For the function generator - Sjaak and I have something up our sleeves :)
Got a question? Please ask in the forum for the fastest answers.

Re: Open source project idea: Computer controlled PS/function gen/multimeter

Reply #13
Sorry, I seem to have forgotten the wiki that I just read... updated with your values.
Quote
Ideas for the Potential Pirate:
    * Bus pirate like USB/Serial interface
    * Two tracking power outputs that can either be voltage or current sources.
    * Several analog inputs.
    * Full multimeter like functionality on at least 2 analog inputs.
    * Low cost

Applications:
    * Curve tracing (diodes and other semiconductors)
    * Battery charging
    * General purpose bench power supply
    * Alternative energy monitoring
    * Instrumentation

Power supply objectives:
    * At least 1A per output
    * 0.7-12v range
    * Input of 12-24v DC
    * User supplied DC supply (reuse old laptop power supplies for example)
    * Software controlled constant current or constant voltage
    * Script-able control
    * Ability to set limits on current and voltage output (software breakers)
    * Any input can be used for current or voltage control/limits

Analog input objectives:
    * Ability to measure AC voltages up to mains
    * 16 bit resolution
    * High input impedance
    * 8 Inputs

Implementation ideas:
    * Atmega168 /w ft232 for usb/serial and 8channel SPI adc
    * Use 16bit PWM for power control
    * Use the 6 onboard A2D to monitor input voltage, 2 output voltages, 2 output currents (poor resolution, only 10bit, maybe good enough for input voltage and output current, but not output voltage)
    * Power switching MOSFETs???
    * Filtering Network???



Quote
a computer controlled current/voltage supply(maybe 2 independent outputs) and maybe 8 channels of high impedance, high resolution analog inputs.

Great description. It makes it a very definable, doable project.

We should define some goals/features:
*voltage source (0-12volt, 1A max)
*current source (0-1A)
*constant current load (0-XmA)
*voltage measurement (Xvolts max)
*current measurement (XmA max)

ADC
How many for:
current measurement
voltage measurement
internal feedback
internal voltage monitoring

We have a huge selection of PICs with up to 32 500ksps ADCs, but only at 10 or 12bits of resolution. A 16bit external ADC with serial interface for the channels that need high resolution is a good idea, did you already have a chip in mind?

I need some help on this part:
There will be voltage supplies with adjustable current and voltage. We'll need to measure voltage and current from there. I found this interesting page about using a coil of 12AWG wire for measuring current. We can probably auto-calibrate whatever resistive element we use (couple more ADCs, maybe 16bits...).

The measurement probes will be connected to an ADC. They also have a (switchable) current measurement feature that enables a resistive load that would need another ADC (and maybe calibration ADCs).

How about a constant current load?

[s:]My initial inclination is to start very small, maybe 2 or 4 16bit external ADC channels. Would current measurement be on separate channels/probes, or something that can be enabled from the PC? Or does each measurement channel have both voltage and current measurement all the time (since we're already supplying the power, we supply the ground, or I'm confused...)? (There really isn't an IC that provides this kind of data? Is there a vocabulary for what we're doing? I'm tongue tied trying to describe it).[/s:]

Power supply
Maybe it could have 0-37volts 1A with a adjustable regulator. It is a cheap, easy, and clean without a lot of engineering, heat is a problem at high currents. I'm not sure how much this is a bench supply and how much it is a testing instrument. I've been thinking of it more as a test instrument, my considerations are biased by that.

Quote
It would be nice if 2 of the analog inputs could handle AC mains voltages and the rest be 0-12v DC.
0-12vDC might be a good goal for the first prototype. Then the AC mains adapter circuit can be developed over time using the v1 hardware, used as an accessory, and added to a future version. I'm also nervous about DP being involved in anything that encourages you to stick it into live mains.

Constant load
This follows from the EEVblog link above. I'm not sure if this was a proposed feature, but it could be useful for component profiling.
Got a question? Please ask in the forum for the fastest answers.

Re: Open source project idea: Computer controlled PS/function gen/multimeter

Reply #14
[quote author="ian"]
Also... For the function generator - Sjaak and I have something up our sleeves :)
[/quote]

Sssst that [s:]is[/s:] was a secret!!!

For a autoranging voltmeter do a google on 'nuts and volt autoranging voltmeter' Then you'll directed to a small article which basicly uses a resistor with an 4066 analogue switch to switch between the different voltages. To prevent damage two diode restrict the voltage to +/-0.7V for the DAC and 4066. All you need are a couple of comparators to shift the voltage in the 0-xV range.