Sciencemadness Discussion Board

Electrolysis power supply

12AX7 - 23-4-2010 at 10:29

The long awaited(?) design is here. :D

http://webpages.charter.net/dawill/tmoranwms/Circuits_2010/H...
http://webpages.charter.net/dawill/tmoranwms/Circuits_2010/H...
http://webpages.charter.net/dawill/tmoranwms/Circuits_2010/H...
http://webpages.charter.net/dawill/tmoranwms/Circuits_2010/H...
http://webpages.charter.net/dawill/tmoranwms/Circuits_2010/H...

Over 90% efficiency, >0.99 power factor, 5V at up to 100A output. Adjustable and programmable voltage and current limits. Digital control, timing, charge integration and so on.

Tim

quicksilver - 23-4-2010 at 11:23

DAMN! Bro' did you work up that schematic? That is a really well done job!

When you have something of high current, you really can't work that out on a breadboard (the little clips will fry, it seems) -- So how do you work out prototypes?

12AX7 - 23-4-2010 at 13:10

Easy, you build it. ;)



This is my senior project so I shall release it under GPL.

Funny thing about those little clips (alligator clips, that is), on one occasion I had the oscilloscope probe ground lead clipped to a capacitor. Turns out it had been touching both leads of said capacitor, thus "shorting" the output. It cleared this fault quite effectively at around 0.2V and 50A, coincident with a little puff of smoke. Bye bye capacitor lead. :D

Tim

quicksilver - 24-4-2010 at 04:57

The large toroids catch the eye. Those are not "store bought" are they?
Have you begun to "light her up" and try for a week or so test?
I have a 5Vdc switching supply that I bought surplus. It needs two high end fans to draw the air over the contents. In your design I see no provision was made for strong cooling. Does it not need it or has it not been presented in the initial design?

watson.fawkes - 24-4-2010 at 07:43

Quote: Originally posted by 12AX7  
Over 90% efficiency, >0.99 power factor, 5V at up to 100A output. Adjustable and programmable voltage and current limits. Digital control, timing, charge integration and so on.
Good work. I have some questions. Naturally.

What kind of pulse frequency are you using on the PWM? I see you're using a gate drive transformer, so it must be reasonably high. What's the typical duty cycle? What's the magnitude of your output ripple?

Your output filters are in the schematic as three turns and four turns, but I see a pair of five turn ones in the picture. Was this construction tuning, or what? I assume that this must be related to the pulse frequency.

I have to admit I don't understand the power factor correction circuit, but I'm assuming that's because I don't have time this morning to read the data sheet on the FAN7527 you're using.

You're taking OUT1 and OUT2 for the rectifier section from the first gate driver of its pair rather than from the PWM controller directly. Is this just a matter of buffering the PWM output? Or is there some zero-crossing timing subtlety going on?

What are the decoder outputs for? If I had to guess, I'd say "for inspection during code development", but I can just ask you instead.

Is there an ICSP header on the prototype board? I don't see it. Or is it taken off as discrete wires? I mean, your microcontroller isn't socketed. Brave man. Not even any optocouplers.

I assume that signals CFB and VFB are those for current and voltage sensing. But then what's VCOMP for that generates the actual analog signal into the controller?

I don't see an analog crowbar circuit. How are you dealing with an output short condition?

12AX7 - 24-4-2010 at 08:59

On closer inspection, you should also notice there's none of the familiar PFC parts on that board, nor a 40 pin DIP and its support hardware. That's just the PWM board (drawings 2 and 3). :)

This is the PFC board,



and this is the MCU board.



1. The TL598 oscillator runs around 240kHz, i.e. the output is 120kHz. Duty varies from 0 to 43% (per output), controlled by the voltage and current error amps. I haven't measured output ripple yet but it should be small.

2. Turns out I could fit 5T on there, so I did. More inductance, the merrier!

3. FAN7527 is a typical PFC chip. It operates by turning on the MOSFET switch until inductor current reaches a certain peak value, then turns off until current falls to zero, where it restarts. By varying the peak current, the average (= 1/2 peak, since current takes on a triangular shape) can be varied. A multiplier circuit mixes supply voltage (i.e., humps of rectified line voltage) with the error signal, thus modulating currect draw by voltage. Since voltage and current are proportional, the power factor is 0.99 or better. If a straight rectifier and filter capacitor were chosen, PF might be 0.5 or less! Finally, the error amp, which must be slow enough that it doesn't react to line frequency, regulates the average output to 406-412VDC over all supply and load values.

