Skip to main content

Instructions

1. Download the latest copy of the API DLL for your product

Visit the product page for your product and look for the C# API download, for example for the SMD4, visit the link below, and look for the downloads tab at the bottom of the page. https://arunmicro.com/products/smd4-stepper-motor-drive/

2.  Download the pythonnet library

Pythonnet is a python library that allows developers to integrate .NET code within python. More information about pythonnet can be found here . htttps://pypi.org/project/pythonnet/

To install pythonnet via pip use the following command:

pip install pythonnet

3. Importing the API 

With the pythonnet library you have to import the library into your python file also by modifying the path to where the DLL is on your device. Note this file path has to be an absolute path not a relative.

Here is an example of how importing the SMD3 API would look like.

import clr
clr.AddReference(r"C:\source\SMD3API.dll")
from SMD3API import SMD3

Here is an example of how importing the SMD4  API would look like.

import clr
clr.AddReference(r"C:\source\SMD4API.dll")
from Aml.Equipment.SMD4Api import *

4. Using the API 

Example code, demonstrating connecting and moving the motor via an SMD3.

import clr 
import time
clr.AddReference(r"C:\source\SMD3API.dll")
from SMD3API import SMD3

#create an instance of the SMD3 class from the C# DLL class
smd3=SMD3()
#connect to first SMD3 device via serial connection
smd3.Connect("COM")

#move motor in postive velocity
smd3.MoveVelocity("+")

#wait 5 seconds
time.sleep(5)

#stop motor
smd3.Stop()

Example code, demonstrating connecting and moving the motor via an SMD4.

import clr
import time
clr.AddReference(r"C:\source\SMD4API.dll")
from Aml.Equipment.SMD4Api import *

#create an instance of the SMD4 class from the C# DLL class
smd4=SMD4()

#connect to first SMD4 device via all connections
smd4.Connect()

#move motor in clockwise direction
smd4.MoveClockwise()

#wait 5 seconds
time.sleep(5)

#stop motor
smd4.Stop()

INFORMATION : The SMD3 and SMD4 have commands that may not work on both devices.