ATX computer power supply current limit.

(This post is also available in Dutch)

For another project I’m tinkering with an old computer power supply. While I’m at it, why not see if I can build some crude current limiting. It does not need to regulate the current neatly, as long as it is short circuit proof.

A LED on the 12V output of a computer PSU would normally be blown to bits. Such a power supply can furnish ridiculously large amounts of current, while a LED only needs 20mA and as a diode won’t self-limit this. The PSU in the picture is an old one, the 12V line is orange instead of yellow. (The 3V3 is brown.) The 12V can deliver about 7A, 350 times more than the LED needs.


Yet, in this picture, the LED does not break, because I added some current limiting circuit. How does this work?

WARNING: Do not try this at home. Or anywhere else. Or at least don’t blame me if you do anything stupid and/or electrocute yourself. There are dangerous (potentially lethal) voltages inside a computer power supply. I won’t tell you to disconnect it from mains and discharge primary capacitors before you work on it, you should know already or else leave the cover on. Put that screwdriver down!

Voltage regulation in a atx computer PSU is done via optocouplers. The controller IC, UC3842 (or similar) is after all connected to mains power.

On the secondary side of the supply a TL431 is used to send current trough the LED of an optocoupler when the output voltage of the PSU goes too high. The TL431 is used as a comparator (it is a programmable zener / shunt regulator / voltage reference). The other side of the optocoupler is connected to the uc3842 so it lowers its duty cycle and therefore the output voltage.

At schematics of computer power supply’s can be found. Go there to see the voltage regulator circuit (And all the protection circuits I removed from my PSU)

A crude form of current limiting is actually quite easy to make.

By connecting a second optocoupler with its transistor side parallel to the transistor of the first, the output voltage will go down if the led in the second optocoupler gets activated. For the UC3842 this is the same situation as when the output voltage goes to high. So now all I need is a circuit that activates the second optocouplers LED when the output current rises to high, and I have a crude form of current limiting.

This circuit is not that hard. Every resistor has a voltage drop if there is current going trough it. Ohms law. So the output current can easily be measured by putting a resistor in series with it. A sense resistor. Then a transistor that starts conducting when the voltage over the sense resistor surpasses 0,7V. Have the transistor drive the LED from the opto, and that’s the circuit.


For this test the sense resistor is 68Ohms. This would be a current of 0,7/68R=10mA. Because the voltagedrop over the sense resistor can be annoying it’s possible to connect the voltage regulation feedback after the sense resistor so it will compensate. I have not done that for this test.

In practice I won’t limit the current to 10mA, but more likely to 10A, and the sense resistor would be much smaller (0,068R).

But for this test it’s fun to light a LED with a computer power supply.

The current limit oscillates, causing the LED to flash, see video below:

If instead of the LED I connect my ammeter, the value fluctuates between 10 and 20 mA, but probably the peak values are further apart and the meter can’t keep up with the change.

But for short circuit protection this works fine. A big disadvantage however is that the fan in the PSU is on the same 12V line and also gets tuned down / turned off when current limit kicks in.

Because all the “modified computer PSU” project i’ve so far seen on the web only mess with the output voltage and not with the current limit, I decided to post this in both Dutch and English in the hope that it will be useful to anyone, however this idea comes with NO WARRANTIES whatsoever. Please note the rectified line voltage inside those supplies is potentially lethal and capacitors might remain charged to this voltage even when the supply is disconnected from mains. Do not attempt this unless you know how to safely deal with this. If you do attempt this, you do so at your own risk.

Please let me know if you see a similar project somewhere that also deals with current limit on a modified computer powersupply.

ATX voeding stroombegrenzing.

Ik ben voor een ander project wat aan het prutsen met een oude computervoeding. Nu ik toch aan het prutsen ben, eens kijken of er een simpele stroombegrenzing te klussen valt. Het hoeft geen nette stroomregeling te zijn, als het maar kortsluitvast is.