4. OUT1 and OUT2 must be inverted -- analyze the circuit carefully to see why this is so. The first pairs of transistors accomplish this. The second pair inverts it again, so the gate drive transformer is driven in phase. Hmm... I suppose the second stage isn't really necessary, due to the way the GDT is wired. Oh well.

As for delay, ideally the GDT gets driven first, as it has more delay (20ns lost through the transformer, 50ns at the transistors, another 40ns or so at the OPT). The total skew isn't too horrible as shown (~200ns), which may increase switching losses.

5. The decoder outputs are intended to control process equipment, for example if you programmed a sequence to drive 10 faraday of charge, then activate a series of pumps to introduce a new batch of electrolyte. The PWM output is intended for higher frequency switching, like if you added a phase reversal circuit in order to do high-throw electroplating.

The program is not currently setup for external inputs, but as you can see, a few ADC inputs are available which could be buffered to, say, a pH probe. A secondary program might be setup to control pH via the decoder outputs, operating an acid pump for instance. In this way, a completely automated chlorate cell could operate simply by adding raw materials and performing maintenence as required.

6. The ICSP header was changed to a 6 pin header, for use with the AVR ISP mk II.

7. Vcomp leads to a compensation capacitor, stabilizing the feedback loop. DC feedback is from the output (VFB).

8. No crowbar is provided to prevent voltage overshoot because in the intended use, this is not a problem. If you use this for digital logic supply, it would be wise to add one, and also tweak the feedback loop to minimize overshoot.

The inverter is current protected (CFB and associated circuitry).

Tim

watson.fawkes - 24-4-2010 at 10:14

Quote: Originally posted by 12AX7  
On closer inspection, you should also notice there's none of the familiar PFC parts on that board, nor a 40 pin DIP and its support hardware. That's just the PWM board (drawings 2 and 3). :)
D'oh! I didn't even think to count parts.

Thanks for your responses.

I have a couple of comments, mostly about a device boundary for publication. First, I would recommend publishing with a crowbar circuit in place. This is not for your personal benefit, or anybody else with enough experience to avoid shorting the output by accident, but there are plenty of folks who'll want one of these and don't have that kind of experience and thus who, a fortiori, won't know how to design a crowbar or even know what one is. If I build one, I'll put one in, just because I've got other folks around who aren't as experienced as I am.

Second, I'd recommend packaging the supply as just as supply and not as a supply-with-process-controller. Again, I'm sure this is just fine for you, because you're intimately familiar with the control software and intuitively know what not to do in software. Other people won't know any of that. Admittedly, this means you'd need a proper data interface, perhaps even USB, and some kind of protocol, and that's a chunk of extra work. But it would improve resiliency of the supply as a separate unit that would just work and could be relied upon. What I'd do in this case would be to use a daughter board as interface. That would allow for one board with buttons and a display and another microcontroller, and this board would be for completely detached operation. Another daughter board would have a network interface. Etc.

I'd enjoy hearing from Swede here on how he'd integrate such a power supply into his existing rig, which already does a bunch of data capture.

12AX7 - 24-4-2010 at 11:26

I still don't know what exactly you think "crowbar" means. A crowbar is NOT a short circuit protection device as you seem to imply. It is an overvoltage protection device, which shorts the output brute-force, in order to protect any attached circuitry.

For example, a nominal 5V supply powering a bank of digital logic boards, which fail above 6V, would require a crowbar at about 5.5V to protect it from surges. The fate of the power supply is of no interest because it's cheaper than the logic boards, though it would be useful to make the supply handle such an overload gracefully.

This power supply is inherently current limited so it will handle a crowbar or other short-circuit fault gracefully.

As it is, the three boards stand alone and can be used effectively as such. For example, the PWM board can be used with a conventional line filter and rectifier/doubler circuit for 120/240V operation, making it overall very similar indeed to a conventional ATX power supply. The downside is poor power factor and two voltage input only (not universal input).

The PFC board can be added to improve power factor and accommodate any line voltage in the world.

The MCU board only provides voltage and current control signals to the PWM board, which can be supplied with potentiometers instead, thus making a conventional regulated voltage supply with adjustable current limit. If programmable operation is not required, it can be omitted.

The power supply can be programmed on screen, no need for USB or whatever. The RS232 interface allows serial connection (which can be connected via USB dongle, if you prefer USB) for control by remote computer. None of this requires knowledge of the internal programming, though the intrepid user could reprogram his microcontroller using the internal ISP port. Microcontrollers can be programmed before installation, so the end user doesn't need any knowledge of programming to use it.

Tim

densest - 24-4-2010 at 12:55

Very nice!

