Skip to main content

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 SMD4 and SMD3 devices, allowing seamless integration into Python projects.  To install the package, visit smdAPI · PyPI

To use smdAPI, you need to import it into your Python project. Here’s how to import based on your needs:

For SMD4:

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. 

You can create multiple instances for multiple SMD devices as demonstrated below:
# 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()