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. Note paths must be absolute.
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 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 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 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()
5. Using the Enumerations
Example code for the SMD3, showing use of enumerations.
import clr
clr.AddReference(r"C:\source\SMD3API.dll")
from SMD3API import *
#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")
#set the temperature selection to thermocouple (Tsel.Thermocouple is a enum)
smd3.SensorSelect = Tsel.Thermocouple
INFORMATION: The SMD3 and SMD4 do not have the same commands. Always refer to the C# API documentation for your device.