Een LED op een uitgang van een computervoeding zal normaal gesproken onmiddellijk stuk gaan, zo’n voeding kan lomp veel stroom leveren. Het exemplaar op de foto is een oudje, de 12V lijn is oranje ipv geel (Normaal is de 3V3 oranje, maar die is hier bruin), en kan zo’n 7A leveren. De 5V (rood) zelfs 22A. De LED mag maar 20mA krijgen, dus 7/0,02=350 keer minder dan de 12V kan leveren.


Op deze foto gaat de LED niet stuk, want ik heb een stukje stroombegrenzing toegevoegd. Boven de connector is al een stukje van het circuit te zien. Maar hoe werkt het?

Waarschuwing: Niet thuis uitproberen, of waar dan ook elders, als je niet al weet hoe veilig om te gaan met de (potentieel dodelijke) gelijkgerichte netspanning in zo’n computervoeding. Als je het uitprobeert, dan doe je dat op eigen risico. Condensators kunnen nog lading bevatten ook als de voeding niet meer met het lichtnet verbonden is. De Engelse versie van deze blogpost heeft een uitgebreider disclaimer, voor de Nederlanders hoop ik op wat common sense. (Wat Engelstaligen ook moeten hebben gezien het een Engels woord is. Maar ik dwaal af)

De spanningsregulatie van een atx computervoeding gaat via optocouplers. Het regelIC, UC3842 (of variant) is immers vrijwel direct met het lichtnet verbonden.

Aan de secundaire kant van de voeding wordt een TL431 gebruikt om indien een de uitgangsspanning te hoog wordt, de LED van een opto te laten oplichten. De andere kant van de opto zit aan de uc3842, zodanig dat deze de pulsbreedte naar beneden regelt en de uitgangsspanning dus weer lager wordt.  De TL431 wordt eigenlijk als een soort comparator gebruikt, al is het een instelbare zener / voltage reference / shunt regulator.

Op zijn wat schema’s van voedingen te vinden, zie aldaar voor het spanningsregelcircuit. (En alle overvoltage/overcurrent beveiligingen die ik er bij mijn voeding uitgesloopt heb)

Een lompe vorm van stroombegrenzing blijkt veel simpeler te maken dan gedacht.

Door een 2e optocoupler met z’n transistorkant parallel te zetten aan de eerste, valt de uitgangsspanning naar beneden te regelen als er stroom door de LED van de 2e opto loopt. Vanuit de UC3842 gezien gebeurt er namelijk precies hetzelfde als wanneer de eerste opto gaan geleiden in geval van een te hoge uitgangsspanning. Nu nog een circuitje dat stroom door die optocoupler LED stuurt bij teveel uitgangsstroom, en ik heb een lompe vorm van stroombegrenzing.

Dat circuitje is niet zo moeilijk. Over elke weerstand valt spanning als er stroom door loopt, dus de uitgangsstroom laat zich makkelijk meten door een weerstand in serie te zetten. Een senseweerstand. Verder een transistor die als de spanning over de senseweerstand boven de 0,7V komt gaat geleiden. En vervolgens die transistor de LED van de 2e opto aan laten sturen.


Voor deze test is de senseweerstand 68R. Dit zou een stroombegrenzing opleveren op 0,7V/68R= ongeveer 10mA. Om de spanningsval over de senseweerstand vervelend kan zien, is het leuk de feedback van de spanningsregeling ná de senseweerstand af te tappen. Dat heb ik voor deze test niet gedaan.

In de praktijk ga ik de stroom van een voeding die zo veel stroom zou kunnen leveren als deze natuurlijk niet op 10mA begrenzen, maar eerder op rond de 10A, en de senseweerstand zou dan 0,068R worden. Maar als test is het leuk eens te proberen een LED te laten branden op een ATX voeding.

De stroombegrenzing gaat oscilleren, wat leid tot een knipperende LED. Zie het volgende filmpje.

Als ik in plaats van een LED mijn stroommeter aansluit, schommelt de waarde tussen de 10 en de 20mA, maar waarschijnlijk zijn de pieken groter en kan de multimeter het allemaal niet bijhouden.

Maar als kortsluitbeveiliging werkt dit prima. Nadeel is wel dat de ventilator van de voeding op dezelfde 12V rail zit, en dus ook naar beneden wordt geregeld/uit gaat als de stroom begrensd wordt.

