Controlling Different Types of DC Motors Synchronously
by Acrome Robotics in Circuits > Robots
400 Views, 3 Favorites, 0 Comments
Controlling Different Types of DC Motors Synchronously
This project is aimed to provide a well-rounded motor synchronization application using linear motors and DC brushed motors. Whether you are a seasoned engineer, a robotics enthusiast, or someone new to the field, this post will equip you with the knowledge you need to understand the intricacies of application of combination of Linear motor and synchronizing DC Motors in robotics and industrial automation settings.
To learn more about the application, its use-case and details about the components, feel free to read the detailed blog post available on ACROME's website at this link:https://www.acrome.net/post/synchronizing-linear-motors-and-dc-motors
Supplies
- 3x Acrome's Smart Motor Driver (SMD)
- 2x Pololu's 37D Metal Gearmotors
- 1x Progressive Automation's Mini Linear Actuator
- 3x RJ11 Cables
- 1x 12V DC Adapter Power Cable
- 2x Power to Power Cables
- One Personal Computer to run the python code
Selecting the Right Motor Controllers - Smart Motor Drivers (SMD)
The game changer of the field of motor control and synchronization is Acrome's Smart Motor Driver (SMD). This versatile, high-performance motor driver, including DC and linear motors, is designed to manage a range of motor types. In this Project we are going to discuss the SMD RED, which is used to control Brushed DC Motors.
Setting Up the Hardware
If you are looking for the crazy pin layouts and the number of jumper cables you need to use, you will not find it here. Using Acrome's SMD is easier than you think.
Since each SMD drives one Motor, first you start by connecting each of the three motors to one of the SMDs. You just have to connect only one of the SMDs to the power supply or the adapter with a 12V DC Adapter Power Cable. Then connect the other two SMDs to the first one without worrying about the order. Only two cables are needed to connect SMD's with each other. Power to Power cable for power supply and RJ11 cable for communication. By connecting the first SMD to your computer through the MasterCard's USB port, you can now compile the python code and start your application!
The Coding
Here is the Python code for move_math containing the Sinus Functions
import math
import decimal
import time
from smd.red import *
def float_range(start, stop, step):
while start < stop:
yield float(start)
start += decimal.Decimal(step)
timePoints = list(float_range(0, 4.18, '0.1'))
def SinVelocity(x):
final = 50*math.sin((1.5)*x)
if final < 0:
return -1 * final
else:
return final
def Sin_pwm80(x):
final = 80*math.sin((1.5)*x)
return final
And here is the Main Python code for the Synchronizing DC and Linear Motors Application
from move_math import *
import threading
from smd.red import *
port = "COM12"
m = Master(port)
#We need to know the IDs of the SMDs used
m.scan()
linear_ID = 0
dc1_ID = 1
dc2_ID = 2
# setting the operation modes of SMDs
m.set_operation_mode(linear_ID, OperationMode.PWM)
m.set_operation_mode(dc1_ID, OperationMode.Velocity)
m.set_operation_mode(dc2_ID, OperationMode.Velocity)
def driveID():
while True:
for t in timePoints :
m.set_duty_cycle(id, Sin_pwm80(t))
time.sleep(0.1)
def driveID1():
while True:
for t in timePoints :
m.set_velocity(id, SinVelocity(t))
time.sleep(0.1)
def driveID2():
while True:
for t in timePoints :
m.set_velocity(id, SinVelocity(t))
time.sleep(0.1)
m.enable_torque(linear_ID, True) #enables the motor torque to start rotating
m.enable_torque(dc1_ID, True)
m.enable_torque(dc2_ID, True)
if __name__ =="__main__":
t1 = threading.Thread(target=driveID, args=())
t2 = threading.Thread(target=driveID1, args=())
t3 = threading.Thread(target=driveID2, args=())
t1.start()
t2.start()
t3.start()
t1.join()
t2.join()
t3.join()
print("Done!")
You can also access this code through our Github page.
Result (Demo)
Here is a video demonstration done by the Acrome team.
Share the Experience
That's all for this project! Feel free to add your comments, leave tips or ask any questions you have. Tackled a project like this before? Give us a virtual high-five, hit that 'I made it' button and share the love! You can also contact us for further questions about our products. The Acrome team is always ready and happy to help you!