A stepper motor is an electric motor that converts electrical pulse signals into corresponding angular displacement or linear displacement. For each input pulse signal, the rotor rotates an angle or moves forward one step. The output angular displacement or linear displacement is proportional to the number of input pulses, and the speed is proportional to the pulse frequency. Therefore, a stepper motor is also called a pulse motor.
Stepper motors usually need to be paired with a stepper motor driver module (also called a stepper motor driver) to work. A stepper motor driver is an actuator that converts electrical pulses into angular displacement. When the stepper driver receives a pulse signal, it drives the stepper motor to rotate a fixed angle (called the "step angle") in the set direction. Its rotation runs step by step at a fixed angle. The angular displacement can be controlled by controlling the number of pulses to achieve accurate positioning; at the same time, the speed and acceleration of the motor rotation can be controlled by controlling the pulse frequency to achieve speed regulation and positioning.
According to the different power-on sequences, four-phase stepper motors can be divided into three working modes: single four-beat, double four-beat, and eight-beat. The step angles of single four-beat and double four-beat are equal, but the torque of single four-beat is small. The step angle of eight-beat working mode is half of that of single four-beat and double four-beat. Therefore, the eight-beat working mode can maintain a high torque and improve control accuracy. The driver is equivalent to a combination unit of switches. The motor phase sequence is energized in sequence through the pulse signal of the host computer to make the motor rotate.
This article uses the 28BJY-48 stepper motor.
Hardware Hookup
First, you need to connect the stepper motor and the motor driver board. Simply insert the white plug of the motor into the white slot on the driver board (pay attention to the direction of the buckle).
Then connect the driver board and Raspberry Pico. The wiring is as follows:
The + pin of the motor driver board is connected to the VSYS of Pico.
The – pin of the motor driver board is connected to the GND of the Pico.
The IN1 pin of the motor driver board is connected to the GP18 of Pico.
The IN2 pin of the motor driver board is connected to the GP19 of Pico.
The IN3 pin of the motor driver board is connected to the GP20 of Pico.
The IN4 pin of the motor driver board is connected to the GP21 of Pico.
programming
Save the following code in the root directory of Pico as main.py.
from machine import Pin
import utime
# Initialize the pins of the stepper driver module
in1 = Pin(18,Pin.OUT)
in2 = Pin(19,Pin.OUT)
in3 = Pin(20,Pin.OUT)
in4 = Pin(21,Pin.OUT)
ROUND_VALUE = 509
delay = 1
# Sequence value of four-phase eight-beat stepper motor
STEP_VALUE = [
[0,0,0,1],
[0,0,1,1],
[0,0,1,0],
[0,1,1,0],
[0,1,0,0],
[1,1,0,0],
[1,0,0,0],
[1,0,0,1],
]
# Reset pin output low level
def reset():
in1(0)
in2(0)
in3(0)
in4(0)
# Single-step clockwise rotation, count is the step value, which can be negative (counterclockwise)
def step_run(count):
direction = 1
if count < 0:
direction = -1
count = -count
for x in range(count):
for bit in STEP_VALUE[::direction]:
in1(bit[0])
in2(bit[1])
in3(bit[2])
in4(bit[3])
utime.sleep_ms(delay)
# Rotate clockwise at a specified angle, a is the angle value, which can be negative (counterclockwise)
def step_angle(a):
step_run(int(ROUND_VALUE * a / 360))
# Reset the driver board
reset()
# Rotate 90 degrees counterclockwise
step_angle(-90)
# Continue to rotate clockwise in single step
while True:
step_run(1)
The program defines the driving mode and parameters of this stepper motor. There are two ways to drive it: step_angle (angle) or step_run (number of steps).
After running, you can see that the stepper motor first rotates 90 degrees counterclockwise and then continues to run clockwise.
Previous article:Share the correspondence table between 20 PLC component numbers and Modbus number addresses
Next article:What is a stepper motor? Simple stepper motor drive debugging
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Issues with chip drive power and load size
- [NXP Rapid IoT Review] NO1. First experience with NXP Rapid LoT development kit
- [TI recommended course] #TPS65086100: User programming of multi-rail power management IC#
- DAC analog multiplier, DDS (frequency synthesizer), signal generator
- For beginners of TI 6000 series DSP
- MSP430F6638 MCU interrupt, clock and low power consumption
- How to draw this circuit in dxp
- 【CH579M-R1】2. SYSTICK + GPIO + INT
- Microchip Live at 10:00 today: MCU programming is no longer difficult, use MPLAB Code Configurator (MCC) to achieve rapid development
- Application of TMS320DM642 in ATP Technology of Mobile Platform