I am an undergraduate student. I am trying to make a project that does the following:
Achieve microstepping of the level of 1/128 or 1/256 of a typical step (1.8 degrees).
Implement a closed loop system with encoder feedback.
So far, we have been trying to figure out the hardware required for the project. Looking at other projects online we decided on the NEMA 17 stepper motor and TMC5160 stepper motor driver. However, we were unable to simulate the working of the motor and driver together on wokwi or Tinkercad as those components were not available. We don't know what model to select and the compatible driver or encoder that can together achieve such high mocrostepping.
This is my first time working with such a project. Hence, I have very little idea of what is supposed to be done.
Can someone please help in figuring out what hardware we can choose?
Thanks
You will surely need to lower the ambitions. If such an encoder would exist it would cost a fortune.
Start searching for encoders and see what's within ecenomical range.
What is the purpose of microstepping? Have you considered that your stepper will always power on at a full step position and you will need to program your project to move to a known beginning position so you can count the steps as they are taken.
Do you know that microstepping is not the exact movement every time? The 1/128 for one step will not be 1/128 for the next step, but 128 of those steps will sum to 1 full step. Is that why you need the encoder?
Remember that a NEMA 17 stepping motor just defines the mounting diameter of the motor. It tells us nothing else about the motor, like the current it takes or the voltage it needs.
This link tells you about what stepping motor driver options you have. Note you can get motors from this company from resellers all over the world so search for these from your own country. See the distributes tag on this site.
Do not try and do too much at any one time, that is a classic beginner's mistake. Just build up your project, implementing one aspect and test it thoroughly before adding the next aspect, an so on.
Thank you so much for letting me know what is possible and what is not. Our project requires us to operate the stepper motor with arcsecond precision and to move approximately 100 - 300 arcseconds per motion depending on the microstepping mode. We also have to support approximately half a kilogram of weight. We are also required to verify this motion.
The purpose of our project in to simply demonstrate microstepping and if possible include an encoder for feedback.
We are unable to test or build our project systematically as we don't have any access to components. Our assumptions that what we chose will work are based on what we've seen online.
So far we chose the following hardware:
Nema 17
My question regarding this is that a typical Nema 17 motor is bare with just the shaft. Will we need a Nema 17 motor along with a gearbox to support the weight and achieve the required microstepping?
Arduino Mega
TMC5160 from BIGTREETECH
MKS 1.4 Gen L board
My question regarding this : We chose this because we thought that the high current requirements (1.2 A) of the motor could melt the breadboard? I am not sure.
Is a typical breadboard enough along with a external DC power supply? Is it better to use one of these boards instead?
We were thinking of some sort of optical or magnetic encoder, but were unable to find anything. For the time being, is there any way to verify the motion of the motor without an encoder?
That is simply silly, and surely a waste of everyone's time. You can't assume things will simply work. Even with the correct components, coding and tolerances can render a hand full of components that could work into a system that will not work. How are you going to demonstrate anything without access to the hardware.
Sorry there is no such thing, the coils and hence the drive requirements are different. If you measure the resistance of one of these coils and tell us then we would have a clue as to what you have, and so able to recommend at least a type of driver. But as you have not got any real motors this is impossible.
A bit unrealistic, especially when you consider the weight it has to carry. This is further complicated by the fact that you don't consider the mechanics of this weight. That is why you must specify the torque you require. Search on line to tell you how to convert a weight to a torque. Also with such a system the mechanical backlash will be significant. But again you do not have access to the actual components, but you could still do the calculations.
But why is this expressed in arcseconds? There are 60 arcseconds in an arcminuite.
We are probably talking a very lot of money here. Have you considered a magnetic absolute hall effect encoder. These are quite cheap. I have used the AS5040 sensor in one of my books for a project to turn the swinging of four pendulums into Harmonograph pictures. See the video at:-
Sadly the link to the website in the video's description is no longer working.
You will not be able to measure each individual step, but being an absolute encoder you will be able to accumulate many steps and see the result. Then simply divide the value from the encoder by the number of steps you have made to get the size of one step.
Be aware that microstepping is not suitable to get higher resolution and accuracy of the stepper. Microstep positions are much more unprecise than full step positions. Main advantage of microstepping is the more smooth and silent movement of the motor.
Thanks a lot everyone.
Through our Lab we were able to obtain a Nema 17 motor and a TMC5160 driver. Our team tried testing the NEMA 17 motor along with the driver. We just wanted to see if the motor would run for its normal step size of 1.8 degrees.
We tried driving the motor using the driver. However, the motor shaft remained stationary. We connected the driver's VCC_IO to the external power supply and its logical VCC to the Arduino. We connected the driver's A1 and A2 pins to the Red and Blue wires of motor coil A respectively and the B1 and B2 pins to the Green and Black wires of motor coil B respectively. The driver's pinout is attached. We have also attached the pinout of the motor coils we used.
We have attached images from the previous lab where we took pictures of our setup.
The other connections from the Arduino to the driver are:
EN_PIN 7
DIR_PIN 5
STEP_PIN 2
CS_PIN 11
SW_MOSI 9
SW_MISO 8
SW_SCK 10
We have attached the hardware setup and code. However, we don't know what we are doing incorrectly. Can someone please help?
Our code:
#include <TMCStepper.h>
#include <SPI.h> // Include SPI library for TMC5160 communication
// Pin Definitions
#define EN_PIN 7 // Enable Pin
#define DIR_PIN 5 // Direction Pin
#define STEP_PIN 2 // Step Pin
#define CS_PIN 11 // Chip Select (SPI communication)
#define SW_MOSI 9 // Software MOSI (not used, we use hardware SPI)
#define SW_MISO 8 // Software MISO (not used, we use hardware SPI)
#define SW_SCK 10 // Software SCK (not used, we use hardware SPI)
// TMC5160 Configuration
#define R_SENSE 0.11f // Sense resistor value, specific to your setup
// Initialize TMC5160 stepper driver
TMC5160Stepper driver(CS_PIN, R_SENSE); // TMC5160 uses SPI communication
void setup() {
// Pin Modes
pinMode(EN_PIN, OUTPUT);
pinMode(STEP_PIN, OUTPUT);
pinMode(DIR_PIN, OUTPUT);
// Enable motor driver
digitalWrite(EN_PIN, LOW); // Enable driver (active low)
// Initialize SPI communication
SPI.begin(); // Start SPI bus
// Initialize TMC5160 driver
driver.begin(); // Initialize the TMC5160 driver
driver.rms_current(1000); // Set motor RMS current (1000 mA, adjust based on your motor)
driver.microsteps(16); // Set microstepping to 1/16th (adjust if needed)
driver.en_pwm_mode(true); // Enable stealthChop for quieter operation
driver.pwm_autoscale(true); // Enable automatic current scaling for smooth operation
}
bool shaft = false;
void loop() {
// Rotate 5000 steps and switch direction
for (uint16_t i = 5000; i > 0; i--) {
digitalWrite(STEP_PIN, HIGH);
delayMicroseconds(160); // Control speed by adjusting delay
digitalWrite(STEP_PIN, LOW);
delayMicroseconds(160); // Control speed by adjusting delay
}
// Toggle motor direction
shaft = !shaft;
driver.shaft(shaft); // Reverse motor direction
}