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
Add a reference to the required dll, for example:
import clr
clr.AddReference(r"C:\source\SMD3API.dll")
from SMD3API import SMD3
4. Using the API
Example code for the SMD3, demonstrating connecting to the drive and moving the motor.
import clr
import time
clr.AddReference(r"C:\source\SMD3API.dll")
from SMD3API import SMD3
# Create an instance of the SMD3
smd3=SMD3()
# Auto connect to the first SMD3 device found
smd3.Connect("COM")
# Choose a temperature sensor
smd3.SensorSelect = Tsel.Thermocouple
# Move 100 steps in the positive direction
smd3.MoveRelative(100)
Example code for the SMD4, demonstrating connecting to the drive and moving the motor.
import clr
import time
clr.AddReference(r"C:\source\SMD4API.dll")
from Aml.Equipment.SMD4Api import *
# Create an instance of the SMD4
smd4=SMD4()
# Auto connect to the first SMD4
smd4.Connect()
# Move motor in clockwise direction
smd4.MoveClockwise()
# Wait 5 seconds
time.sleep(5)
# Stop motor
smd4.Stop()