Motor Rotation Based on Turn Input Value
Last updated
Last updated
This program demonstrates a simple motor control application using Python. The main objective of the script is to rotate a motor by a specific number of turns, which is determined by the user input. The motor's position is tracked, and it continues to rotate until the desired number of turns is achieved.
About Tools and Materials:
()
()
()
()
Project Key Components
The SMD acts as a bridge between the script and the modules. It is responsible for interpreting the commands sent by the script and translating them into actions that read input from the and actuate the BDC motor, the and the .
The motor is controlled using velocity commands, allowing for smooth acceleration and deceleration.
Project Key Features
Establishes a connection with the SMD Red motor using the Master and Red classes from the smd.red library.
Allows users to specify the number of turns for the motor, using an encoder with a predefined steps-per-turn value.
Continuously monitors the motor’s position and stops it once the desired rotation is achieved.
Sets the motor velocity dynamically, starting with maximum speed and stopping precisely at the target position.
Designed to work efficiently within multi-threaded applications for real-time motor control.
Getting Started
Hardware Setup
Make sure that the SMD is powered and all connections are correct.
Run the Script
Execute the script to initiate the Motor Rotation Based on Turn Input Value project.
Enter different turn values in the control interface to observe the motor behavior.
Input a positive value to rotate the motor clockwise (CW).
Input a negative value to rotate the motor counterclockwise (CCW).
Input zero (0) to stop the motor.
Observe how the motor speed dynamically adjusts based on the magnitude of the input value.
• Modify input values in the script to control the speed and rotation direction.
• Experiment with different PWM signal ranges to fine-tune motor performance.
• Implement acceleration profiles to create smoother speed transitions.
• If using an encoder, integrate it for closed-loop control and precise motor positioning.
When the program is executed, it will ask the user to input the number of turns:
After the user inputs the value (e.g., 5), the motor will rotate the equivalent number of turns. The program will print a message once the motor has completed the rotation:
Connect the SMD to the PC or Arduino board using or .
Connect the 100 RPM with Encoder to the motor ports of the SMD using an RJ-45 cable.