We are constantly trying to offer our valued users as much support as possible. We take into account all their suggestions and wishes. Consequently, we decided to reveal PoStep60 USB communication protocol. In addition to I2C and Modbus serial interface, you will now be able to write your own app to communicate with the USB stepper motor controller.
The API describes all read and write commands for complete driver control. Namely, all the settings we make with PoStep60 application now we can completely perform with custom application as well.
About the USB stepper motor controller PoStep60-256
The PoStep60-256 driver incorporates advanced stepper motor driver and external N-channel MOSFETs to drive a bipolar stepper motor or two brushed DC motors. A driver has a micro-stepping indexer integrated, which is capable of step modes from full step to 1/256-step. An ultra-smooth motion profile we achieve using adaptive blanking time and various current decay modes, including an auto-mixed decay mode. A simple step/direction or PWM interface allows easy interfacing to controller circuits. An I2C serial interface or Modbus-RTU over RS485 can we further use to control all the driver functions including position control on board.
All running parameters (output current (torque), micro-stepping, step mode, decay mode…) can be set over USB and stored onboard for stand-alone operation. Internal shutdown functions are provided for overcurrent protection, short circuit protection, under-voltage lockout and over temperature. Fault conditions indicate a FAULT LED, and each fault condition can we read in the configuration software. All information about stepper motor driver you can find: stepper motor driver- complete explanation.
The API you may find in updated PoStep60 User Manual.
USB protocol description
PoStep60-256 is USB HID-compliant vendor-defined device. It uses OS’s integrated drivers to communicate with software. No additional drivers are necessary to communicate with device. USB stepper motor controller PoStep60 board uses following descriptors:
Each PoStep60 has it’s own unique serial number. The serial number can be used to enumerate USB device when more then one PoStep60 is connected to computer.
The device uses endpoint IN and endpoint OUT descriptors as shown above. The data package size 64 Bytes is the same for both directions. More information you can find in PoStep60 User manual.
How to start programming
At the start, choose your favorite software development tool. For our example, we used a VisualStudio19 and libusb.h library. For more advanced applications you will need some additional knowledge about the specific driver which you will find in a IC’s data-sheet. The exact IC type number you can find in a PoStep60 user manual.
In the next lines we will introduce a basic example how to connect to the device and send a specific command.
First we define PoStep60 specific PID and VID (product and vendor identity) and declare USB session.
Than we initialize the library and connect to the device using next functions:
libusb_init(&ctx); dev_handle = libusb_open_device_with_vid_pid(ctx, PID, VID); libusb_kernel_driver_active(dev_handle, 0); libusb_claim_interface(dev_handle, 0);
After that we will read PoStep60 info registers. In short, we going to use write_PoStep(data) and read_PoStep(data) functions. In that case we will send a GET DEVICE INFO as output_byte = 0x01 command to the device. It is important that the output_data is always 0x00! The response from the driver will be 64 byte long. As an example we will parse data bytes[8…9] and bytes[44…45] and get driver’s supply voltage and temperature, for instance. More about that you should read in PoStep60 user manual chapter “USB Commands”. Finally we send command to move a stepper motor for few second in one direction and then with double speed to a reverse direction. To achieve that we use commands 0xA1(RUN/SLEEP) and 0x90 (WRITE STEP/DIR DATA).
The entire source code you can download here: USB_PoStep60_example.cpp
USB stepper motor controller – conclusion
For developing custom software we can take as an example the PoStep60 application. The driver has quite a range of parameters that can be set. You can choose between different modes of operation. Namely, specify micro-stepping, torque, and decay parameters, check for driver’s status, save settings to EEPROM, and so on. However, for some of them, we must write to the driver’s specific registers according to the chip datasheet. Please, be aware that writing a specific command can lead to sudden motor movement!
Stepper motor controller IC link.
Under downloads find the PoStep60 user manual.
If you are interested in using Modbus read this blog.
Please also check our latest blog posts and products. It can help you to improve your machines or get some ideas on how to even make them better.
- CNC controller: Pokeys57CNC
- Bipolar stepper motor driver – PoStep25-256
- Homing sensor
- Torch height controller – THC
- PCB tester – PoStep25-256
- 4th axis for CNC router
- Introduction to CNC hardware – electronics
- Plasma cutting equipment
- What is CNC plasma cutting
- CNC plasma floating head
- Plasma cutter troubleshooting guide