Category Archives: Hacks

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…

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

I’ve had a magnifying desk lamp for years, of which starter plug, and donut fluorescent lamp had died last year. I wanted to replace the lamp with a LED block made for this purpose, but I could not find one anywhere here. So, I decided to make my own. I had a 3m 12V white LED strip (50 x 3 LED strips, merged together) in stock from another project, which I could use for this hack. The lamp had an ID of 150 mm and an OD of 207 mm. All I needed was a circular cardboard piece of the same size, so I could stick the LEDs on it.

Then I had an idea! Why not wrap the LED strip around the old fluorescent lamp? I made some calculations, and realized the LED strip was the perfect size. The diameter of the fluorescent lamp was about 180 mm at the center of the cylinder (28.5 mm thick) forming the donut. So the circumference was about 565 mm. Each 3 LED section of the strip (10 mm wide) perfectly covered one turn around the cylinder. So I needed roughly 565 / 10 = 56 of these 3 LED sections. I had 50 all together, which  was enough 🙂

I started with disassembling the desk lamp, removing the fluorescent lamp and the ballast transformer at the base. I decided to keep the already mounted cables and the switch.


After unscrewing a couple of screws, the bare-bones of the lamp was ready for the hack.

The plastic part of the fluorescent lamp and the piece holding the starter were crumbling to pieces, probably due to heavy UV exposure from the lamp over time. I replaced the plastic part of the fluorescent lamp with duct tape, and started winding the LED strip around the donut.


It took me a while to nicely wrap the adhesive backed LED strip around the donut lamp.


Quarter way through.


And here’s a nice donut LED lamp with spiraling LEDs all over.

I stabilized the final winding with duct tape as well 🙂 Next, I inserted the leads of the LED strip to the terminal block in the lamp’s head, and and placed the lamp in its grove. Finally I placed the huge magnifier in its place, and screwed the transparent lid back in its place.


Looking good 🙂


Here’s the final assembly. Still needs a LED driver, and a part to stabilize the PSU.

I used a 12V 5A switching power supply for this lamp. I still don’t know the current draw (should be about 1500 mA), and I’ll measure it tonight. Eventually, I may get a smaller PSU, so I can fit it better where the ballast transformer was. I also made a simple PWM driver with an N-MOSFET, for driving high powere LEDs. I’ll also use it with this lamp for adjustable lighting. All will be explained in the next part.

Here are some shots of the lamp while it’s on. Although it’s hard to tell from the pictures, I’m rather pleased with the amount of light the LED strip puts out.


See you in the next part 🙂

New Optimum S 122 G Bandsaw and a Hack

I recently got a bandsaw, to be able to cut stock for general use and big steel square tubings for the future DIY lathe stand quickly. So, I got an Optimum S 122 G (which was within my price / performance range). I’m not even going to start about the problems I had while buying it (welcome to Turkey, where no one gives a shit about customers post-sale).

Optimum S 122 G

This one looked suitable for my needs.

This video had all the help I needed to be able to align the saw blade. Ghostses even kindly responded my question in detail. Yet, something was wrong, and I couldn’t get decent cuts for the life of me.

At the end of each cut, I kept finding the one side of the blade making an angle from the stock, while the other side was square (and when on rest, the blade was dead square to the vise, I used parallel bars and an angle ruler). I kept getting cuts with a vertical angle, with more material at the bottom.

Crooked Blade

This was always what I had. One side of the blade at angle.

10mm Silver Steel

10mm silver steel after a bad cut.

I soon realized that, when I pushed the main saw part when it was all the way down, the hinge shaft was actually moving about 1mm up and right in one of its holes (also moving the blade away from stock). All was good when it was all the way up, due to weight on that part pushing the shaft down. Right after that, I still wanted to try and cut some 60 mm x 60 mm box tubing with 3mm wall thickness for the lathe stand, and I broke the blade, probably due to excess speed. I left the shop for a while not to stress anymore over it.

So, I came back after an hour or so and disassembled the saw to be able to reach the angle plate on the saw stand with no fear, since dealing with machines is easier than dealing with shifty sellers here.

Saw Hung

I hung up the main body where my punching bag used to be, since my back (thanks to lumbar disc herniation) can no longer handle such weights. Gone are the days when I could lift 50kg boxes.

Saw Wheels

A closer look at the main wheel assembly.

I drilled and tapped M6 screw holes in both base plates of the hinge right above the gap (piece of cake on this cheap cast iron), screwed in cone point setscrews (better angular pressure for what I needed) and stabilized them with non-permanent Loctite clone. The resulting motion was very smooth.

5mm Drill Hole

Drilling this porous cast iron was very easy with the good quality bits I recently got.

Tapping Second Hole

