In this Instructable, I will share my experiments in making a set of PCB electromagnets for motion control.
For about a year, I have been experimenting with dual-axis pointing mirrors for lasers. Initially, I build a laser steering module out of solenoids. Then, I acquired some Texas Instruments TALP1000B modules from a scientific surplus outlet and experimented with those.
The Texas Instruments module had the advantage of being fantastically small, but it was very fragile and is no longer available for purchase. My DIY module had the advantage that had a clear (rather than gold) mirror, allowing it to work with violet lasers and phosphorescent screens. The DIY module was also robust and could be made from easily sourced parts. The downside was the solenoids made the module large and heavy and they could only provide a pulling force, complicating the driver circuit and limiting control.
At some point, I came across Carl Bugeja's very interesting experiments with PCB motors and I began to wonder whether I could use PCBs to make a DIY device that combined the advantages of my larger module and the smaller TALP1000B.
The mirror assembly would be 3D printed, as in my original, but I hoped that flat PCB electromagnets and neodymium magnets in the place of solenoids would make it smaller, lighter and more responsive.
Step 1: What I Set Off to Make...
Conceptually, the idea was simple.
Like in my earlier design, a mirror would be mounted on a 3D printed platform with integrated hinges. I knew from my earlier project that this was well within the realm of what a consumer 3D printer could make.
The PCB would be a short distance below the platform and would provide four electromagnetic coils. The two diagonally opposite coils would be wired in series, so that when current flowed through them, one would provide a pulling force while the other would provide a pushing force on 2mm diameter neodymium magnets positioned right above. The two opposing coils, working together, would rock the hinged platforms back and forth across that diagonal.
Two sets of opposing coils, each acting at 90 degrees from the other, provides dual-axis control, just like in the commercial TALP1000B module.
Step 2: Planning for the PCB
For this project, I knew I would need four coils with as many turns as possible. I wanted to get the boards made in the U.S.A. at OSH Park, so this meant I had to limit myself to four copper layers and a trace width of 5 mils. I aimed to keep the size of the board at 1 square inch, so that 3 boards would cost around $10. Later I had to increase to board a bit to accommodate a header, bringing the total cost to $13.80 for 3 boards.
Initially I wanted to design the whole thing in Inkscape. It was a tool I was familiar with and I knew it could draw some great looking curves with it. However, after some research, I found out going from Inkscape layers to a manufactured PCB wasn't particularly easy. Since this was my first board, I did not want to screw it up!
At that point, I had to learn a real PCB layout program! I considered Eagle, but the free version was limited to two layers, which was not enough for my project!
While browsing hackaday, I read about Contextual Electronic's Getting to Blinky tutorial for KiCAD and realized it would be perfect. I completed all the lessons, except for sending in the blinky board for manufacturing, as I had plans for an entirely different sort of board!
Step 3: Designing the 4 Layer PCB in Kicad
The blinky tutorial gave me a great start in designing my own board. My board only needed one component, a four pin header, which made drawing a schematic easy!
The hardest thing about designing the board was to figure out how to lay down the spiral traces correctly so that all the PCB layers contributed to the magnetic field. I also had to find a way to connect the two diagonally opposed coils and header pads in series without crossing traces.
I used Ampère's right hand rule quite a bit. All of my spiral traces turn counter-clockwise, but they alternate from going outside-in to inside-out on each layer. It was challenging to place the vias so that they would not short out any of the layers. Since a via runs down through all four layers, they must be carefully offset from each other and made to connect only two layers at once. Fortunately, once I had drawn one coil, I could duplicate it and rotate it to make the other three.
It would have been most natural to have the first two pins drive the first coil and the second two pins drive the second coil, but the only way to interconnect everything was to interleave the pins, such that pins 1 and 3 connect to one pair of coils, while 2 and 4 connect to the other pair. This is why the schematic has crossed wires.
Once my design was complete, I was able to visualize it in 3D using KiCAD's visualization function. How cool is that?
Step 4: Submitting for Manufacture
As a last step, I validated my design using the design rules for OSH Park. The Getting to Blinky tutorial walked me through the entire process, including the necessary design rule changes in KiCAD.
Once I was satisfied with my design, I created an account on OSH Park and uploaded my KiCAD PCB file, the one with the ".kicad_pcb" extension.
The ordering page gave me a nice rendering of all the layers, giving me one last time to verify my design one last time. Once I submitted the order, OSH Park did a great job of keeping me informed of the status of my order, letting me know when the panel (which contained my board and others) went to fab and when they were ready to be separated and mailed.
Step 5: Designing the 3D Printed Parts
While I waited for the boards to be manufactured, I set out to design the 3D printed parts. I began my design in FreeCAD but found the design exceeded my FreeCAD skills. So I moved to OpenSCAD, a tool I have a lot more experience with.
I designed a part that used concentric ovals to make the various parts of the movable gimbal. I made a small bridge as a hinge and hoped enough plastic would be deposited across that bridge to make a flexible hinge.
Getting a good print was difficult, but eventually I had a part that worked as expected... at least in theory!
Step 6: Unboxing the Boards From Osh PARK
A few weeks later I received the manufactured boards! Here is a video of me unboxing my first custom manufactured PCB!
I then soldered a 4-pin header on one of the boards and measured the resistance of across each pair of coils. It came out to be 31.7 ohms, which was half as much as the 64 ohms I measured across the terminals of the TALP1000B. This resistance meant that the each axis would draw 157 mA when connected to 5V, for a total of 314 mA when both axis were powered on.
Step 7: Initial Testing of the Boards
I wasn't sure how high I much current the PCB board could actually handle, so I first hooked it up to a variable bench top power supply and gingerly turned up the voltage while observing a small 2 mm neodymium magnet on the PCB. Since I intended to power the board with 5V, this is as far as I turned up the current. I did not want to destroy the board, so I did not try to find out the maximum current it could withstand.
Step 8: Making the Driver Circuit
The resistance of the PCB coils turned out to be a fortunate accident, as it meant that I could reuse the driver circuit I used in my experiments with the TALP1000B.
The circuit consists of an Arduino Nano and a SparkFun Motor Driver - Dual TB6612FNG as the motor driver. The current for the motor driver is drawn from the Arduino Nano's 5V pin, which can provide 500mA when powered by a USB connector. So this is enough to power the PCB coils without any modifications at all!
Step 9: Can It Steer?
Unfortunately, my first attempt at making a laser steering module led to disappointment. The attraction and repulsion forces are quite weak, far too weak for my original flexible hinge design. After a few variants, I settled on using spiral hinges instead, which were flexible enough to allow some movement.
This still wasn't enough for acceptable performance. The trick turned out to be to stack the PCBs to increase the magnetic force!
Step 10: Stacking PCBs for More Power!
A single PCB was not sufficient for driving the laser. But when you order from OSH Park, you get three identical PCBs. It turns out, it is possible to stack these PCBs for increased number of turns per coil and more magnetic power!
By using extra long headers, you can solder through two or three PCBs at once. This puts the coils in parallel, so that you can still drive it using 5V, but the current per pair of coils will increase from 150 mA to 450mA. You can no longer drive the circuit from a computer USB port, but a cell phone charger rated at at least 1A will do the trick.
To stack the PCBs, you will need:
- An USB charger that can put out 1A at 5V.
- Extra long 3/4 inch headers
- A soldering iron
- A desoldering iron
- Perforated protoboard
- A hard surface, such as the side of some pliers
First, make a stack of the three PCBs, with the proto-board on the bottom. Insert the long side of the headers through all four boards, so that the tines emerge through the protoboard on the bottom. The protoboard will act as a spacer, allowing us to push the plastic bridge down to the correct height. Place the tines against the hard surface and from the top, push the plastic bridge down so it lies flush against the topmost PCB board. Now, when you remove the protoboard from the other side, the tines will protrude just the right amount for soldering.
Since the PCB stack is several millimeters thick, it is unlikely solder would wick properly all the way through. To ensure good contact, I soldered one board at a time, but I had to use a desoldering iron during the process.
I started with the first PCB. The solder climbed the header pins so that it was impossible to make the second board flush to the first. I found that by using my desoldering iron I was able to suck up excess solder, leaving just enough so to make contact and so the second board could lie flat on the first. I repeated then soldered on the second PCB and once again used the desoldering iron to suck out the excess. On the final board, I used extra solder to allow it to wick all the way through the stack.
Once I was done, I bend the pins with pliers to make them stick off to the side!
Step 11: How Well Does It Work for Steering Lasers?
With the three layer PCB, the module was powerful enough to steer a laser surprisingly well. It was a huge improvement over my original solenoid-based DIY Laser Steering module — It is smaller, lighter and has much less distortion!
I would go as far as to say it has the same performance as the commercial TALP1000B, but with the added benefit of being more robust, easy to make, and that it works with a violet laser, which allows a glow-in-the-dark screen to be used for projecting!
The SimpleDriver Arduino sketch can draw a Circle, Heart or a Lorenz Attractor using floating point math (to change the shape, edit line 563. For the Lorenz Attractor, also uncomment line 581 to enable auto-scaling).
The LineDrawing sketch is an experiment using Bresenham's line algorithm for line drawing. In principle, it should allow line drawing with less vibration, but I think I need a microprocessor with higher resolution PWM for this to be truly effective (I am currently awaiting a blue pill STM32duino for further experiments!).
Step 12: Conclusion and Future Work
Although with a single PCB, the performance is inadequate, stacking all three PCBs gave me a 5V laser steering module that is comparable to the TALP1000B, cheap and easy to build, and far better than my original solenoid based version!
It is a slimmer, lighter and far more capable version than my original solenoid based DIY Laser Steering Module. While it's been over a year's worth of tinkering to get here, it has been a great learning experience and I am pleased with the outcome!
In future versions, I would consider improving upon this design with the following enhancements:
- Adding holes to the middle of each of the coils, so the magnets can move in and out of the board, where the field would be stronger.
- Add castellated edges to the board, as this would make it far easier to solder them together in a stack.
- Experiment with microcontrollers that are able to generate higher resolution PWM signals.
- Integrate the motor driver into the PCB so that it would be a standalone Arduino module.
- Add the ability to PWM the laser for brightness control.
- Replace the hobby store mirror with a first surface mirror for better reflection.
Runner Up in the