The stepper motor control shield, powered by Infineon’s H-bridge IFX9201 and XMC1300 microcontroller, is designed to simplify the task of driving a stepper motor for beginners. It is capable of controlling the two coils in a stepper motor through its dual H-bridge configuration. Additionally, the shield enables motor control by sending a STEP signal via the STEP Pin, and it can be easily connected to a microcontroller due to the integrated XMC1300 microcontroller with high-speed control capabilities.
Now that the product itself is properly pitched! Let's take a step back and look into what a stepper motor actually is: A stepper motor is like a robot that can turn its own wheels and stop exactly when you tell it to. Inside the motor, there are special coils and a magnet. By turning these coils on and off in a particular order, the motor can take small, precise steps. This makes it perfect for things like 3D printers, where accuracy is super important. A simplified picture of a stepper motor is shown in the next picture.
The motor moves in these tiny steps because it's designed to do so. Each time you give it a "command, " it turns a little bit, like a clock ticking. These commands are usually given by a special device that controls the motor, telling it when to move and how far.
There are different types of stepper motors. Some have two coils, others have more. Each type has its own strengths and weaknesses. But the cool thing about all of them is that they can move very accurately and hold their position without needing extra power.
So, when you're building something that needs to move precisely – like a camera slider or a robotic arm – a stepper motor can be your best friend. Just remember, they're not great at going super fast, and they can get a bit hot if you make them work too hard. But for careful, steady movement, they're hard to beat!
CompatibilityThe shield is suitable for driving loads with peak currents of up to 6 A, with realistic continuous drive currents typically around 2 A per coil. When connecting stepper motors, it's important to ensure that the nominal voltage of the motor is lower than the supply voltage. The Stepper Motor Control Shield regulates the current and reduces the output voltage using PWM, providing safe and controlled operation for bipolar stepper motors (4-wire connection).
It is intended to use as a shield with an XMC 1100 Boot Kit or XMC4700 Relax Kit for 5V shields but can also be controlled by other methods.
Considering these compatibility factors will help ensure the proper matching of stepper motors with the capabilities and limitations of the IFX9201 and Stepper Motor Control Shield for a reliable and efficient operation.
Operation ModesFull Step, Half Step, and Microstep are different ways of controlling and moving a stepper motor, each offering its own advantages and characteristics. Let me explain each of them in more detail:
- Full Step: In full-step mode, the motor takes one step at a time, moving to the next stable position. This means that for a typical 1.8-degree stepper motor, it would move 1.8 degrees for each step. Full stepping provides good torque and simple control, making it suitable for applications that prioritize torque over precision, such as driving mechanical loads.
- Half Step: Half-stepping is a method that allows the motor to move in smaller increments than full-stepping by energizing the coils in a specific sequence. With half-stepping, the motor can take steps that are half the angle of a full step, such as 0.9 degrees in the case of a 1.8-degree stepper motor. This approach provides higher resolution and smoother motion but may sacrifice some torque compared to full stepping.
- Microstep: Microstepping takes precision even further by dividing the motor step into much smaller parts. This is achieved by controlling the current in the motor coils in a more gradual and controlled manner, allowing for very fine movement. Microstepping results in reduced vibration, quieter operation, and improved positioning accuracy. It's commonly used in applications that demand high accuracy and smooth motion, such as precision manufacturing equipment and 3D printers. An example of the current profiles for one “full” step is shown in the next Figure.
Each of these control methods offers a trade-off between torque, resolution, and smoothness of motion. Full stepping provides good torque but lower resolution, while micro stepping sacrifices some torque for higher resolution and smoother motion. Half-stepping falls between the two, offering a balance between torque and resolution. The choice of which method to use depends on the specific requirements of the application, such as the need for precision, speed and torque.
Pin BreakDownThe top view in the picture of the stepper motor control shield shows all the key components of the board.
The inside of the shield includes the XMC1302 and two IFX9201 controller. Besides the power supply the board includes the necessary output pins for the stepper motor. The rest of the pins you should or could use are:
- DIS: Disable/Enable
- STP: Steps Input
- DIR: Direction of steps
An better example on how to connect the motor control shield is shown in the following picture:
The potentiometer on the board limits the current delivery to the motor. Adjust like in the picture:
In your Arduino IDE click on Tools and Manage Libraries (Press CTRL+Shift+I) for short. The Library Manager window should pop up (sometimes it takes a couple of seconds to load). Then search for IFX9201_XMC1300_StepperMotor and click Install.
Of course, now that the library is installed it is a given that we would have to include it like allways at the very top of our code. Whenever we try and use the shield just use:
#include <IFX9201_XMC1300_StepperMotor.h>
Programming GuideStepper Object instantiation
First and foremost, the initial step involves the instantiation of a stepper object. To instantiate it you'll have to call the constructor of the Stepper_motor class which initializes an instance of the class for controlling a stepper motor. Include are the following parameters:
- StepsPerRevolution:This parameter represents the total number of steps per revolution for the specific stepper motor being controlled. It defines how many steps the motor needs to complete a full 360-degree rotation. For example, a typical 1.8-degree stepper motor would have 200 steps per revolution (360 degrees / 1.8 degrees per step).
- DIR_PIN:The DIR_PIN parameter specifies the pin number associated with the direction control of the stepper motor. This pin is used to set the direction of rotation for the motor and is typically connected to the driver or controller circuit.
- STP_PIN:The STP_PIN parameter represents the pin number used to send step pulses to the stepper motor. Each pulse received by this pin causes the motor to move one step in the specified direction.
- DIS_PIN:The DIS_PIN parameter indicates the pin number used to enable or disable the stepper motor. This pin is often used to control the power supply to the motor, allowing it to be turned on or off as needed.
Here you can find an example of the instantiation:
Stepper_motor MyStepperMotor = Stepper_motor(StepsPerRevolution, DIR_PIN, STP_PIN, DIS_PIN);
Control
To start using the stepper motor you have to call the begin() method into the stepper motor object we just instantiated. For example:
MyStepperMotor.begin();
Set the speed by using the setSpeed() method. This method takes the speed in rotations per minute. For example:
MyStepperMotor.setSpeed(60);
To move the motor you could use either:
- move_degree( ): takes in input the amount of degrees to rotate (+ve input indicates clockwise rotation, while -ve numbers cause counter clockwise motion)
- step( ): takes in input the amount of steps to rotate (+ve input indicates clockwise rotation, while -ve numbers cause counter clockwise motion)
To stop the motor use the end( ) method.
Note: In most applications (even when the motor is not spinning) the motor emits some noise on standby. To avoid that you could disable the motor when you're not using it and re-enable it by using the begin( ) method.
Configuration
For configuring the functionality of the motor we need to instantiate a configuration variable and specify the configuration metrics which are:
Stepping Mode:
The Stepping Mode parameter determines the stepping mode of the stepper motor. It can be set to one of the following values:
- IFX9201_STEPPERMOTOR_STEPPINGMODE_FULL: This corresponds to full-step operation, where the motor moves in its full step angle for each step.
- IFX9201_STEPPERMOTOR_STEPPINGMODE_HALF: This corresponds to half-step operation, allowing the motor to take steps that are half the angle of a full step.
- IFX9201_STEPPERMOTOR_STEPPINGMODE_MICROSTEP: This enables microstepping, allowing for even smaller incremental movements of the motor shaft.
PWM Output Frequency:
- The FreqPWMOut parameter specifies the PWM output frequency, measured in Hertz (Hz). It determines how rapidly the PWM signal is switched on and off to control the current flow through the motor windings.
PWM Duty Cycle Normalization Factor:
- The PWMDutyCycleNormFactor represents the duty cycle of the PWM signal, normalized to a specific range. It influences the proportion of time that the PWM signal is in the "on" state versus the "off" state, regulating the effective current supplied to the stepper motor windings.
Number of Microsteps:
- The NumMicrosteps parameter defines the number of microsteps per full step of the motor. Microstepping allows for finer control and smoother motion by subdividing each full step into smaller increments, enhancing the motor's positional accuracy and reducing vibration.
Store Configuration:
- The Store parameter determines whether the configured settings should be stored in the non-volatile memory (NVM) of the stepper motor. It can be set to either IFX9201_STEPPERMOTOR_STEPPINGMODE_STORE_CONFIG or IFX9201_STEPPERMOTOR_STEPPINGMODE_DO_NOT_STORE_CONFIG, depending on whether the configuration should be retained across power cycles.
Loadingthe configuration
After instantiating and setting the configuration variable to your liking you'll have to load it.
Here you can find an example of the configuration instantiation and loading:
IFX9201_STEPPERMOTOR_config_t example_config =
{
.SteppingpMode = IFX9201_STEPPERMOTOR_STEPPINGMODE_FULL,
.FreqPWMOut = 20000u,
.PWMDutyCycleNormFactor = 2000u,
.NumMicrosteps = 64,
.Store = IFX9201_STEPPERMOTOR_STEPPINGMODE_DO_NOT_STORE_CONFIG
};
MyStepperMotor.configure(CONFIG_SERIAL, &example_config);
If you have your configuration finished you can try out the modes with you stepper motor. In our example we used it together with the XMC1100. A short video of the runing example is demonstrated in the video below.
That's it for today! Thanks for tunning in to this protip, feel free to check out the example code samples provided by the stepper motor library and check out the rest of our protips on our hackster account by clicking HERE!
Comments
Please log in or sign up to comment.