Tag Archives: PIC

Converting a Magnifying Desk Lamp’s Donut Fluorescent to LED Strip – Part II

Well, I completed the project last night. Here is what I did…

First, I measured the current draw of the LED strip from the PSU. It was 1.45A max. I found a 12V 2A wall wart laying around (trusting it would actually provide 2A), and it fit perfectly in the space at the bottom of the lamp (where the ballast transformer was). I removed the plastic case of the adapter, soldered the power input and output cables (also stabilized them with black hot glue), and used the bottom half of its case for insulation.


The surgery on the 12V 2A wall wart adapter went well.


I used the bottom half of the wall wart adapter for insulation.

After screwing the cover plate of the bottom part back into its place, it was time to make another LED driver card. I had made one of these for a sculptor friend, who is going to use it for one of his lamps. So the firmware and the PCB was ready, all I needed to do was to print the PCB on a piece of PNP paper, laminate it on a 50 mm x 100 mm copper clad, etch it, and solder the components on. The whole process of making this card took me about an hour and a half.


As I stated on a previous post, the laminator does a great job with these PNPs.


2 nice PCBs at once. 50 mm x 50 mm each.


Program the PIC 16F88, and all is set.

My friend, who wanted this LED driver built for him, needed to control the brightness of the LEDs with an optical quadrature encoder in his project (well, he actually said: “no turn limits, very little friction, high resolution”). So the PIC counts the pulses, checks the direction, and feeds it to the PWM DC registers. No look-up tables, no gray code, simple and functional. Works with both mechanical and optical encoders. The only difference is, the mechanical encoders’ A and B pins can’t be reversed, optical ones don’t care. They only need the extra power pin on the board. The mechanical encoder I use in this project is 24 P/R, the optical one I used for his project is 400 P/R. Here’s the schematic, and the PCB shot. Schematic and PCB files are in Proteus Isis & Ares format, but there’s also a PCB print in PSD format. The PIC was programmed in Hitech PIC C. The code is rather simple and efficient. All can be downloaded from here.


The circuit is simple. 12V DC is fed to the LEDs through an N-MOSFET, which is PWM driven by the PIC. The plastic box is an efficient, 5V, switching DC/DC converter, which requires no external components. You could use a 7805 with the necessary capacitors if you chose. The N-MOSFET IRF530 can drive 100V at 14A, continuously. A bit of an overkill, but good for future uses. The firmware limits the DC (duty cycle) of the PWM to 98%, since the N-MOSFET heats up badly (there is a technical explanation for this, but I don’t know what it is) at 100%. The LED on the card is on whenever the min (0%) or the max (98%) value is reached. The PWM frequency is 980Hz, and the DC is adjusted by loading the number of encoder pulses from 0 to 250 (250 is 98% and 255 is 100%) to CCPR1L. Since it would take the mechanical encoder 250 / 24 = 10.42 turns to sweep the whole range, I multiplied the counter with 10, to be able to cover the whole range with 25 pulses (one pulse more than a whole turn). This was no problem with the 400 P/R optical encoder, since 62.5% of a turn (250 / 400) was covering the whole range. It took me a while to be able to fit the card in the space at the head of the lamp. I had to remove a terminal block which was actually unnecessary. I also added two 100 nF capacitors from the A and B pins, which are on the side of the mechanical encoder, to the center GND pin of the encoder for debouncing.


I had to push the card under the lamp to open up room for the rotary encoder.


The two 100 nF capacitors for debouncing.

As I was thinking about drilling a hole in the head of the lamp for the quadrature encoder, I realized could actually use the hole for the starter of the old fluorescent lamp. But there was a problem. The hole was too deep for the length of the knob on the encoder. So I turned a  25 mm long aluminum cylinder with 20 mm diameter (good for the 22 mm hole), and drilled a 6 mm hole 12 mm deep (encoder shaft length) at its center. I also cut a grove around the end, and sanded the edges for a better finish. Later on I drilled and tapped a hole on the side for a M4 setscrew. I was actually proud of this last part. It looks really good IMO.


Mechanical encoder with the new knob on. The smaller original knob is on the right.


The encoder was stabilized using black hot glue (gunk).


More detail on the knob.


Click click!

After stabilizing the card in its place, and making the necessary connections with the cables, I screwed the plastic cover back in its place, and finished this project / hack. Here are some extra shots of the lamp and other details.


The blue LED is on when min and max DC values are reached.


From another angle.


All covers closed, ready to go 🙂

I also made a rather affordable MIDI Thru box for my music setup in the meantime. I will be writing about it in my next post.


I decided to put the status LED outside for better visibility. Since I didn’t turn off the lamp (what a noob!) as I was unscrewing the cables, I shorted the PSU, and fried it. I mounted the LED in a hole by the knob anyway. The fuse was blown, so I went and got another 0.5A glass fuse. But when I came back, I realized I had fried the IC as well. So I went and got another PSU, 12V 5A (3A was the same size) this time. The case looked bigger than what the space at the bottom of the lamp could handle. Yet, when I opened it, I realized I could saw off an ample part of the PCB, since the traces were straight, thick, and long towards the right. And I didn’t need the 220V socket. So I did that, soldered and gunked the cables back in their places and closed case cover.


The PSU, after about 20mm from the right part of the PCB was cut off.


A perfect fit 🙂 I put a piece of cardboard at the bottom for insulation.


Status LED on when DC = 0%


Status LED on when DC = 98%

Ok, now I can use my lamp…

Rotary Table and Electronic Controller

Ok, it’s been a while. We are in a new year, (sarcastic) yaaaay. But at least we have a 4 (minus 2 already) day break ’til Monday, yet I don’t feel very productive. I still did a couple of things in the shop, in the past week.

I worked on the aforementioned rotary table controller, played with the rotary table and the 125 mm manufacturing chuck I got for it, and I still need to finish the boat! It snowed a bit lately, and we’re expecting more. I want more…

Rotary Table Lay

Rotary table without the chuck on it.

Continue reading

8 x 8 Laser Matrix for Fun – Part I

As I decided to replace the metal brackets for the motor mount, and didn’t have the proper parts, I worked on another project last week. I got some 1.5 mm stainless steel sheet today, though. I also got a new dial indicator, since Pamir knocked over and broke the one I got last night (It’s ok, it wasn’t no Mitutoyo anyway. I could have also turned the base magnet on to avoid it).

Stainless Steel

1.5 mm thick stainless steel sheet with 50 mm x 1000 mm size.

Continue reading

Commodore 64 MOS6581 SID Based Synth / Sequencer

Here’s another Instructable from a long time ago. It was also featured there and brought me some months of free pro membership. I’m just putting a copy here again. Another lazy day, all pictures in one gallery. Right click and view image on FF, for real size.

Continue reading

PC Interfacing a GameBoy Camera

This is an Instructable I wrote a while ago. It was featured there and brought me some months of free pro membership. I’m just putting a copy here, since I got my own blog now. Some schematics here  (the PIC Mother Card) are very old and crappy. I didn’t know much about PCB design then. I’m a lazy ass when it comes to web stuff, so I put all the pictures in one gallery. Right click and view image on FF, for real size.

Continue reading