Laat het me weten als je een soortgelijk project ergens tegenkomt, wat ik tot nog toe tegenkwam was alleen spanningsregeling, daarom post ik dit.

Some short notes on the Lecroy9450 repair project

Because there is no big news yet, some short updates.

– Claude Schwarz pointed me to the Yahoo user group “Lecroy Owners group”, they have design files for a HHZ406 replacement. (Made by Dieter Frieauff). So maybe the ext. trigger input can be repaired as well.

– A service manual for this ‘scope (And others) can be found there as well, or alternatively here: (Or on – but that site is full of ads)

– NoTMS was caused by a missing “Vct”, I accidentally scratched trough this trace while placing the bottom cover. Took quite some time to find, then just a little wire to fix.

9450_scratchedVCT 9450_scratchedVCTFixed

– Thanks to Claude Schwarz (Again), I now have a third ADC card. So I now have spareparts, and if I get one of the 2 broken cards working again, a working 2ch 350Mhz / 400Ms/s (10Gs/s)  DSO. (Or rather: the Leidse Makerspace then has a 2ch 350Mhz DSO). The 3 ADC cards will hereafter be named “9450_3A Claude”, “9450_3A LMS-Broken” and “9450_3A LMS-Working”. (order shown in the picture, ltr: broken, Claude, working )

9450_3A ADCs

– I measured the power supplies on “9450_3A LMS-broken”. All are present. (-5V, -12V, 5V and +12V). Next up: reference voltages and tracing the signal path.

– Some more pictures:

lecroy_patchedOn some of the ADC boards, a 5V regulator is placed where others have just a cap.


This is another original patch (-5V regulator), both on “9450_3A LMS broken”. This board has no LeCroy repair stickers (shown below), but those patches were there when I got the ‘scope so I assume they are original.

Bot these 2 regulators and the -12V and 12V ones have the correct output voltages.


Lecroy Repair stickers on the timebase board. (This board is working fine) There are more of those stickers in the scope on other boards.


And the last one for today: The calibration error log. Chan2 has “9450_3A Claude” in this picture, but “9450_3A LMS broken” gives similar results. If I exchange the cards between the channels, ch1 gets the errors and ch2 is error-free. (The error-free channel has “9450_3A LMS working” in both cases).

‘ll keep you posted!

EDIT 2-7-2014:
“Next up: reference voltages and tracing the signal path.”

Measured on HMS403, seems to be OK. Also none of the ADC’s have stuck bits (did not log what bit connected to what line of the LA, but with no input all are 0, as long as there is no selftest / calibration running.)

Please note if you connect a logic analyser to these circuits they are negative logic (“1” is – 5V, “0” = 0V). As the 0V is connected to chassis ground, and your LA’s ground might also be (through the powersuply’s both connected to earth ground), use caution!

The scope does not do a memory test on boot up. I carefully removed one of the RAM IC’s to test this, and the scope does still show “ADC/TMS state working”.

So there might be something wrong with the memory. Fortunately this is normal TTL logic again.

EDIT 8-Aug-2014:
On slower sample rates this scope only uses 1 of its 4 ADC’s (per channel). On slower sample rates, the problem stays, 1 out of 4 points on the display (Maybe 1 out of 4 samples?) is out of line. So it’s not 1 of the 4 adc’s that’s broken (because it only uses one at that sample rate), but something in the memory or further in the data pad. The memory is also divided in 4 parts/banks, so it could just be… But for now I’m going to work on other projects for a while.

Please comment if you have any questions or suggestions!

LeCroy 9450 oscilloscope repair

This was supposed to be an easy repair, and therefore not worth blogging about. But as it turns out, it might get interesting after all. (The ‘scope is not repaired yet)

The “Leidse Makerspace” owns a LeCroy 9450 350Mhz DSO. When they moved to their new location I temporarily got this oscilloscope. Not just for use or storage, but also to attempt to repair it. One of its channels was not working, sometimes it even wouldn’t display anything.

The display problem quickly turned out to be a loose connector. With this connector loose it would display nothing it al, or if it did work, it would sometimes glitch out like this:


