The following example, using the motion program for axis 0, demonstrates the specific steps for creating a project. This method is applicable to WMX3_V3.3 and above.
Operating environment
System environment: RTX 3.7
Software version: WMX3_V3.4u1_64bit, PyCharm2019.3
Programming language: Python 3.6.2
step
1. Create a new project using PyCharm.
Figure 1. Project Creation Interface
Figure 2. Project configuration interface
2. Copy the library files to the Python project directory.
(Default location: C:\Program Files\SoftServo\WMX3\Lib\PythonApi)
Figure 3. Copying library files
3. Copy "IMDLL.dll" to the Python project directory.
(Default location: C:\Program Files\SoftServo\WMX3\Lib)
Figure 4. Copying the IMDLL file
4. Right-click the folder and select "New -- PythonFile" to create a new "Python file".
Figure 5. Creating an executable file
5. Add the following sample code to the program page to start communication. The engine will establish communication with the servo, IO module or other slave device and control the axis movement. In addition, WMX3 can also start virtual platform communication (simulator platform) for testing and simulation.
Figure 6. Writing code
from WMX3ApiPython import *
import * from time
def main():
Device=WMX3Api()
Wmx3Lib_cm = CoreMotion(Device)
Device.CreateDevice('C:\\ProgramFiles\\SoftServo\\WMX3\\',DeviceType.DeviceTypeNormal, 10000 )
Device.StartCommunication( 50 00)
sleep( 1 )
Wmx3Lib_cm.axisControl.SetServoOn( 0,1 )
sleep( 2 )
posCommand=Motion_PosCommand()
posCommand.profile.type=ProfileType.Trapezoidal
posCommand.axis = 0;
posCommand.target = 100000
posCommand.profile.velocity= 10000
posCommand.profile.startingVelocity= 0
posCommand.profile.endVelocity= 0
posCommand.profile.acc= 100000
posCommand.profile.dec= 100000
posCommand.profile.jerkAcc= 1000
posCommand.profile.jerkAccRatio= 0.5
posCommand.profile.jerkDec= 1000
posCommand.profile.jerkDecRatio= 0.5
Wmx3Lib_cm.motion.StartMov(posCommand)
Wmx3Lib_cm.motion.Wait( 0 )
sleep( 2 )
Wmx3Lib_cm.axisControl.SetServoOn( 0,0 )
Device.StopCommunication()
Device.CloseDevice()
return 0
if __name__=='__main__':
main()
6. Right-click and select "Run WMXMotion" to start the project.
Figure 7. Startup Program
7. Open the WMX3 Console tool, run the program, and monitor the communication status. When the axis number turns green and the Communication State turns On, it indicates that communication is enabled. The Op state corresponding to axis 0 is POS, indicating that the axis is in motion. Actual Pos displays the current actual position of the axis.
Figure 8. WMX3 Console Interface
Additional notes:
There are currently no 32-bit Python libraries.