Are you going to publish PCB layouts or sell etched PCBs? They're the biggest
hurdle for most amateur builders. Getting 10 PCBs made is usually only a little
more expensive than getting 1 :(

How did you calculate loop stability over the 10:1 output voltage range? Or did you
do a worst case for the highest gain?

BTW I have a dozen or so pairs of TSF 8040 material 42-21-15 E ungapped cores and a hundred or so bobbins with pins to fit. I think they'd work for this design. Electronic Goldmine was selling similar cores with a gapped center recently which could work for the PFC inductor.


[Edited on 24-4-2010 by densest]

12AX7 - 24-4-2010 at 13:04

Calculate loop? Wazzat?

^ In fact, just last quarter I took a control system analysis class. Stuff like Routh-Hurwitz and root locus. Outdated, abstract and utterly useless.

I haven't tested transient response yet. Adjustment entails substituting values for compensation capacitors, adding a zero (R+C), etc. I have tested the PFC controller and discovered it is unstable with the PWM board as load, so it needs adjustment. I have the knowledge to evaluate a control loop, but having learned to adjust them by the seat of my pants, I am quite satisfied to continue doing so.

Stability should be fine over the entire voltage range. Nothing in the system changes with respect to voltage. The inductances change slightly at high currents (dropping by about half at 100A), causing the filter's cutoff frequency to rise by about 1.4x. No big deal. The only problem is the discontinuity when duty approaches zero, which causes hysteretic behavior and oscillation. This is inevitable.

Your cores seem to be:
http://www.tscinternational.com/8040graphpage.pdf material
http://www.tscinternational.net/422115.html TSC store
which I guess is like a 3F3 or type 43 medium permeability ferrite.
Ewwww, the TSC store homepage has a rather annoying MIDI file on it. :-!

The 42-21-15 appears to have overall dimensions 42mm x 21 x 15.44 mm, a 30.32 x 9.13 mm winding window when assembled, with l_e = 97.23mm, A_e = 181.5 mm^2, V_e = 17.644 cm^3, W_a = 276.9 mm^2, m = 89.6 g and A_L = 6.57 uH/t^2.

The core I got is almost twice as thick, so you'll need to either ~double the number of turns (with copper strap, you don't want that), double up the core (can't use the same bobbin), or double the frequency (unwise, although not impossible).

One thing you cannot do is use two transformers, because the secondary winding must have extremely low leakage inductance from end to end. As constructed, a transmission line is formed between the circuit board ground plane, going up through the transformer, enclosing very little area = generating very little inductance. Low inductance is necessary because, when one side of the synchronous rectifier turns off, stray inductance will generate a flyback pulse, and when that stray inductance is charged to 100A or so, a lot of power will be dissipated by the snubber, trashing efficiency.

Tim

[Edited on 4-24-2010 by 12AX7]

Rosco Bodine - 25-4-2010 at 06:45

For the cannibals amongst you, there may be a tasty morsel in this

http://cgi.ebay.com/NJE-5VDC-200A-Power-Supply-5-Volt-200-Am...

chief - 25-4-2010 at 11:41

At least in some countries you can't just market anything that runs on mains power ...; you would need permissions, need to be a person who can get permissions, would need to have the design approved etc., at least in Germany ...

==> So for electric circuitry the only thing one can sell is something that runs on battery or incorporates a commercial power-supply ...

======================

But you might sell it as "functionable artwork", "only to be operated by qualified personnel" ... :D

Mr. Wizard - 25-4-2010 at 12:09

Quote: Originally posted by chief  
At least in some countries you can't just market anything that runs on mains power ...; you would need permissions, need to be a person who can get permissions, would need to have the design approved etc., at least in Germany ...

==> So for electric circuitry the only thing one can sell is something that runs on battery or incorporates a commercial power-supply ...

======================

But you might sell it as "functionable artwork", "only to be operated by qualified personnel" ... :D


Seriously? Here in the US, we barbarians are allowed to pull whatever we want out of the mains, as long as we don't pop our breakers, and pay the bill. There are limits; if you start sending spikes back up the line or causing problems with radio interference, somebody will tell you to stop. Wiring installation codes are followed, but nobody would ever think about asking for permission to install a damned electrolysis power supply, welder, or even a kilowatt radio transmitter, provided you were licensed to operate one.

It's a different type of outlook I guess.


12AX7 - 25-4-2010 at 15:30

In the E.U., you just slap a CE sticker on it. No one ever bothers to ask... just look at all the Chinese crap that obviously doesn't satisfy CE regs yet has the hologrammed stickers and everything. In China, hologram stickers are a few bucks a roll.

Tim

Contrabasso - 26-4-2010 at 10:07

CE in reality means China Export, except for some curious people called Eurocrats!

You should have CE for when you place a product on the european market. Not a design for consideration.

quicksilver - 26-4-2010 at 13:56

Remember the TV shows that illustrated what Underwriter Labs did in tests? It was around the time we would watch Mutual of Omaha's Wild Kingdom.

If I do buy electronics I really make an effort to buy US, Japanese, or EU stuff. If anyone is interested I have some really good places for Lamda Power Supplies (PM me). I've learned that I have a tough time getting a PC board as neat & clean as 12AX7: but I get better @ hiding my work in boxes.

watson.fawkes - 27-4-2010 at 05:18

Quote: Originally posted by 12AX7  
I still don't know what exactly you think "crowbar" means. A crowbar is NOT a short circuit protection device as you seem to imply. [...] This power supply is inherently current limited so it will handle a crowbar or other short-circuit fault gracefully.
Well, OK. I use the term "crowbar" in my head to refer to both over-voltage and over-current conditions. I was indeed thinking primarily of over-current.

Have you tried using the supply as a welder? This is the case I was most concerned about, that an inadvertent use of one in this mode would cause something Horribly Wrong to happen. I mean, 5V @ 100A makes a good resistance welding supply.

More generally, I don't understand why it's inherently current limited, but then again I've not spend any significant time working with a synchronous rectifier. I can see how the output filters give in an inherent impedance at f > 0, but not how it's limited at DC. Is it in the PFC circuit?

12AX7 - 27-4-2010 at 15:20

The inverter is always switching, so it is always sending current into the OPT and therefore inducing current in the current transformer. This feeds back to the current error amplifier, closing the loop in current.

Tim

watson.fawkes - 27-4-2010 at 21:59

Quote: Originally posted by 12AX7  
The inverter is always switching, so it is always sending current into the OPT and therefore inducing current in the current transformer. This feeds back to the current error amplifier, closing the loop in current.
OK, thanks. It helps to have time to read the chip sheets. The piece I was missing is that it's the TL598 and its current fixed point that's preventing over-current. I had been looking for something in the discrete part of the circuit.

[Edited on 28-4-2010 by watson.fawkes]

densest - 27-4-2010 at 22:40

I'm curious that you didn't use the OC pin on the half-bridge stage - the HV cap after the PFC holds 30+ J.

chief - 28-4-2010 at 00:43

How complicated ...
==> How much can you electrolyze with this ? 5V == 1 cell ... ...:D ; with the 100 A you can make 1kg of chlorate each day ...

=============

So my idea would be to construct some serious rectifier and have a big transformer ..., with enough voltage for several cells ... :
==> The rectifier, if capable of 100 A, will do it also for 20-30 Volts, which gives 4-6 cells, capable of electrolyzing 5 kg per day ... (chlorate anyhow only as example ...)

==> or maybe a 100$-welding-supply, of the switching type, would do well: I has maybe 40-80 Volts at a lot of amperes ...

Anyhow a 10-liter cell with 80 A will be constantly sub-boiling, evaporate half of it's content per day, spray a lot of salt anywhere etc. ...
==> So more cells need to be run, in series ...

A good old transformer is much easier to setup with a rectification, also mor failsafe ...

12AX7 - 28-4-2010 at 06:49

Quote: Originally posted by densest  
I'm curious that you didn't use the OC pin on the half-bridge stage - the HV cap after the PFC holds 30+ J.


1. Output Control is a half wave / full wave toggle. When enabled, the outputs are driven in parallel. This is useful for buck, flyback and half wave converters, but useless for full-wave (as this is).

2. Yes, the HV cap holds a substantial charge. I don't see where you were going with that...

Quote: Originally posted by chief  

So my idea would be to construct some serious rectifier and have a big transformer ..., with enough voltage for several cells ... :


Ah, but then you completely lose ALL controllability, plus your power factor is down in the sewer!

Quote:
==> or maybe a 100$-welding-supply, of the switching type, would do well: I has maybe 40-80 Volts at a lot of amperes ...


But it probably also has bad power factor (I don't actually know if inverter welders have PFC, but you will neither find a new inverter welder nor one with PFC for the sum of $100!), a completely different controller (maybe current regulated to some extent), and none of the fancy schmancy features, like automated setpoints, timering and charge integration.

Tim

[Edited on 4-28-2010 by 12AX7]

densest - 28-4-2010 at 13:22

Tim - sorry, I naively read "OC" as "overcurrent" which is how some manufacturers have labeled their chips.

My guess was that the cap is big enough to fry FETs. I'm painting my face very red since I overlooked the current transformer feedback :o switching back and forth between diagrams. I'm assuming the time constant is small, & the settings limit switch current to 5A or less, so all is copacetic. My apologies.

As for compensating the loops, I've used SPICE with some success. Some of the IC- manufacturer provided versions model the AC behavior of the switching chips well enough so that all one has to do is break the feedback loop & get a Bode plot of the transfer function. Play with the compensation components until it looks right. Without the IC model, it's a little trickier to model the loop gain & so on from the chip specs, but still doable.


[Edited on 28-4-2010 by densest]

chief - 28-4-2010 at 13:54

Whats the big deal with the power-factor-correction ?
==> Any transformer can just be corrected with a capacitor ...

In the good old days they used mains-voltage, divided through a lot of cells ...
==> That's not even the worst idea, if it can be handled safely ...
==> because with a lousy 10-A-rectifier-bridge you can send those 10 A through 50 or more cells, giving 5+ kg of chlorate each day ..., on almost no electrical equipment ...

Maybe on such small currents even carbon-electrodes would last a while ... : Does anyone know ?



[Edited on 28-4-2010 by chief]

densest - 28-4-2010 at 14:23

@chief - the PFC term is only partially correct - it's short for power factor & harmonic current correction. A motor, transformers, or any other linear device (like a tungsten light bulb) draws a current which is exactly proportional to the line voltage. That only takes adding a capacitor or inductor to make the current drawn from the mains exactly in phase with the mains voltage.

Anything nonlinear, like a rectifier, passes current nonlinearly with respect to the applied voltage. Typical "linear" power supplies with a transformer, rectifiers, and filter capacitors draw current in spikes at the peak of the input voltage. Those spikes cause problems in a number of ways. Mathematically, the current wave is equivalent to the line frequency with large amounts of harmonics at higher frequencies. The power system is not, and never will be, designed to handle that current. The harmonic currents can cause transformers and wires to overheat, interfere with power switching equipment, and cause other devices connected to the mains nearby to fail. Power providers have had to increase generating capacity to ameliorate this a little at large cost and no return.

With these problems in mind, the EC requires that new electrical devices must draw essentially sinusoidal current from the mains. The "PFC" label is a shorthand for fixing power factor & harmonic currents, and overlaps with RFI/EMI suppression.

Even if there is no capacitor after a transformer and rectifier, I'm not sure that current through electrolytic cells is linear. If an energy-consuming reaction has a threshold voltage, then up to that voltage a current would flow proportional to the mobile ion density in solution, but above that voltage current would also flow to power the reaction. This bump of current is what the so-called PFC circuits are supposed to prevent. As I mentioned earlier, large amounts of this nonlinear current can cause transformer overheating.

One further point - rectified mains voltage is either half a sine wave or a sine wave "folded" so the pulses all go in one direction. That causes the cell to see peaks and valleys of voltage. If there are multiple cell reactions with different voltages, the mix of reactions could surprise you if you think that the cell is seeing a constant voltage, especially if there are reverse reactions which take place below a certain voltage - the cell would see 0 volts 50/60/100/120 times a second. That could damage electrodes or reduce yield.


12AX7 - 28-4-2010 at 15:43

Thank you for an excellent explanation.

Another issue more practical: since a poor power factor causes excessive current draw (relative to the amount of real power delivered), you can be drawing about 1000W from an ordinary 120V, 20A circuit, yet blow the breaker! Power factor correction allows you to use the full rated power that circuit can deliver.

Tim

quicksilver - 15-5-2010 at 09:31

That was an excellent & concise explanation.
Just my opinion but it also bears fruit when looking at certain PSU designed for non-linear operation. However there may be a difficult variable in a formula for the level of the given capacitence & more. Within the solution of an Electrolysis environment there may be "fast or sudden" variables as well as slower variables. {I only say this due to designs using IC's instead of a overly large capacitor. Instead of a "big gulp" they are making corrections hundreds of times a sec.} If the capacitor alone could manage such a thing, there would be designs using the super capacitors common today in Farad level capasitence.

I saw this recently in a HV supply for a plasma unit. The design included a CPU & I realized that the factors affecting the gases would change both very intermittently and over the course of a day (outside temp, etc).
That's not to say that a simple design with a HUGE cap, great method of cooling, etc - would not work funtion but I would think that the "smart" PSU would be easier on the electrodes & produce a larger or faster yield.

chief - 16-5-2010 at 00:53

What about using some old PC: The soundcard has it's 40k-samples/second, a good one may have 100k or more ...
==> Some realtime-linux and a c-program might do the trick, evaluating the ingoing data and reacting within 50 microseconds or less ...
==> sending the controlling signals to either soubdcard No. 2 or the same port etc. ...

The outer circuit would have to be some power-parts and some for conversion of the signals frpm/to soundcard-level ...

Anyhow the 50/60 Hz mains-freq. are laughably slow to even an old pentium1/100 MHz, so no expensive things needed at all ...
==> + it would be programmable ... :D

quicksilver - 16-5-2010 at 04:01

-Wish I had 1/2 the time needed to experiment. I just don't (that one of the reasons I bought PSU's instead of working on one. I did try the computer PSU-design & it was great. Had a Fluke meter on it and watched it switch till I ran the battery out. -Was quite impressive.

12AX7 - 16-5-2010 at 07:39

Sound cards are not DC coupled, so that will not work. They also have poor impulse response, being optimized for flat bandwidth rather than flat waveform.

Also, PCs are, in general, not well suited to real time applications (although in this particular case, the PSU section is well enough behaved to be left alone to itself without attention from the computer). A more suitable interface can be provided by a microcontroller, through serial or USB, for data logging, more complex setups, etc. as needed.

Tim

chief - 16-5-2010 at 08:53

What about a real-time linux kernel ? It should straight do busines, within the 50 or 100 microseconds ...
==> Also we deal with changing signals ... : If the voltage drops from 10 to 9.97 V within a millisecond the soundcard will detect it, has 8,16 or more bit of resolution etc. ...
==> The bandwith @ 80 kbit/s is not too small either ...
==> Voltage-levels would have to be transformed into the range of the card, of course, by some simple circuitry, eg. some op-amp ...

Op-amps can be used even to take the logarithm of a voltage, by inserting a diode (backwards) into the line from output to one of the inputs (+ or -, forgot which ...) ... : Thereby even voltages from 0 to 500 V (eg.) could be managed by the soundcard-setup ...

Anyhow the soundcard could have the task of switching the power-supply-circuitry on/off, as well as partially on/off, by the 16bit-resolution ... ... ...


12AX7 - 16-5-2010 at 16:05

If you're going to hack an RTOS, you might as well write your own code. On a microcontroller.

Right now, my code totals 12kB. Beat that with Linux.

Tim

chief - 17-5-2010 at 00:43

Maybe your'e right about that; only I like the universality of the PC:
==> Can be controlled more easily ..., has net for co-functioning with other parts

Also _much_ easier programming ...

A PC ultimately can be blown up to a machine, just by connecting more peripheral things to it ...
==> regulating 5 temperatures, several stirrers as well as some voltages ... and some magnetic valves ... and pumps ...
==> meanwhile logging the data as well ...

Though for the temperatures good PID-units exist for 2-digit €-prices ..., with several I/O-ports ...


densest - 17-5-2010 at 10:28

Elaborating what 12AX7/Tim says from experience & observation:

Using a PC as a controller inside a feedback loop is a bad idea unless your application can tolerate multi-second delays there. Anything but a real RTOS can go deaf, dumb, and blind for several seconds if there's an unusual condition which causes a long loop in the kernel with interrupts disabled.

Even in normal operation Winloss does it too often for comfort. I'd never use Winloss for anything other than a space heater. If you relentlessly strip almost everything in user space and a lot of modules in the kernel out of Linux it can be made usable but they keep using threads which is inherently a disaster. BSD variants like FreeBSD, OpenBSD, and NetBSD have real time hooks which will get you to 20ms or below depending on some details. Old V7 Unix actually could be relied on for < 10ms actions on a 2MIPS (32Mhz = 0.032GHz) machine if you know how to avoid swapping, etc.

A reasonable microcontroller with all sorts of A/D/A and digital I/O mounted on a board can be had for $20 or less. Isolation or controlling power loads can be added for a few $/channel. Careful programming (don't use threads, they don't work, it's been proven, there are papers) avoiding any chance of looping in an interrupt handler will produce something with < 200us response. A fully dedicated one with nothing else to do can go down to 10us or below if the control algorithm is simple. There's at least one paper describing projects using such a micro in the switching feedback loop of a power supply - the result was a bit sloppy but usable.

Using a PC soundcard as a voltmeter/ADC: It can be done but there are a lot of gotchas. They have the following problems:
They don't go down to DC. You would need to chop the input signal into AC, run it into the soundcard, and then postprocess the signal with a digital filter with low enough bandpass to get rid of all the artifacts and noise introduced by chopping. This needs to be done carefully with regard to the card's sampling frequency (see below).
They are Sigma-Delta types which often have a zero point oscillation which produces noise only when there's no input :o so you have to know when and how to filter it out.
They have a high noise floor - maybe -60 to -80 dB (.1% to .01% of full scale). This is random noise as well as RFI/EMI from the computer.
They sample at a relatively low rate. The highest is 192 KHz (rare) 96KHz (not common) 48KHz (universal) and 44.1KHz (common). This means 20KHz to 88KHz upper limit. The impulse response at the high end by definition causes ringing on fast transitions which you have to be aware of.
They are fairly linear but not calibrated. "Full Scale" can be anything from .5V to 5V so you have to have a reference signal to check against. Stereo ones usually are pretty well correlated from side to side.

chief - 17-5-2010 at 11:22

I heare a lot of real-time linuxes ... for industrial applications ...
==> That's what I talked about ; of course no desktop-environment and none of the common packages ...

If the kernel does as much a make possible to run a compiler and read the ports, then a 100 MHz bus will be quite powerful ...

Also: What about using the parallel port ? Eg. connecting some A/D-thing to it for sampling ?
==> The tiny little optimized c-program could wait for each byte from this port, do it's processing at least as good as the microcontroller, and send signals to either the parallel-port again or to another card ... (maybe parallel-port too ...) ...

===================

Also what I thought about a couple of times: Abuse the video-card ... : 3 channels, each in the 100 MHz-range ...
==> could eg. generate some 5-MHz-3-Phases signal for some fun with rotating plasma ...

This wouldn't even be too complicated: Just generating a graphics where some sine-shapes are distributed over the 1024 lines, with 120 deg phase-shifts for RGB ...

[Edited on 17-5-2010 by chief]

12AX7 - 17-5-2010 at 18:05

The video card is capable of extremely complex waveforms (indeed, it's a high resolution, three channel arbitrary-waveform generator with typically 8 bit accuracy), however, your waveforms completely disappear during retrace, both horizontal and vertical. That's not too handy. If you can tolerate that, then it's great for signals that repeat at the sweep rate, but if you want something different, your processing requirement instantly goes up from nil to megabytes per frame.

Now, the old VGA hardware simply has registers, which happen to be given useful values to produce e.g. 640 x 480, and could be assigned arbitrary values to produce oddball scans (most of which aren't supported by monitors), which might be useful for producing different rates. Maybe the same registers still apply today, but if you really want to [ab]use modern hardware, you're SOL as far as what the registers are and how to program them.

In the old days, the parallel port was quite handy. RTOS can run it just fine. Apparently it's possible to use it from Windows as well, but I wouldn't expect that to be very reliable. Synchronous communications (i.e., assign byte, strobe the write pin) are better than more arbitrary bitbanging.

For interfacing microcontrollers, the serial and USB ports are quite sufficient. USB chips are available today to handle the hard stuff, or USB 1.0/1.1 can be bitbanged from a uC as well.

As the number of bitbang routines increases, the demands on any given uC rise substantially. Multiple chips might be used, each one controlling its own system. A more powerful core, like ARM, might also be used. FPGAs also look good, as they provide true parallel processing -- multiple uC cores can be implemented internally.

Tim

quicksilver - 18-5-2010 at 11:12

IN the early 1990's the standard method of using a outboard backup or data transfer was via the parallel port. There were marvelous DOS access times (products written in assembler & were small & sleek). These were written for DAT tape drive backup, forensic analysis, & a great little data transfer program called "Lap Link". It was an all Assembler program that fit on a diskette & your transfer speed basically depended on the speed of the drive. It really flew for that time.
I STILL have all that stuff. I have a 486 DOS computer with all the low-level programming stuff I studied back then. Legacy stuff doesn't have any market today, but I still have my library, my books, & software that makes all the Microsoft Visual Library look very sluggish & bloated. There were 16bit hex editors that would still be valuable today in certain instances (& they were stunningly fast). It was those products that let you really close to the machine.
Microsoft BOUGHT a product called Visual Pascal from Borland (who bought it from the Univ. of San Diego) & buried it. That was a real shame, for at the time, it was a developer's language that produced graphics products under DOS or UNIX w/ out windoze of x-windows

[Edited on 18-5-2010 by quicksilver]

chief - 19-5-2010 at 02:29

There is a program calles "ledblink" for linux, which can control each keyboard led and the parallel-port ...
==> In it's basic configurtion you can switch on/off each of the parallel-port-pins independently ...; I used this eg. for a simple Temp-control, where the temp came in through a voltmeter from the serial port and one of the parallell-pins was connected to a relay, switching on/off the heating: Could regulate the temp of a furnace or even regulate a lightbulb to 100 Cels ... ...

This "ledblink"-program could serve as an example for accessing the port under linux: Link below; only thing you _need_ to do for having it work: Insert into the code the right adress for the parallel-port on your machine ... : I had it run on several different PCs and it worked well ...

================

Besides I remember: Once I compiled a kernel under Debian with 1000 Hz-interrupt-resolution for midi, so it had quick-enough reaction-time ...
==> Those 1 kHz may as well be set to something else, probably ...
==> These days linux is the way to go ... : Well enough documented etc. ...


Now the program:



[Edited on 19-5-2010 by chief]

Attachment: ledblink-aldi.tgz (28kB)
This file has been downloaded 824 times

[Edited on 19-5-2010 by chief]

quicksilver - 19-5-2010 at 06:01

That's my buddy. Have you ever noticed how the good ones are timeless? Norton Commander, Xtree, Lap-link are all "public domain code" (read bought out and undeveloped) and someone gets to port them over to 32 bit or compile them under a certain x-ux?
Since everyone is using wireless it's only a matter of time till we see Novell code being ported to a free Linux package, I'd bet. I can't understand why a serious security conscious company would care SO MUCH about wiring that they'd loose their hard wired networks. But then I'm no millionaire either.

watson.fawkes - 19-5-2010 at 06:03

Quote: Originally posted by 12AX7  
If you're going to hack an RTOS, you might as well write your own code. On a microcontroller.
I concur. If you're learning microcontrollers for the first time, I heartily recommend using Arduino. It's a little board with an Atmel AVR chip and in-circuit programming via USB. The little development environment has a "run" button on it that automatically downloads the program onto the target board and starts execution. Easily the slickest way to program an embedded processor I've ever used. From there, once you've got some experience, you can move onto other platforms or programming methods.

Barring that, if you absolutely insist on using PC hardware, with its huge size and power consumption relative to what's needed, there's always DOS, which has no autonomous processing at all and turns your PC into a bulky microcontroller. These days you can use FreeDOS.

chief - 19-5-2010 at 07:48

Norton commander is already there: "Midnight Commander", "mc" is the command ...

quicksilver - 19-5-2010 at 08:37

Quote: Originally posted by chief  
Norton commander is already there: "Midnight Commander", "mc" is the command ...

There's also "Free Commander" and Ztree or WinTree. The latter are written in languages w/ assembler subroutines as they are text-based and super fast (I mean it). But a lot of the "Commander" clones are written as full windoz programs and are just explorer with two frames: which seems a shame because if the code is there to play with, why compile it in Visual-whatever instead of a text-based 32bit thing like many do with Linux ports....?


Speaking of micro controllers....There is (was?) a learning toy sold at radio shack that taught basic chip programming. It had a little breadboard and you had a 8-pin dip with 2k of space but it also had the setup inside for working with much bigger chips. There's a PC card it comes with that is basically a chip writer. The whole thing sell for less that $80 or so. That's a lot cheaper than a eeprom writer (used) & NO instructions.
I saw the book it comes with and it's a pretty damn good one.
That was what I thought could be a solution, if you knew enough to make a simple eeprom (the kit would show you what to do - what we are talking after anyway). I've never done that stuff before but I still remember the MASM timing analysis (func time, func + child time, hit count funtion, etc). It couldn't be THAT hard to do. They didn't call it a macro assembler for nothing. Writing code isn't needed if you just pluck macros and cut & paste. It's likely the same shit.
I'm not sure how much space is available today but you look at CMOS chips of today's computers and I'd bet there was more than 64k of space to write something. Likely as not; if you could wipe a CMOS chip and use it, you'd get about 8Mb of room. Thats enough to write anything.







[Edited on 19-5-2010 by quicksilver]

chief - 20-5-2010 at 01:00

Just to share one of my ways: Regulating voltage with the parallel port ...

There are those 8 out-pins, switchable with the "ledblink"-program from above ... : Each connected to 1 relay ...
==> Then you have a transformer with 8 separate windings, following voltages: [1,2,4,8,16,32,64,128] Volt
==> ... each of the relays can swith one of these into series with the others, providing any voltage from 0 to 255 Volt ... , 1 Volt resolution ... :D

The actual Voltage can be metered by the serial port, voltmeter, with the linux-program "cdmm" which is part of the package "qtdmm" ... ..., which gives a stream of the measured values and can read many voltmeters ...

Of course the Voltmeter can be set to read amperage, or temperature ...

Also the relays can switch someting else either parallel or in series, eg. capacitors for regulating the Joule-number, or inductivities or resistors ...
With several parallel-port-cards there are several such relay-banks possible ... ; eg. as well there might be switched different
Pt100=Thermoresistors to the voltmeter, for monitoring 8 Temperatures instead of 1 (would use reed-relays for that ...)

Each relay of course to be connected via a simple optocoupler-circuit, 50 ct each chip ...

[Edited on 20-5-2010 by chief]