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 

Add a reference to the required dll.dll, Notefor paths must be absolute.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# Create an instance of the SMD3
class from the C# DLL class
smd3=SMD3()

#connect# Auto connect to the first SMD3 device via serial connectionfound
smd3.Connect("COM")

#move# motorChoose a temperature sensor
smd3.SensorSelect = Tsel.Thermocouple

# Move 100 steps in postivethe velocitypositive direction
smd3.MoveVelocity("+")

#wait 5 seconds
time.sleep(5)

#stop motor
smd3.Stop()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# Create an instance of the SMD4
class from the C# DLL class
smd4=SMD4()

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

#move# Move motor in clockwise direction
smd4.MoveClockwise()

#wait# Wait 5 seconds
time.sleep(5)

#stop# Stop motor
smd4.Stop()

5. Using the Enumerations 

Example code for the SMD3, showing the 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.