While at other times it would display normally:


Probably just some transport damage, as after refitting this connector the problem has not been back. Now, on to the more interesting problem: channel 1 did not work: it did not respond to an input signal and it had a huge offset. After using the vertical position adjustment knob to bring it into view it would sometimes even oscillate on it’s own, showing needle-like pulses. The ‘scope also wouldn’t trigger on channel 1. Channel 2 functions fine, so it is still a usable 350Mhz DSO. However, 2 channels would be a lot nicer, and fault-finding is one of my hobbies. So… Time to remove the covers.

The easy-est way to measure in the analogue front-end of this oscilloscope is to turn it upside down, remove the bottom cover, remove the 12 screws holding the shielding, and remove the shielding.


After this, an input signal can be followed, measuring before and after each subcircuit.
(I don’t have a picture of this, but I do have a picture of the 9450_7 front end, removed from the ‘scope, and from my annotated copy of the schematic)



Close- up of the area of the board I’m looking at:


Somewhere here, the signal got lost. As you can see there is another module inserted through the pcb, this is the HHZ406. It turned out the signal entered this module (an amplifier), but nothing sensible got out.  IMG_6076_lecroy9450_HHZ406view from the other side of the board, also showing the relays. (Those metal cans)


This module does not look like it can be repaired, nothing is obviously visibly broken, and those “black blobs” don’t look promising either, because these usually cover (custom) semiconductors directly bonded to the PCB.

It also looks like it cannot be bought anywhere. Too specific, too custom… (If you know where to get these, or work for LeCroy and have spares, or if you would like to reverse-engineer them, let me know.)

But this story does not end here. This scope has 3 HHZ406 modules. One for each channel, and one for external trigger.

So I swapped the modules for external trigger and channel 1. After this, the signal got to the output of the 9450_7 board. When using the same V/Div settings on ch1 and 2, and feeding them the same input signal, the signals here would be identical.

