Share this

Quick Start Guide | Part Twelve: Using the USB Interface of the Positive Motion Technology Motion Controller

2026-04-06 04:50:05 · · #1

Previously, Zheng Motion Technology shared with everyone the firmware upgrade of motion controllers, ZBasic program development, ZPLC program development, communication with touch screens and application of input/output IO, application of motion controller data and storage, use of motion controller ZCAN and EtherCAT bus, application of oscilloscopes, characteristics of multi-tasking operation, and application of motion controller interrupts.

Today, we will explain how to use the USB flash drive interface of the positive motion technology motion controller.

Video Tutorial : "Video Tutorial: Using the USB Interface of the Positive Motion Technology Motion Controller"

The following is a detailed explanation with pictures and text.

1. Material preparation and controller wiring reference

1) Material preparation

2) Controller Wiring Reference

2. Uses of a USB flash drive

The usage method of the USB flash drive interface is the same for different models of controllers.

Simply plug the USB flash drive into the UDISK port on the controller. The USB flash drive indicator light will illuminate when the controller is powered on and a USB flash drive is inserted.

USB flash drives are mainly used for two purposes:

1) Program upgrade

Download the pre-packaged ZAR software via USB flash drive for easy system updates.

Before upgrading the program, download the ZAR program package to a USB drive. After successfully loading the file from the USB drive using the command, the ZAR program will start running automatically.

2) Data exchange between USB flash drive and register

USB flash drive read and write variables and arrays.

FLASH data copying: Data stored in the FLASH memory of multiple controllers can be transferred between them via USB flash drive.

Data can be transferred between the VR register, the TABLE register, and the USB flash drive.

The file types that can be read and written are SD(filenum).BIN or SD(filenum).CSV, and the different file types that can be operated on vary depending on the command.

3. USB flash drive read/write commands

U_STATE: USB flash drive status check. Returns TRUE if a USB flash drive is detected, otherwise returns FALSE.

1) Reading and writing variables and arrays on a USB flash drive

U_READ: Reads data from the USB drive into a variable or array.

U_READ2: Reads data from the USB drive into a variable or array, with the option to specify the starting position for reading.

U_WRITE: Stores variables or arrays, or individual or partial elements of an array, into external memory.

2) Data exchange between USB flash drive and register

USB flash drives use the same data read/write format as TABLE and VR.

STICK_READ: Reads data from the USB drive into the table.

STICK_WRITE: Copy the data from the TABLE to the USB drive.

STICK_READVR: Reads data from the USB drive into VR.

STICK_WRITEVR: Copy VR data to USB drive.

4. Example of USB flash drive read/write

Before the controller can read or write to the USB drive, it must first ensure that the USB drive is plugged in and use the U_STATE command to determine the status of the USB drive.

Operation commands: U_READ, U_WRITE

Example:

Note that the order in which data is stored and read from the USB drive must be consistent.

If a controller is unavailable, an emulator can be used. Create a file named udisk in the root directory of the programming software to simulate a USB drive. Place the files needed for USB drive command operations into this folder.

1) Operations on USB flash drive ZAR files.

2) Data operations between USB flash drives and FLASH memory.

The FLASH block number and the SD file number are in one-to-one correspondence and do not need to be specified.

3) Delete files on the USB drive, supporting the deletion of bin and z3p files.

4) Load files from the USB drive in byte mode, supporting the reading of various file types.

FILE "LOAD_BYTE", "00.txt" , 200, 10, 0

Read the file named 00.txt from the USB drive, convert the reading result into ASCII code, and store it in 10 spaces starting from TABLE( 200 ).

The last parameter, offset, is the byte offset at which the file begins to be read. Setting it to 0 means starting to read from the first character; setting it to 1 means starting to read from the second character and skipping the first character. See the program demonstration below for details.

The contents of the txt file are: ZMOTION

Command read result:

TABLE(200): Total number of bytes

TABLE(201): The first byte read

TABLE(202): The second byte read

TABLE(200+n): The Nth byte read

6. Example program for using USB flash drive

The example uses HMI configuration to pass the value of the MODBUS_BIT bit register to control the execution of USB drive commands.

global sub main_int() 'Initialization function

APP_PASS(123)

VRSTRING(1200,20)="Unscanned"

global warnstr(20) 'Defines an array of warning messages'

dim result 'flag indicating the result of the file command read'

result=0 'Returns -1 for true, 0 for false'

dim filenum 'zar file number'

filenum=0

for i=0 to 100

table(i)=i

next

dim u,uu(8) 'USB flash drive read/write parameters

u=10

for i=0 to 7

uu(i)=i

next

dim a,aa(8) 'FLASH read/write parameters

end sub



global sub main_scan() 'Periodic function

If U_STATE=TRUE, then 'Get the USB drive status and display whether it is connected or not'

