October 13, 2024

An illuminator for my microscope - electronics

The first quick and dirty version was simply a 5 volt supply along with a 56 ohm series resistor. This gives about 50 mA of current and yields a very nice brightness.

Note that this LED can be driven with up to 3100 mA (3 amps!) This would be outrageously bright and entirely useless on the microscope.

I would like to be able to vary the brightness, probably driving the LED with from 0 to 200 mA. In general 50mA is fine, but sometimes at higher power more light is an advantege.

A circuit

The idea is a current sink using an op-amp and a mosfet. A sense resistor (2 ohms in the following drawing) generates a voltage proportional to the current. An op amp compares this to a command voltage and controls current via the gate of the mosfet. The command comes from a potentiometer that divides a 2.5 volt reference voltage. The reference voltage comes from a TL431 reference, which is buffered by an op-amp follower. The follower is probably not needed, but I had a dual op-amp and wanted to do something with the extra amplifier. The sense and control is all done on a scale of 0-2.5 volts. Maximum current is set by the value of the sense resistor and what current will produce 2.5 volts. With a 2 ohm sense resistor this is 1.25 amps. I now use a 15 ohm sense resistor, which gives 167 mA.

My first mistake

I misread the green-blue-black color code on my resistor as 5.6 ohms rather than 56 ohms. So I had thought that 500 mA was giving me the brightness that I liked. This is my own mental issue about resistor color codes and isn't the first time I have made this mistake. This led to more confusion later before I got this straightened out.

This also led me to a more complex design that perhaps I need. I expected to be needing to control from 0 to 1000 mA, wheras I only need to control 0-200, and perhaps 0-100 would do fine. For that low current I might be able to just use a series potentiometer, especially with a 5 volt supply voltage. The LED drops about 2.4 volts, so only 2.6 volts would get dropped across the pot.

But I worked up a design using an LM358 op amp and a IRF644 power MOSFET in a voltage controlled current sink circuit. My first design used a 2 ohm sense resistor, expecting a max current of 1000 mA. Then I discovered my error with the 56 ohm preliminary resistor and changed to a 15 ohm sense resistor. Now I am having trouble getting the simple current sink circuit to work.

I replicated the circuit I soldered up on my breadboard and see the same trouble there. Interestingly when I replace the IRF644 with a bipolar transistor (I use a TIP41 in the same TO220 package) the circuit works! The only problem I see is that when I set my knob to 0, I still get some current (about 47 mA), which would make my lowest brightness the same as the mid-level I am now getting with the 56 ohm resistor. I would really like to turn the knob to 0 and see the LED go out entirely. And I would like to know why the MOSFET doesn't work.

Break out the scope

There is an old saying:

"If you build an amplifier it will oscillate and if you build an oscillator it will amplify."
I power up my Rigol DS1054 and take a look at the circuit on the breadboard. I have a 4.87 volt command and I see 1.5 volts on the sense resistor. I measure 5.2 volts on the gate of the MOSFET. These are all DC measurements taken with my Fluke DVM.

I look at the gate signal with the scope and I see oscillation! We swing from 3 volts to 10 volts at 595 kHz. Looking at the sense resistor, we swing from 0 to 6 volts -- at the same frequency of course. So my multimeter is just sort of measuring average values.

It is all about gate capacitance in the power mosfet and an unstable op-amp.

Adding a 1K resistor between the op-amp output and the gate on the MOSFET tames the oscillation. I get nice control, but only for command voltages of 2 volts or greater. With a command voltage of 1 volt, I get 1.9 volts on the sense resistor and 5.8 volts on the gate. I am working on my breadboard, so it is easy to swap parts. I try a different LM358 and now everything works right down to 0.01 volts. With 0.04 volts, we would get 3 mA, so this seems good.

Curiously, now when I remove the 1K resistor (with the new LM358) on the breadboard, I don't get oscillation. Well, it turns out the 1458 is not a LM358 equivalent, it is a dual 741 and is not happy with the gate capacitance hanging on its output -- the LM358 does not mind.

As a note, I can get DIP package LM358 from Digikey for 30 cents each.

So it is all working now on the breadboard. The thing now is to solder a 1K resistor into the gate path on my circuit board and test it. First I put the scope on my circuit board, and see it oscillating at 1.09 Mhz, with swings (on the gate) from 3 to 8 volts. Once I install the 1K resistor, the oscillations go away. But ...

I see the same problem with the op-amp refusing to drive its output to zero. This part is marked UA1458TC. The other one that refused to work properly on the breadboard was a MC1458CP. The one that works is a National Semi LM358N.

The bottom line is that the 1458 is not the same as the LM358. It is not a single supply op-amp. It is a dual 741. So my mistake and wrong assumption. The LM358 is rail to rail, the 1458 is not.

I chop the 1458 off the board, cutting the legs as close as possible to the body of the chip. This leaves all the legs sticking up. Then I fit the LM358 in between those two rows of 4 legs and solder it into place. This is quick and easy and does not disrupt all the point to point wiring under the board.

Best of all, it works now. The 1K resistor may not be needed with the LM358, but it doesn't hurt anything and I don't intend to remove it.

Lessons learned

Sockets can cause as many problems as they solve unless top quality machine tooled sockets are used.

Not testing on a breadboard may boil down to hubris. In the software world, I have learned many times that thinking, "this is so simple, it is just a small change, nothing can go wrong, there is no need to test this" never turns out well.


Feedback? Questions? Drop me a line!

Tom's Mineralogy Info / [email protected]