Introduction: DC and Stepper Motor Tester
Few months ago, a friend of mine gave me a couple of discarded inkjet printers and copy machines. I was interested in harvesting their power source units, cables, sensors and especially motors. I salvaged what I could and I wanted to test all the parts to make sure they were functional. Some motors were rated at 12V, some at 5V, some were stepper and others were DC motors. If only I had a device, where I could simply connect the motor, set the frequency, duty cycle and select a stepping method to test it.
I decided to build it without using digital signal processor, or microcontroller. The humble 555 or tl741 as oscillator, 4017 counter and many logic gates for stepper motor modes. At first I had lot of fun designing the circuit, as well as designing the front panel for the device. I have found a decent wooden tea box to put everything inside. I have divided the circuitry into four parts and started testing it on a breadboard. Soon, the first signs of frustration appeared. It was a mess. Lot of gates, lot of ICs, wires. It didn't work properly and I was thinking between two options: To make it very simple - just for DC motors, or put it aside and finish it sometimes later ... I choosed the second option.
Step 1: DC and Stepper Controlling Theory
The most common way to control a DC motor is through the so-called pulse-width modulation (PWM). PWM is applied to a specific switch and turns the motor on and off. In the picture you can see the indicated switching period and its relation to the frequency, the switching time is also indicated. Duty cycle is defined as the switching time divided by the total period. If we keep the frequency constant, the only way to change the duty cycle is to change the on time. By increasing the duty cycle, the mean value of the voltage that is applied to the motor also increases. Due to the higher voltage, a higher current flows through the DC motor and rotor rotates faster.
But what frequency to choose? To answer this question, let's take a closer look at what a dc motor is actually. Equivalently, it can be described as an RL filter (neglecting back EMF just for a moment). If a voltage is applied to the motor (RL filter), the current increases with a time constant tau that is equal to L / R. In the case of PWM control, when the switch is closed, the current flowing through the motor increases and decreases during the time the switch is off. At this point, the current has the same direction as before and flows through the flyback diode. Motors with higher power have a higher inductance and thus a higher time constant than smaller motors. If the frequency is low when the small motor is powered, there is a rapid decrease in current during the switch-off time, followed by a large increase during the switch-on time. This current ripple also causes the motor torque to ripple. We don't want that. Therefore, when powering smaller motors, the PWM frequency should be higher. We will use this knowledge in the design in later steps.
If we want to control a unipolar stepper motor, used in hobby electronics, we have a choice of 3 basic control options (modes) - Wave drive (WD), Half Step (HS) and Full Step (FS). The sequence of individual modes and the position of the rotor is indicated in the figure (for simplicity, I have indicated a motor with two pairs of poles). In this case, Wave Drive and Full Step cause the rotor to rotate 90 degrees and can be achieved by repeating 4 states. In Half Step mode, we need a sequence of 8 states.
The choice of mode depends on the requirements of the system - if we need a large torque, the best choice is Full Step, if a lower torque is enough and maybe we power our circuit from the battery, wave drive mode is preffered. In applications where we want to achieve the highest angular resolution and smoothest motion, Half Drive mode is an ideal choice. The torque in this mode is about 30% lower than in Full Drive mode.
Step 2: Circuit Diagram
This simple meme aptly describes my thinking process during the design.
Upper part of the diagram describes the power supply - a 12 volt adapter, which is reduced to 5 volts by a linear regulator. I wanted to be able to choose the maximum test voltage of the motor (MMTV) - either 12 or 5 volts. The built-in ammeter will bypass the control circuits and measure only the motor current. It would also be convenient to be able to switch between internal and external current measurement using a multimeter.
The oscillator will operate in two modes: the first is a constant frequency and a variable duty cycle, and the second is a variable frequency. Both of these parameters will be able to be set using potentiometers, and one rotary switch will be switching modes and ranges. The system will also include a switch between the internal and external clock via a 3.5 mm jack connector. The internal clock will also be connected to the panel via a 3.5 mm jack. One switch and a button to enable/disable the clock. DC motor driver will be a single quadrant N-channel mosfet driver. The direction will be changed using the mechanical dpdt switch. Motor leads will be connected via banana jacks.
The stepper motor sequence will be controlled by an arduino, which will also recognize 3 control modes specified by the dip switch. The driver of the stepper motor will be uln2003. The Arduino will also control 4 LEDs that will represent the animation of the powered motor windings in these modes. The stepper motor will be connected to the tester via a ZIF socket.
Step 3: Schematics
The schematics are divided into five parts. The circuits framed in blue boxes represent the components that will be on the panel.
- Power Supply
- DC Driver
- Arduino Stepper Driver
- Logic Gates Stepper Driver
Sheet nr. 5 is the reason why I left this project lying. These circuits form sequences for the previously mentioned control modes - WD, HS and FS. This part is replaced by arduino completly in sheet nr. 4. Complete Eagle schematics is also attached.
Step 4: Necessary Components and Tools
Necessary components and tools:
- Cardboard cutter
- Fine pliers
- Cutting Pliers
- Wire stripping pliers
- Soldering iron
- Wires (24 awg)
- 4x spdt switch
- 2x dpdt switch
- 4x banana jack
- Push button
- ZIF socket
- 2x 3.5 mm jack
- DC connector
- Arduino nano
- 3-pole DIP switch
- 2x 3 mm LED
- 5x 5 mm LED
- Bicolor LED
- Potentiometer knobs
- DIP sockets
- Universal PCB
- Dupont connectors
- Plastic cable ties
with your chosen values, corresponding to the frequency ranges and brightness of the LEDs.
Step 5: Front Panel Design
The tester was placed in an old wooden tea box. First I measured the internal dimensions and then I cut a rectangle out of hard cardboard, which served as a template for the placement of components. When I was happy with the placement of the parts, I measured each position again and created a panel design in Fusion360. I divided the panel into 3 smaller parts, for simplicity in 3D printing. I also designed an L-shaped holder for fixing the panels to the inner sides of the box.
Step 6: 3D Printing and Spray-painting
The panels were printed using an Ender-3 printer, from the residual material I had at home. It was a transparent pink petg. After printing, I sprayed the panels and holders with matt black acrylic paint. For complete coverage, I applied 3 coats, laid them outside for a few hours to dry and ventilate for about half a day. Be careful, paint fumes can be harmful. Always use them only in a ventilated room.
Step 7: Panel Wiring
Personally, my favorite, but the most time-consuming part (I apologize in advance for not using the shrink tubes, I was in a time crunch - otherwise I would definitely use them).
Adjustable brackets help a lot when mounting and handling panels. It is also possible to use the so-called third hand, but I prefer the holder. I covered its handles with a textile cloth so that the panel would not be scratched during work.
I inserted and screwed all the switches and potentiometers, LEDs and other connectors into the panel. Subsequently, I estimated the length of the wires that will connect the components on the panel and also those that will be used to connect to the pcb. These tend to be a bit longer and it is good to extend them a little bit.
I almost always use liquid solder flux when soldering connectors. I apply a small amount to the pin and then tin and connect it to the wire. Flux removes any oxidized metal from the surfaces, making it much easier to solder the joint.
Step 8: Panel-Board Connectors
To connect the panel to the pcb, I used dupont type connectors. They are widely available, cheap and, most importantly, small enough to fit comfortably in the chosen box. The cables are arranged according to the scheme, in pairs, triplets or quadruplets. They are color-coded to be easily identified and easy to connect. At the same time, it is practical for the future not to get lost in a uniform tangle of wires. Finally, they are mechanically secured with plastic cable ties.
Step 9: PCB
Since the part of the diagram that is outside the panel is not extensive, I decided to make a circuit on a universal pcb. I used a regular 9x15 cm pcb. I placed the input capacitors together with the linear regulator and heatsink on the left side. Subsequently, I installed sockets for IC 555, 4017 counter and ULN2003 driver. Socket for 4017 counter will remain empty as its function is taken over by arduino. In the lower part there is a driver for the N-channel mosfet F630.
Step 10: Arduino
The connection of the system with arduino is documented in schematics sheet nr. 4. the following arrangement of pins was used:
- 3 digital inputs for DIP switch - D2, D3, D12
- 4 digital outputs for LED indicators - D4, D5, D6, D7
- 4 digital outputs for stepper driver - D8, D9, D10, D11
- One analog input for potentiometer - A0
LED indicators that represent the individual motor windings, light up slowly than the windings are actually powered. If the flashing speed of the LEDs corresponded to the motor windings, we would see it as a continuous illumination of all of them. I wanted to achieve a clear simple representation and differences between the individual modes. Therefore, the LED indicators are controlled independently at 400 ms intervals.
The functions for controlling the stepper motor were created by the author Cornelius on his blog.
Step 11: Assembly and Testing
Finally, I connected all the panels to the pcb and started testing the tester. I measured the oscillator and its ranges with an oscilloscope, as well as frequency and duty cycle control. I didn't have any big problems, the only change I made was to add ceramic capacitors in parallel to the input electrolytic capacitors. The added capacitor provides attenuation of high-frequency interference introduced into the system by parasitic elements of the DC adapter cable. All tester functions work as required.
Step 12: Outro
Now I can finally simply test all the motors that I have managed to salvage over the years.
If you are interested in the theory, scheme, or anything about the tester, do not hesitate to contact me.
Thanks for reading and your time. Stay healthy and safe.
Participated in the
Finish It Already Speed Challenge
7 months ago
Wow, comprehensive good tester. Very impressive. Nice that you used an Arduino Nano too. Software makes everything more versatile.
2 years ago
I rarely vote for anything involving 3D printing but seeing your sketches for circuits was kinda nice. Over-reliance on computers takes something away in my opinion. 'Old school' method with sheets of paper and no 'library' of parts suits my Luddite style. ;o)
Reply 2 years ago
Thanks, I'm happy you enjoyed it :)