table ( 100 ) = 1

elseif U_STATE = FALSE then

table ( 100 ) = 0

endif

If U_STATE = TRUE , then check if the USB drive is inserted.

'************Load the ZAR upgrade program from the USB drive************'

if MODBUS_BIT( 0 ) = 1 then 'Check if the button is pressed.'

MODBUS_BIT(0)=0 'Key recovery'

The code `result = FILE "find_first",".zar" , 1200` can be replaced with `.bin`, but it cannot be downloaded using `load_bin`.

If result = -1 then 'Check if the ZAR program read successfully'

filenum= 1

else

Print "No file"

endif

elseif MODBUS_BIT( 10 )= 1 and result = -1 then

MODBUS_BIT( 10 ) = 0

result = FILE " find_prev ", 1200 ' Search for files from the previous USB drive'

if result=-1 then

filenum = filenum - 1

else

result=FILE"find_next",1200

warnstr = "The First File"

HMI_SHOWWINDOW(100)

endif


elseif MODBUS_BIT(20)=1 and result=-1 then

MODBUS_BIT(20)=0

result=FILE"find_next",1200 'Search for the previous USB drive file'

if result = -1 then

filenum = filenum + 1

else

result = FILE " find_prev ", 1200

warnstr=" The End File "

HMI_SHOWWINDOW( 100 )

endif

elseif MODBUS_BIT( 30 )= 1 then

MODBUS_BIT( 30 ) = 0

result = FILE " load_zar ", VRSTRING( 1200, 20 ) 'Load the ZAR upgrade file from the USB drive'

if result = 0 then

result=FILE"find_first",".zar",1200

warnstr="Download Failed"

HMI_SHOWWINDOW(100)

endif

'************Data Interaction Between USB Drive and Table ************'

'TABLE read/write commands: STICK_WRITE STICK_READ'

VR read/write commands: STICK_WRITEVR STICK_READVR

elseif MODBUS_BIT( 40 ) = 1 then 'Perform operations on the table or VR'

MODBUS_BIT(40)=0

STICK_WRITE(10,0,5,1) ' Outputs the table to a USB drive, taking five elements starting from table ( 0 ).

print "table output to USB drive"

elseif MODBUS_BIT( 41 )= 1 then

MODBUS_BIT( 41 ) = 0

STICK_READ( 10,0,1 ) ' Output the data from the USB drive to the starting address of table(0)

print "USB drive output to table"

'************USB flash drive data read/write************'

elseif MODBUS_BIT( 50 )= 1 then

MODBUS_BIT( 50 ) = 0

U_WRITE 1 ,u,uu 'Writes data to the USB drive, performs operations on variables and arrays.

print "Data written to USB drive"

elseif MODBUS_BIT(51)=1 then

MODBUS_BIT(51)=0

U_READ 1,u,uu 'Read data from USB drive'

print "USB drive data read"

'************USB flash drive and FLASH data interaction************'

elseif MODBUS_BIT(60)=1 then

MODBUS_BIT(60)=0

FLASH_WRITE 3,a aa

The command `file"copy_from","sd3.bin"` copies the data from flash block 3 to the USB drive. Here, `sd_num` refers to the flash block number.

print "Data from the flash block has been copied to the USB drive"

elseif MODBUS_BIT( 61 )= 1 then

MODBUS_BIT( 61 ) = 0

file "copy_to","sd1.bin" 'Read data from sd1 and write it to flash block 1'

print "USB drive data written to flash"

flash_read 1,a,aa

print *aa

'************Reading USB drive file contents************'

elseif MODBUS_BIT( 11 )= 1 then

MODBUS_BIT( 11 ) = 0

FILE " LOAD_BYTE ", " 00.txt ", 200,10,0 'Reads text file data from the USB drive and saves it to the 10 addresses starting with table200.

print "Reading a txt file from a USB drive"

endif

endif

end sub

HMI configuration interface:

If there is no touchscreen, open the root directory of the ZDevelop programming software, find the screen folder, open the xplcterm application inside, and connect it to the controller to perform touchscreen simulation.

That concludes our sharing on the use of the USB flash drive interface for the Zhengdong Technology motion controller. For more exciting content, please follow our official WeChat account.

This article was originally created by Zheng Motion Assistant. We welcome everyone to reprint it for mutual learning and to improve China's intelligent manufacturing capabilities. Copyright belongs to Zheng Motion Technology. Please indicate the source if you reprint this article.

Read next

CATDOLL 115CM Nanako TPE (Customer Photos 2)

Height: 115cm Weight: 19.5kg Shoulder Width: 29cm Bust/Waist/Hip: 57/53/64cm Oral Depth: 3-5cm Vaginal Depth: 3-15cm An...

Articles 2026-02-22