Using the milling machine as a guide for the tap wrench. The angle looks wrong, but it’s due to lens curve.

Tapping End Close

The cast iron was so soft, it was a piece of cake to tap it with this HSS tap. Looks crooked again. See how the hole looks warped? Also see how they failed to center the drill at first attempt…

Tap SS Hole

The resulting hole was rather nice and functional.

SS Clean Stick

I first cleaned the holes from grease with brake pad cleaner, then applied Loctite clone to stabilize the setscrews.

Setscrew In

Testing the first hole with a longer cone point setscrew.

Setscrews Shaft

I left it to cure overnight, after wiping off the excess.

Eventually, I ordered two 14 TPI blades and one 24 TPI blade yesterday. The saw will be sitting in the shop until I receive them. Projects on pause as well. I also removed, cleaned,  and re-mounted the lathe chuck. The runout is now down to 0.01 mm.

Hacking a 2D 1002 EEPROM

Last week, a friend of mine came to me with a problem that his dentist friend was having. This dentist friend uses a teeth whitening machine, which  allows for 4 x 15 minute sessions when you insert a small PCB, with a small IC on it, in the machine. After these 4 sessions, he needs to purchase a new card, which costs a lot (at least in this country).

2D 1002

2D 1002 my ass…

The IC on the little PCB is labeled 2D 1002 013B1, whose datasheet is nonexistent on the Net. After hours of Google’ing, and Google Translating Russian, Slovenian, German, Polish, and Czech sites for information, I realized that no one had a solution. One Russian site stated that it was a DS2430, which was wrong (DS2430 has one 256 bit memory page, and DS2431 has 4 x 256 bit memory pages – different addressing modes helped me see the difference), but it got me started. With only two active pins connected to the IC, 1-wire communication was obvious.

My Bus Pirate was on my desk for the rescue, and this Hackaday post also provided great help. I used a 1K resistor to pull up the MOSI line, since BP Wiki recommends a value below 2K for parasitic power devices. I got the 5V power from my Bus Pirate by entering W at the prompt, after entering m and 2 to enter 1-wire mode. I use screen /dev/ttyUSB0 115200 for accessing the Bus Pirate console. By the way, the 1-wire family code you get when you read the ROM with a Bus Pirate 1-wire macro (you can list them with (0)) is 0xAD, which is also nowhere to be found on the Net. You can refer to the OWFS web site for future uses.

DS1002 BP

So glad to have a Bus Pirate v3.b. That red croc clip is there to hold the resistor in place.

My first writing attempts failed miserably. Later on, when I finally dumped the whole EEPROM array with (85)(1) 0xf0 0x00 0x00 r:144 (thanks to the DS2431 datasheet), and observed the contents, I realized that the memory pages were all set to EPROM mode, which ANDs the incoming data with its contents (and they were all 0x00, except for a few).

The first two bytes of the last memory page was filled with some values, also the last 8 bytes here contained other information, such as a copy of the protect control bytes, manufacturer ID, etc. which actually reside in the last 2 bytes of the EEPROM (total EEPROM array is 18 x 8 = 144 bytes, 128 is reserved for user data). And I managed to overwrite them all with zeros.

BP Console

Here’s the BP console with the necessary steps to read the 1-wire EEPROM.

Here‘s a text file containing the EEPROM data, before I altered it. The output is from the Bus Pirate console, with my comments and extra information added.

So, the next step is to get an unused card and observe the data in it, then get a fresh DS2431 and write it the same way, and give it a try on the machine. We’ll see how it turns out this week.

Update: After seeing a couple hacks for sale on ebay and such, I realized this was not a matter of just rewriting the EEPROM. People used MCU’s, probably to emulate the EEPROM anyway they liked. So, I would need an actual working machine to tap the com and see what’s really going on. Naaah, screw it…

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

BF20L motor brushes, Links, and Purchases

Yes, it’s been a lazy week at the shop (not at work). I got my motor brushes yesterday, though. And the mill now runs better than ever. The first time I ran the motor (at the lowest speed), there was a periodic ringing sound, and I could tell it was some sheet metal hitting some other metal (cooling fan?). We (Pamir and I) opened the motor only, and this time I removed the can (naively, I had thought it was somehow mounted to the bottom, but it was the magnets), and I was right, the cooling fan was warped. I fixed the blades with my hands and a flat head screwdriver, and closed back the motor. I, of course, had to reinstall the motor brushes.

Continue reading

Optimum BF20L Motor Brush Problems

As I wrote in my previous posts, the brushes of the motor are gone, and I need to get a pair or more soon. So, I decided to remove the motor in the mean time. Here are some pictures of the motor and the mill during the disassembling process.

Motor Off Top

Top of the mill after I removed the motor and cleaned the grease with break pad cleaner.

Continue reading