The story does not end here either, however. Channel 1 still does not work. It does respond to an input signal and the ‘scope does trigger on this channel now, but the signal is not displayed properly. It has needle-like pulses on it. These pulses move when changing V/Div settings on the ‘scope or input signal amplitude from the signal generator. (Video:

There is another defect lurking somewhere in the 9450_3a ADC boards, because when I swap them, the problem moves to the other channel (Ch2). Measuring on these boards is harder because they are not easy to get to while the ‘scope is operating, unlike the analogue front-end (9450_7).

IMG_6036_lecroy9450_3a_adccardsTo be continued (?).

Quick and dirty Arduino optical mouse sensor experiment (a2620 chip)

I wanted to experiment with a optical mouse sensor, did a websearch, found this blogpost, and adapted the code for my A2620 mouse sensor.  As it might be useful to others,  below is my Arduino sketch and the processing sketch.

Use the processing sketch to view the image from the sensor, or use a terminal program to ask it for X / Y movement.


(Yes, that thing to the left used to be a mouse… The thing to the right is an avrdb-m328 board used as an Arduino)

[ Arduino ]
#define FRAMELENGTH 324
#define SCLK 6 // portd.6
#define SDIO 7 // portd.7

byte frame[FRAMELENGTH];
byte flop;

Serial driver for ADNS2010, by Conor Peterson (
Serial I/O routines adapted from Martjin The and Beno?t Rosseau’s work.
Delay timings verified against ADNS2061 datasheet.

The serial I/O routines are apparently the same across several Avago chips.
It would be a good idea to reimplement this code in C++. The primary difference
between, say, the ADNS2610 and the ADNS2051 are the schemes they use to dump the data
(the ADNS2610 has an 18×18 framebuffer which can’t be directly addressed).

This code assumes SCLK is defined elsewhere to point to the ADNS’s serial clock,
with SDIO pointing to the data pin.

Adapted for A2620 on AVRDBM328 by Luke.

const byte regConfig    = 0x40; //a2620 . A2610 =0x00
const byte regStatus    = 0x41; //a2620 . A2610 =0x01
const byte regPixelData = 0x48; //a2620 . A2610 =0x08
const byte maskNoSleep  = 0x01; // unchanged for a2620
const byte maskPID      = 0xE0; // idem

const byte regYmov = 0x42; // a2620
const byte regXmov = 0x43;  //a2620

void mouseInit(void)
digitalWrite(SCLK, HIGH);
digitalWrite(SCLK, LOW);
digitalWrite(SCLK, HIGH);
writeRegister(regConfig, maskNoSleep); //Force the mouse to be always on.

void dumpDiag(void)
unsigned int val;

val = readRegister(regStatus);

Serial.print(“Product ID: “);
Serial.println( (unsigned int)((val & maskPID) >> 5));

void writeRegister(byte addr, byte data)
byte i;

addr |= 0x80; //Setting MSB high indicates a write operation.

//Write the address
pinMode (SDIO, OUTPUT);
for (i = 8; i != 0; i–)
digitalWrite (SCLK, LOW);
digitalWrite (SDIO, addr & (1 << (i-1) ));
digitalWrite (SCLK, HIGH);

//Write the data
for (i = 8; i != 0; i–)
digitalWrite (SCLK, LOW);
digitalWrite (SDIO, data & (1 << (i-1) ));
digitalWrite (SCLK, HIGH);

byte readRegister(byte addr)
byte i;
byte r = 0;

//Write the address
pinMode (SDIO, OUTPUT);
for (i = 8; i != 0; i–)
digitalWrite (SCLK, LOW);
digitalWrite (SDIO, addr & (1 << (i-1) ));
digitalWrite (SCLK, HIGH);

pinMode (SDIO, INPUT);  //Switch the dataline from output to input
delayMicroseconds(110);  //Wait (per the datasheet, the chip needs a minimum of 100 µsec to prepare the data)

//Clock the data back in
for (i = 8; i != 0; i–)
digitalWrite (SCLK, LOW);
digitalWrite (SCLK, HIGH);
r |= (digitalRead (SDIO) << (i-1) );

delayMicroseconds(110);  //Tailing delay guarantees >100 µsec before next transaction

return r;

//ADNS2610 dumps a 324-byte array, so this function assumes arr points to a buffer of at least 324 bytes. (A2620: unchanged)
void readFrame(byte *arr)
byte *pos;
byte *uBound;
unsigned long timeout;
byte val;

//Ask for a frame dump
writeRegister(regPixelData, 0x2A); // wite anything to pixeldatareg to start at first pixel (A2620)

val = 0;
pos = arr;
uBound = arr + 325;

timeout = millis() + 1000;

//There are three terminating conditions from the following loop:
//1. Receive the start-of-field indicator after reading in some data (Success!)
//2. Pos overflows the upper bound of the array (Bad! Might happen if we miss the start-of-field marker for some reason.)
//3. The loop runs for more than one second (Really bad! We’re not talking to the chip properly.)
while( millis() < timeout && pos < uBound)
val = readRegister(regPixelData);

//Only bother with the next bit if the pixel data is valid.
if( !(val & 64) ) {
//Serial.println(“Invalid data.”);

//If we encounter a start-of-field indicator, and the cursor isn’t at the first pixel,
//then stop. (‘Cause the last pixel was the end of the frame.)
if( ( val & 128 ) &&  ( pos != arr) ) {
//      Serial.println(“last pixel read.”);

*pos = val & 63;


void setup()
pinMode(SCLK, OUTPUT);
pinMode(SDIO, OUTPUT);

Serial.println(“Serial established.”);



void loop()
int input;
byte buff;


if( Serial.available() )
input =;
switch( input )
case ‘f’:      // capture frame
Serial.println(“Frame capture.”);
case ‘d’: // dump frame, raw data
for( input = 0; input < FRAMELENGTH; input++ )  //Reusing ‘input’ here
Serial.write( (byte) frame[input] ); // use serial.write so it does not convert to ascii, –Luke
Serial.write( (byte) 127 );
case ‘p’: // Powerup sequence
case ‘x’:  // read X movement register
buff = readRegister(regXmov);
Serial.print((byte) buff);
Serial.print(” “);
case ‘y’:  // read Y movement register
buff = readRegister(regYmov);
Serial.print((byte) buff);
Serial.print(” “);
case ‘s’:  // Shutdown
case ‘i’: // Dump frame values seperated and human readable

for( input = 0; input < FRAMELENGTH; input++ ){  //Reusing ‘input’ here
Serial.print( (byte) frame[input]);
Serial.print( ” “);
// maybe find something to print LF each 18th datapoint?
Serial.print( (byte)127 );
case ‘t’: // test image

for( input = 0; input < FRAMELENGTH; input++ ){  //Reusing ‘input’ here
Serial.write( (byte) input%64);
Serial.write( (byte) 127 );

[ / arduino]


import processing.serial.*;

final int rate = 38400;
final int off_x = 75;
final int off_y = 70;
final int sz = 22;
final int frameX = 18;
final int frameY = 18;
final int frameLen = frameX * frameY;

Serial port;
int[] frame;
int serialCounter;

int nextFrameTime;
int framePeriod = 1000;

void setup()
size( 550, 550 );


frame = new int[frameLen];


nextFrameTime = millis();


void draw()

if( millis() >= nextFrameTime )


for( int i = 0; i < frameLen; i++ )
fill( map(frame[i], 0, 63, 0, 255) );
rect(off_x + (i % frameX * sz),
off_y  + (i / frameY * sz),
sz, sz);

nextFrameTime = millis() + framePeriod;

void keyPressed()
if( key == ‘f’ )

if( key  == ‘ ‘ )

if( key  == ‘t’ )
port.write(‘t’); // test frame
serialCounter = frameLen;


void initSerial()
String portName = “/dev/ttyUSB0”;
port = new Serial(this, portName, rate);
println(“Using ” + portName + ” as serial device.”);

void requestFrame()

port.write(‘d’); // dump normal frame
serialCounter = frameLen;
port.write(‘f’); // request new frame

void serialHandler()
int incoming;
while( port.available() != 0 )
incoming =;
print(incoming + ” “);
if( serialCounter > 0 )
if( incoming == 127 )
serialCounter = 0;
frame[serialCounter – 1] = incoming;


ESR LC meter behuizing

Ik ben momenteel bezig aan een ESR / L / C meter. In “Boem een blog” was al een foto te zien van het VFD, en een kort verhaaltje over hoe ik dat aanstuur.

Hierbij wat foto’s van de bouw van de behuizing. (Het oorspronkelijke plan was om gedurende de bouw te posten wat de voortgang was, maar de bouw heeft het posten ingehaald, de ESR/L/C meter is bijna af. Nu is “bijna af” wel het langste stadium van een project…)

Ik heb de behuizing gemaakt door vuren latjes aan elkaar te lijmen. Dat levert verrassend stevige kastjes op, en het is een makkelijker manier van bouwen.

Als je vragen hebt, over de esr-LC-meter: Laat het weten! Om een reactie op dit blog te geven hoef je geen account te maken en zelfs geen mailadres op te geven! (dat is, totdat ik teveel spam krijg).

De elektronica is natuurlijk een stuk interessanter dan gelijmd hout, dus vragen daarover zijn ook zeer welkom.

Haaks uitlijnen onder/bovenkant
Lijmen van de zijkanten
Behuizing in “houtskeletbouw”

Daarna moeten er nog plankjes op de zijkant gelijmd of geschroefd worden om er een dichte behuizing van de maken, en daarna kan de elektronica worden ingebouwd

Ingebouwde elektronica

Vervolgens komt er nog een stuk plexiglas op de bovenkant van de behuizing, waardoor de VFD afleesbaar blijft. Hierop worden dan ook de schakelaars voor de bediening gemonteerd. (Hier heb ik nog geen foto’s van)

VFD in het donker

In het echt is de VFD gelukkig een stuk beter afleesbaar dan op de foto’s. M’n camera lijkt een hekel te hebben aan de specifieke kleur blauw/groen van de VFD. Wat wel goed te zien is op de foto is ghosting… Gelukkig valt ook dat in het echt mee, maar wellicht valt het nog wat terug te dringen door trager te multiplexen.