|
KiCADKicad
|
|
|
arduino IDEArduino
|
Stepper motor developing platform
Introduction
In this project, I show you my newest device which is a stepper motor developing platform. I often work with stepper motors, either because I develop a new project, or because I have a customer that needs a stepper motor-based solution. Usually, I assemble the circuit with all the components on a breadboard. This is sometimes cumbersome, especially if a lot of parts are involved. Too many cables and connections, sometimes different drivers or different components…etc.
So, to solve the headache, I decided to create a PCB where all these components can be embedded and I can develop code for stepper motor projects with great ease.
The board is a “hybrid” PCB with some SMD components (AS5600 circuitry and the DC-DC converter) and some off-the-shelf parts and modules. I tried to make the board as compact as possible while still providing enough space to comfortably access the controls (buttons and rotary encoder) and the connectors. The SMD parts are 0603 (1608 metric), so with a little skill and patience, one can solder all the components without a stencil. A good way to solder the SMD components manually is to first leave a little solder blob on one of the solder tabs for the component. Then, the component should be placed over its place, on the recently left solder blob. Then, while holding the component in place, the solder blob can be remelted with a soldering iron. This will fix the component in place and then we can proceed with the rest of the legs. If it is a 2-pin component (passive), we can simply heat up the other (unsoldered) pin and then add a tiny bit of solder, to make the connection. If it is an integrated circuit (IC), we can apply a little flux over the pins and then spread a small amount of solder around the IC. The flux will help to make the solder stick to the pins of the component and it will also help to avoid bridging. Alternatively, we can apply a small amount of solder paste around the components or at their solder tabs, and use a heating tool to blow hot air on the area to melt the solder.
Microcontroller
The core of the board is an STM32F401CCU6 microcontroller board. This module is a very cheap (about $3-$4), but extremely powerful microcontroller board. It has many GPIO pins and plenty of peripherals that allow a huge degree of freedom when developing circuits with it. For example, the AS5600 encoder uses one of its i2c interfaces, the TMC2209 uses one of its UART interfaces, and the display will use one of its SPI interfaces. Also, thanks to the fact that most of the GPIO pins can be configured as interrupt pins, the buttons, the rotary encoder and the limit switches (LS1, LS2) can all be set up using an interrupt instead of polling. Most importantly, thanks to the STM32Duino framework, we can develop code for the microcontroller using the Arduino IDE. More adventurous people are encouraged to use the STM32CubeIDE platform and learn the HAL (Hardware Abstraction Layer) framework. It gives much more powerful access to the microcontroller and allows us to program it to utilize its full potential.
TMC2209
Another key component of this circuit is the TMC2209 board. This is a novel stepper motor driver board with many great features. It can be controlled with the traditional STEP and DIR pin pair, but it can also be controlled via the UART connection. My example Arduino code demonstrates both options. While the STEP-DIR pins can be controlled using the AccelStepper library, the UART control requires the TMCStepper library.
One of the main specialities of this driver is that it can drive the stepper motor silently (StealthChop feature). This is beneficial, for example, in 3d printers where several stepper motors work simultaneously which can be quite noisy. But in general, it is nice to have silent motors. It also can detect stalling (StallGuard feature) which can be used for homing without limit switches.
Please notice, that there are several driver boards that use the TMC2209 chip. If you are going to replicate my project, it is very important to have the exact same driver. Some drivers have slightly different pin layouts and using a different TMC2209 board could render the developing platform inoperable.
AS5600
Another important feature of the platform is the AS5600 magnetic absolute encoder. I have a relatively popular video and Arduino code for this device. This little device works together with a magnet mounted on the shaft of the stepper motor. When the magnet is rotated, the change in the magnetic field is detected by the AS5600 chip and this change is then converted into a digital value that represents the position of the magnet within the chip’s coordinate system. The chip has a 12-bit resolution which means that the angular resolution is about 0.088° (360/4096). Just as a reminder, a full microstepping produces a 1.8° rotation on the shaft of the stepper motor. The chip can resolve about 20 times smaller steps.
The PCB is designed in such a way that it can accommodate a NEMA17 stepper motor (31 mm x 31 mm hole-to-hole distance with M3 bolts). When the motor is properly mounted and there’s a sufficient gap between the chip and the magnet, the chip will provide precise feedback on the position of the shaft. The purpose of this feature is to be able to practice and study closed-loop control. I know that when a system is set up properly, stepper motors do not need a closed-loop control and the best example of this is the 3d printers that we can buy for peanuts and can maintain submillimeter precision. However, they are still good systems to practice the principles of such systems. So, I still feel the relevance of it.
Other than a closed-loop control we can also simply just use the sensor for feedback. For example, we can check if the stepper motor arrives at the desired position or if it maintains the speed…etc. We can also send it to a target position by relying on the shaft position instead of the number of steps…etc. The possibilities are endless and it is really just up to the imagination of the user.
Power regulator
The power supply is solved in a (I think) neat way. Since the STM32F401CCU6 is mainly 3.3 V-compatible, I designed the rest of the circuit to be 3.3 V-compatible, too. The pull-up resistors for the buttons and the i2C pins and the components are all selected to be able to work with 3.3 V.
First of all, I had to think about the maximum voltage that the TMC2209 driver board can take. This is 28 V in the case of the driver I picked. In fact, some datasheets on AliExpress state 38 V, but I think it is a typo as all the official Trinamic documents (chip, eval. board) state 28 or 29 V. So I feel better to say 28 V as the maximum voltage. So, this 28 V directly goes to the driver. Since 28 V is not a typical “commercial” voltage value, I recommend using a 2 A, 24 V power supply, a wall-wart. This input voltage is also directed towards the input of the buck converter that converts it down to 3.3 V. The circuit of the converter is inspired by the SparkFun BabyBuck regulator’s schematics. It is a very simple circuit and it provides up to 2 A current which is more than enough for the circuit.
Then the output of the regulator is connected to the rest of the circuit, to the whole 3.3 V network. This part is designed with a simple but (hopefully) smart feature. So, the thing is that we may want to use the board while programming the microcontroller when it is sitting on the platform. This means that the microcontroller and the rest of the circuit are powered by the USB port. If the circuit were powered by both the USB connection and the onboard regulator, something would be fried sooner or later. Therefore I came up with a simple solution. When the board is supposed to be used in a “standalone mode”, then a jumper must be put on the enable position. This connects the output of the regulator to the rest of the 3.3 V network. Otherwise, if the jumper is removed, the 3.3 V network is not connected to the regulator. In this case, the microcontroller board is supposed to supply the whole 3.3 V network.
Controls and display
I should also talk about the “inputs and outputs” of the board. The board is equipped with a cheap but good 128x64 pixels graphical LCD. The display has good contrast, it is easy to read and its driver chip (ST7565R) is compatible with the u8g2 library which allows us to create a nice GUI. The display uses the SPI interface for communication.
I also added two 12x12 mm push buttons to the circuit. I’ve been using this kind of arrangement in my stepper motor-related circuits for a while and I think it works fine, so I decided to implement it in this circuit as well. The buttons don’t have any specific purpose, it is entirely up to the user how they are used. They can be used as up/down buttons for navigation or changing a value, or they can be used as start/stop buttons…etc. It is really up to the user’s imagination.
Then, a more important component is maybe the rotary encoder module. The module I used in this platform is my own design. It is a debounced rotary encoder module. Its advantage is that it uses RC filters and Schmitt trigger circuits to create perfect square wave outputs whenever the encoder shaft is rotated. It may be an overkill, but it is a fun little project. The purpose of the encoder can be also different, depending on the user. I typically use it for navigating in the menu. The rotation can be used to go up/down in the menu, and the switch can be used to enter/exit a menu item. The rotation can also be used to increase/decrease a value (e.g. target distance or speed) or directly rotate the motor. I developed a stepper motor control panel in the past where you can see how a rotary encoder can be used in such an application.
Finally, let’s mention another feature. I equipped the board with two limit switch connectors. Sometimes when I develop code for customers, they require limit switches in their system. Therefore I found it useful to add two limit switch connectors to the board.
One can set up for example a linear rail where there is a limit switch at each end of the rail. They can be used to practice and study homing, or shutting down the motor as a safety feature and so on. Again, the options are endless.
Originally, I had a certain module in mind when I added the connectors. They are simple mechanical switches on a red PCB with 3 cables coming out from the PCB. They are typically equipped with a cable that ends with 3-pin 2.54 mm female socket. I added this specific product to the link collection below.
But actually, as long as you respect the polarity and the pin layout, you can use any switch as a limit switch. You can use an optical gate, a push button, or even some capacitive or inductive proximity switch as long as they can operate at 3.3 V.
If you managed to reach this part of the article by actually reading it, thank you for your attention! Please don't forget to visit my website and check all the links and files attached to the project. I provided schematics, a bill of materials, a minimal working example Arduino source code and some other goodies that you can use to kickstart your journey with stepper motors.
Have fun and enjoy the learning process!
Update 2024-01-23:
I made a new video using this platform where I explained how a stepper motor can be driven using PID control.
Stepper motor developing platform
*PCBWay community is a sharing platform. We are not responsible for any design issues and parameter issues (board thickness, surface finish, etc.) you choose.
- Comments(7)
- Likes(7)
- Engineer Aug 09,2024
- Engineer Aug 02,2024
- Taiecosell Jun 22,2024
- Engineer May 07,2024
- PatHightree Feb 15,2024
- Orwa Diraneyya Jan 03,2024
- Mahatma_Coat Nov 29,2023
- 2 USER VOTES
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
-
8design
-
7usability
-
8creativity
-
5content
-
8design
-
8usability
-
7creativity
-
6content
More by Curious Scientist
- USB PD Breadboard Power Supply In this article, I show you my new creation. It is a USB PD decoy-based breadboard power supply. All...
- ADS1256 - RP2040 Custom DAQ Front Panel with GPIO This is just a simple PCB panel that belongs to my other project which is a high-performance DAQ.A r...
- ADS1256 - RP2040 Custom DAQ Front Panel without GPIO This is just a simple PCB panel that belongs to my other project which is a high-performance DAQ.A r...
- 10th Anniversary Badge I designed this small badge for PCBWay's 10th anniversary.I tried to make a deeper meaning to the bo...
- ADS1256 - Atmega32u4 Custom DAQ board IntroductionIn this project, I show you two things. One is a new version (v1.2) of my custom DAQ bas...
- Debounced rotary encoder module In this project, I show you my approach to making a rotary encoder module.One can buy different rota...
- Custom ADS1256 board with ATmega32U4 I created my own ADS1256 PCB after working with this AD converter for several years. I wanted to bui...
- 2-channel breadboard voltmeter The project originally stems from my CH32 tutorial series. I started working with this chip not so l...
- ADS1256 - RP2040 Custom DAQ Rear Panel This is just a simple PCB panel that belongs to my other project which is a high-performance DAQ.A r...
- ADS1256 - RP2040 Custom DAQ with GPIOs This is my (hopefully) last iteration of the ADS1256-based DAQ board. I replaced the ATmega32U4 micr...
- High-performance 3-axis stepper motor control panel In this project, I show you my new development which is a high-performance 3-axis stepper motor cont...
- STM32F070F6P6 miniature USB microcontroller board A small but powerful Arduino-compatible STM32 board.I designed this board because I was curious if i...
- Stepper motor developing platform IntroductionIn this project, I show you my newest device which is a stepper motor developing platfor...
- Custom-made self-contained DC power meter This project realizes a tiny "self-sufficient" power meter that can be inserted into any DC power li...
- 10-channel NTC thermistor-based temperature logger This project is designed to be a 10-channel temperature logger based on 10k NTC thermistors.I design...
- Educational board for strain gauges, Wheatstone bridges and op-amps I show you a little device that I built so I can explain more things related to strain gauges, Wheat...
- Focus Stacking Mechanism In my previous project, I shared the PCB for this mechanism. In this project, I share the parts of t...
- Focus Stacking Circuit For Macro Photography This circuit is mainly designed to serve as a tool for shooting pictures for focus stacking macro ph...
-
-
kmMiniSchield MIDI I/O - IN/OUT/THROUGH MIDI extension for kmMidiMini
74 0 0 -
DIY Laser Power Meter with Arduino
87 0 2 -
-
-
Box & Bolt, 3D Printed Cardboard Crafting Tools
121 0 2 -
-
A DIY Soldering Station Perfect for Learning (Floppy Soldering Station 3.0)
418 0 1 -
Custom Mechanic Keyboard - STM32
244 0 3