Reference

Last revision 2026/01/08

This reference guide offers a comprehensive overview of drivers, libraries, and communication protocol descriptions to enhance device management efficiency across various platforms like Windows, Linux, MAC, and Android. It includes API descriptions, Python control capabilities, and MODBUS RTU protocol details for seamless integration and application development.

Driver

  • Driver Download Links:
  • Driver Description:
    • Windows Driver: CH340/CH341 USB to Serial Windows Driver. Supports 32/64 bits Windows 10/8.1/8/7/VISTA/XP, SERVER 2016/2012/2008/2003, 2000/ME/98. Certificated by Microsoft digital signature. Supports USB to serial port 3-wire and 9-wire.
    • Linux Driver: CH340/CH341 USB to serial port Linux Driver, supporting 32/64bits.
    • MAC Driver: CH340/CH341 USB to serial port MAC OS Driver, supporting 32/64bits. Manual included.
    • Android Driver: CH340/CH341 USB to serial port Android driver-free library for Android OS 3.1+. Includes apk, lib files (Java Driver), and APP Demo.

Library

  • Pinpong Library: Used for Python control. Install via pip3 install pinpong. Provides functions like get_version(), get_addr(), set_freq(), set_duty(), set_enable(), pwm().
  • Serial Library: Used for direct Python control. Install via pip3 install serial.
  • Modbus_tk Library: Used for direct Python control. Install via pip3 install modbus_tk.

Communication Protocol Description

  • Protocol: Standard MODBUS RTU.
  • Register Table (ModBus RTU Communication Protocol):
Type Address Name Read/Write Data Range Default Value Description
Holding Register 0×0000 PID R 0×C032 0×C032 Module PID(DRI0050)
Holding Register 0×0001 VID R 0×3343 0×3343 VID(DFRobot)
Holding Register 0×0002 Device Address R 0×0032 0×0032 Module Device Address(50)
Holding Register 0×0003 Reserve R 0×0000~0×FFFF 0×FFFF Reserve
Holding Register 0×0004 Reserve R 0×0000~0×FFFF 0×FFFF Reserve
Holding Register 0×0005 Version R 0×0000~0×00FF 0×1000 Firmware Version: 0×1000, for V1.0.0.0
Holding Register 0×0006 PWM0 Duty Ratio R/W 0×0000~0×00FF 0×007F PWM0 Output Duty Ratio(0-255 for 0%-100%)
Holding Register 0×0007 PWM0 Frequency R/W 0×0000~0×00FF 0×007F PWM0 Output Frequency(0-255 is actually frequency division factor, PWM frequency is 12M/256/(X+1)), so 0-255 corresponds to the frequency 48K-183Hz
Holding Register 0×0008 PWM Output Enable/Disable Status R/W 0×0000~0×0001 0×0000 Enable/Disable PWM0 Output

API Description

  • Pinpong Library API:
    • DRI0050(port): Initialize the module with the specified port.
    • get_version(): Get the firmware version.
    • get_addr(): Get the module address.
    • get_vid(): Get the VID.
    • get_pid(): Get the PID.
    • get_freq(): Get the current PWM frequency.
    • get_duty(): Get the current PWM duty ratio (0-1).
    • get_enable(): Get the PWM enable status (0: disabled, 1: enabled).
    • set_freq(freq): Set PWM frequency (183HZ-46875HZ).
    • set_duty(duty): Set PWM duty ratio (0-1).
    • set_enable(enable): Set PWM enable status (0 or 1).
    • pwm(freq, duty): Set PWM frequency and duty ratio simultaneously.
  • Direct Python API:
    • get_pid(): Read PID from register 0x00.
    • get_vid(): Read VID from register 0x01.
    • get_addr(): Read device address from register 0x02.
    • get_version(): Read firmware version from register 0x05.
    • get_duty(): Read duty ratio from register 0x06 (divided by 255).
    • get_freq(): Calculate frequency from register 0x07 (1210001000/256/(value+1)).
    • get_enable(): Read enable status from register 0x08.
    • set_duty(duty): Write duty ratio (0-1) to register 0x06 (multiplied by 255).
    • set_freq(freq): Calculate frequency division factor and write to register 0x07.
    • set_enable(enable): Write enable status to register 0x08.
    • pwm(freq, duty): Write duty ratio and frequency division factor to registers 0x06 and 0x07.

Other Supplementary Information

Windows platform needs Python3.5+ for Python control.
PWM frequency higher than 2K may have larger differences from the set value; refer to recommended frequencies.

Was this article helpful?

TOP