Python Library

SMD Python library provides easy-to-use Python modules and methods to extensively use Acrome Smart Motor Driver products. It's user friendly for programmers at any level who have desire to learn and countless projects in mind.

Whether you need simple tasks like changing the speed of each motor or more complex processes like precise positioning, PID auto-tuning etc., this library lets you do it with the versatility of Python. You can easily implement various motor control methods.

The library also enhances your projects by allowing easy integration with SMD sensor modules. This means that it allows you to perform numerous applications by using the necessary modules for your needs. It eliminates the hassle of integrating third-party sensors and their software modules into your system, thus improving the functionality and efficiency of your project.

All you need to develop your projects using the "Acrome Smart Motor Drivers" is a computer capable of running your Python scripts.


To use Acrome Smart Motor Drivers with Python library, follow the installation steps below. The library is compatible with Python 3.x and can be installed on both Windows and Linux systems.


Before you begin, make sure you have the following prerequisites:

Beware that you should check the pip feature while installing Python 3.x. If you didn't, you always can install pip from the source for any OS.

pip installation with Python setup is demonstrated below for Windows.

"Add python.exe to PATH" is necessary for using Python from any terminal.

You can check if pip is installed properly by typing this command in terminal of any OS:

pip --version

This command will return you the version and directory of pip, which means it is installed and ready to use.

Once you have met the prerequisites, you can follow the steps for whichever OS you use.

  1. Open a Command Prompt with administrative privileges.

  2. Install the SMD library using pip (Python package manager) by running the following command:

pip install acrome-smd
  1. Wait until the installation is complete. Pip will automatically download and install the library and any required dependencies.

Verification of Installation

To verify that the SMD library has been successfully installed, open a Python interpreter and run the following command:

import smd

If no errors are raised, the installation was successful.

For usage and more info, see our Github page.

Basic Use of the Python Library

First of all, PC and SMD connections should be made. Connect your USB gateway module to your PC's USB port and connect your SMD to the gateway module with an RJ-11 cable. Lastly, connect a 12V adapter to supply power to the SMD.

There are basics to start programming with SMD Python library. First, the user needs to know the serial port (COM... or /dev/tty...) of the connected USB gateway module, COM3 as an example.

Since SMD cards can be connected to each other, each of them can have a different ID by user's choice. However, an SMD Red has an ID of 0 by default. This value can be intentionally changed between 0 - 255 .

SMD can communicate with different baud rates, user may want to change baud rate depending on the needs of project. SMD Red has a default baud rate of 115200.

With all this information, the crucial part of coding can begin.

Here is the first part of the code:

from import *

SerialPort = "COM3"    # Serial port of the USB gateway module
baudrate = 115200      # Baud rate of the communication
ID = 0                 # ID of the SMD board

master = Master(SerialPort, baudrate)    # Defines the USB gateway module
master.attach(Red(ID))                   # Gives acces to the SMD of specified ID

This code snippet acts as a communication setup for SMD.

We defined baud rate as 115200 and ID as 0 (default SMD ID, if it wasn't changed), and used Masterclass to create an object named master, object name depends on user. Then, we used necessary parameters of Masterclass, which are serial port and baud rate.

Serial port value can be different device to device, so the user can change the code of the serial port as COM... or /dev/tty... according to the OS.

Then we can do our first application , PID auto-tune and velocity control, to practice with our library. You will need an SMD and a brushed DC motor, which are included in the Starter Kit.

We start with the communication setup, and then add the necessary motor control functions, which will be explained below.

from import *

SerialPort = "COM3"    # Serial port of the USB gateway module
baudrate = 115200      # Baud rate of the communication
ID = 0                 # ID of the SMD board

master = Master(SerialPort, baudrate)    # Defines the USB gateway module
master.attach(Red(ID))                   # Gives acces to the SMD of specified ID

master.set_operation_mode(ID, OperationMode.Velocity)    # Sets the motor's operation mode as "Velocity"
master.set_shaft_rpm(ID, 100)        # Defines the motor RPM value as 100
master.set_shaft_cpr(ID, 6533)       # Defines the motor CPR value as 6533
master.pid_tuner(ID)                 # Starts the PID auto-tune process
time.sleep(30)    # Waits 30 seconds for the process to complete
print(master.get_control_parameters_velocity(ID))    # Prints the calculated PID values

master.enable_torque(ID, True)       # Enables motor to operate
master.set_velocity(ID, 50)          # Sets motor to operate at 50 RPM

You should specify the ID of the target SMD when using functions, in this application there is only one SMD and it has an ID of 0, which is also defined as ID variable.

There are various operation modes for motor control, for example, we have selected "Velocity" control mode, which allows the motor to be controlled in terms of RPM value.

Then, we specified the RPM and CPR value of motor, in order to be tuned properly. Brushed DC motor in Starter Kit has 100 RPM and 6533 CPR value.

To run the PID auto-tune process, we use the pid_tuner() function with the ID of the target SMD. After running the function, the motor will start spinning and the process will take about 30 seconds. That's why we put the time.sleep(30) in order to wait for any other processes before the end of the process. The calculated PID values are printed with the get_control_parameters_...() function, the last part of function name changes with the operation mode of the motor, which in our application is "Velocity".

For all detailed function and feature explanations of Python library, visit the Python library GitHub page.

For more use cases, visit the projects and see the Python codes:


Last updated