Software APIs
Introduction
Software APIs provide a means to control the SMD4 through your own software application. The AML device control application uses the same APIs to interact with the SMD4. The API is natively a C# class library supplied as a DLL which can be wrapped allowing use in other environments.
C#
Download the DLL from the downloads section of the product page on our website, https://arunmicro.com/products/smd4-stepper-motor-drive/
It is supplied as a zip file containing a visual studio project, and the API DLL and associated files. The example project demonstrates basic aspects such as connecting to a device, configuring it and programming sequences of moves.
Python
The SMDApi library supports SMD3 and SMD4 devices, allowing seamless integration into Python projects.
1. Ensure pip is Installed and Updated
Before installing SMDApi, confirm that pip is installed and updated to the latest version. Use the following commands based on your operating system:
Windows:
python -m pip install --upgrade pip
Linux/MacOS:
python3 -m pip install --upgrade pip
2. Install the SMDApi Library
To install the latest version, run:
pip install SMDApi
3. Import the library into your python project.
from SMDApi import SMD4
For SMD3:
from SMDApi import SMD3
For Both SMD3 and SMD4:
from SMDApi import *
4. Create a new instance of SMD3 or SMD4.
# Create instances of SMD4
smd4_1= SMD4()
smd4_2 = SMD4()
#create an instance of SMD3
smd3 = SMD3()
Example code for SMD4
This example demonstrates how to rotate the motor and increase the step frequency every 5 seconds by 1000Hz. Once the frequency reaches 5000Hz, the motor will stop and disconnect.
from SMDAPI import SMD4
import time
smd4=SMD4()
smd4.Connect()
smd4.StepFrequency = 100
smd4.MoveClockwise()
for i in range(1,5):
smd4.StepFrequency = 100*i
time.sleep(5)
smd4.Stop()
smd4.Disconnect()
License
SMDApi is under the MIT License which allows to deal in the Software without restriction including the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software.
Refrences
SMDApi uses the pythonnet library. When you install SMDApi, the pythonnet library will also be installed automatically with the latest version. More details about pythonnet can be found here: pythonnet