Welcome to our Motion Control Quick Start (5): How to Achieve IO Input & Output for Motion Controller.
As we all know, IO input and output are basic operations for motion control, and they are used usually.
Today let’s see how to operate input and output IO for Zmotion motion controller.
1. Material Preparations
(1) One computer with ZDevelop3.01 or above installed.
(2) One ZMC306X controller and one ZMC432 controller.
(3) One 24V DC power supply.
(4) Several bus drives + motors (or stepper drives + motors).
(5) A number of controller wiring terminals.
(6) Several network cables.
(7) A number of connecting wires, in addition, IO equipment, expansion module, touch screens, etc. can be selected according to requirements.
2. Motion Controller Introduction
(1) Controller Wiring Configuration Reference
(2) Controller ZMC306X Controller Interface
Basic hardware information of ZMC306X or ZMC432 (motion controller) can be checked through the hardware manual or the programming software (ZDevelop), for ZDevelop method, it needs to build the connection with controller firstly, then enter “?*max” in the online command bar.
Some basic parameters are shown below according to controller ZMC306X hardware manual.
(3) Check Controller ZMC306X Hardware Information
Enter “?*max” in online command bar to print results:
max_axis:12 the maximum number of axes for all axes
max_motor:6 the maximum number of controllable motor axes
max_movebuff:128 the maximum motion buffer for each axis or axis group
max_in:30,528 the number of IN inputs that comes with the controller, the maximum number of IN inputs supported
max_out: 18,528 the number of OUT outputs that the controller comes with, the maximum number of OUT outputs supported
max_ain: 2,128 the controller has its own number of analog inputs, and the maximum number of analog inputs supported
max_aout: 2,64 the controller has its own analog output number, and the maximum number of analog outputs supported
max_pwm:2 the number pf PWM outputs
max_slot:0 the number of buses
max_comport:3 the number of serial ports
max_ethport:3 the number of network port communication connections with PC and API functions
max_ethcustom:2 the number of connections for custom network port communication
max_ethiport:1 network port communication connection for Zmotion motion controller interconnection
max_flashnum: 1000 the number of FLASH blocks
max_flashsize:20480 the size of each FLASH space
max_nand:265551872 NandFlash stores the total amount of space
max_nandremain: 267911168 NandFlash storage remaining available quantity space
max_pswitch:16 the maximum number of software position comparison outputs
max_file:30 the maximum number of files supported by the system
max_3file:1 the maximum number of three files supported by the system
max_task:12 the number of tasks
max_timer:128 the number of timers
max_loopnest:8 the times of internal loops or selections
max_callstack:7 the number of stack layers called by the subroutine
max_local of one sub:16 the number of local variables of SUB
max_vr: 1024 VR register space number
max_table:300000 the number of TABLE array spaces
max_modbusbit: 4096 MODBUS_BIT bit register space size
max_modbusreg:4096 MODBUS_REG word register space size
max_var: 4096 the maximum number of variables supported (including global variables and file variables)
max_array: 1024 the maximum number of supported arrays (including global arrays and file arrays)
max_arrayspace:640000 the total space size of all arrays
max_sub:1500 supports the maximum number of SUB subroutines
max_edgescan: 1024 the maximum supported number of rising/falling edge scans
max_lablelength:17 the maximum length of custom characters such as arrays and variables
max_hmi:1,x:1024y:600 supports 1 remote HMI, the maximum size is 1024*600
function support: Coder Cam MultiMove Circ Merge Frame: supported motion control functions.
(4) Controller ZMC306X State
Use ZDevelop software to connect to controller, in the menu bar, click “Controller” – “State the Controller” to view controller basic information.
VirtualAxises: the maximum number of supported virtual axes
RealAxises: the maximum number of supported motor axes
Tasks: the maximum number of tasks
Files/3Files: the maximum number of files/three files
Modbus0x Bits: Modbus bit register user available space size
Modbus4x Regs: Modbus word register user available space size
VR Regs: VR register user available space size
TABLE Regs: TABLE array user available space size
RomSize: Rom capacity
FlashSize: Flash capacity
SoftType: software model
SoftVersion: system software version + firmware version
IpAddress: controller IP address
HardVersion: hardware version
ControllerID: the unique ID of the controller
Axis features list: list of axis types
ZCanNodes: view the local information of the controller and the information of the expansion modules connected to the CAN bus.
CommunicationInfo: view CAN information and serial channel RS232/RS485/RS422 information.
The controller with EtherCAT interface can view the SlotNodes in the controller status, and the information of all devices connected to the bus slot are displayed.
(5) ZMC306X Digital Input
The general digital input port can be connected to NPN type. And the role of the optocoupler and the filter is to prevent the interference signal from entering the controller through the signal line and the power line.
Special function of the input port: IN0-1 port has the functions of latch input A and latch input B at the same time, and the hardware lag time of the input signal allowed by the latch high-speed input port is 1us. The rest are ordinary input ports, and the hardware delay time of the input signal is allowed to be about 50us, also the filter parameters can be set to increase the filter time.
Special signal definition: the digital input port has no special definition on the hardware, they are all general. For special signals, such as, origin, position limit, alarm quick jog, forward JOG, reverse JOG, feed hold and other special signals are all set through software instructions.
DATUM_IN, REV_IN, FWD_IN, ALM_IN, FAST_JOG, FWD_JOG, REV_JOG, FHOLD_IN and other commands can be used for configuration.
INVERT_IN: inversion configuration of the input signal.
Input inversion:
INVERT_IN(8,ON) 'invert the input
Input filter:
INFILTER=5 'the larger the value, the longer the filtering time, 2-9, default 2
Reading of the input port:
IN(0) reads IN0 data ‘IN(0,7) read IN0~IN7 data at one time
Read rising edge/falling edge status:
Method 1:
SCAN_EVENT(IN(0)) > 0 rising edge
SCAN_EVENT(IN(0)) < 0 Falling edge
Method 2:
After IN_SCAN(0,23), IN_EVENT(0) > 0 rising edge
After IN_SCAN(0,23), IN_EVENT(0) < 0 falling edge
Diagnosis of input signal: ZDevelop->View->In
Run the following program to obtain the state of the input port as shown in the figure.
Grey means there is no input, but green means corresponding input port has input. For special signals, there is the indication in right window. And you can select which IOs are shown through “IO Select”.
(6) Controller ZMC306X Digital Outputs
The general digital output port can be connected to NPN type. And the role of the optocoupler and the filter is to prevent the interference signal from entering the controller through the signal line and the power line.
The maximum single output current of the general output port is 300mA, but the maximum output current of the axis terminal is 50mA.
The command for general output is OP.
Special function of the output port: OUT0~1 supports PWM output, and it is a general output when the PWM function is turned off. The PWM high-speed output port allows an output signal frequency of 1M, and the rest are ordinary output ports, the allowable output frequency is about 10K.
Use the PWM_DUTY and PWM_FREQ instructions to set the duty cycle and frequency respectively.
PWM_DUTY(0)=0.4 '0.4 duty cycle PWM_FREQ(0)=1000 '1k frequency.
PWM_DUTY(1)=0.5 '0.5 duty cycle PWM_FREQ(1)=1000000 '1M frequency.
Diagnosis of output signals: ZDevelop->View->Op
Run the following program to get the status of the output port as shown in the figure.
OP(0, 15, 0) ‘output 0-15 all are off
OP(0, on) ‘output 0 is on
OP(4, 7, $f) ‘set as bit, bit4-bit7 are all on
OP(12, 15, $c) ‘bit12-bit13 are off, bit14-bit15 are on
(7) Digital Input and Output Expansion
When the number of digital inputs and outputs is not enough, an expansion module can be connected to expand the inputs and outputs, and CAN bus and EtherCAT bus can be used to connect the expansion module.
Since ZMC306X only includes CAN interface, it can only be expanded by CAN bus. It can expand up to 512 IN input ports and 512 OUT output ports. When the number of pulse axes is not enough, ZCAN expansion module is supported to expand the pulse axis. The wiring method is shown in the figure below.
Please note be sure to connect the EGND of the controller to the GND of the ZCAN IO, and connect a 120 ohm resistor between CANL and CANH.
(8) Controller ZMC306X Analog Input and Output
ZMC306X includes two AD analog inputs and two DA analog outputs, and the internal AD/DA uses an internal power supply.
The precision of the analog of the controller is 12 bits, the scale range is 0~4095, and the input and output voltage range is 0~10V.
When the number of analog inputs and outputs is not enough, an expansion module can be used to expand, and the analog can be expanded to 256 channels of AD and 128 channels of DA.
Relevant instructions:
Analog input: AIN ‘read AIN(0), AIN(1)
Analog output: AOUT ‘write AOUT(0), AOUT(1)
Diagnos is of AD/DA signal of ZMC306X: ZDevelop->View->AD/DA, monitor the voltage of each analog channel in real time.
3. Input and Output Examples
(1) Synchronization output in motion process
Output OP, DA and PWM synchronously in motion.
Relative instructions:
MOVE_OP: output OP in motion
MOVE_OP2: output OP one certain time in motion
MOVE_PWM: output PWM in motion
MOVE_AOUT: output analog in motion
(2) Data writing and reading (IN, OP, ADC, DAC, etc. of HMI)
IN(0)-IN(4095) correspond to MODBUS_BIT(10000)-MODBUS_BIT(14095), read only.
OP(0)-OP(4095) correspond to MODBUS_BIT(20000)-MODBUS_BIT(24095), read & write.
AIN(0)-AIN(255) correspond to MODBUS_REG(14000)-MODBUS_REG(14255), read only.
AOUT0)-AOUT(127) correspond to MODBUS_REG(13000)-MODBUS_REG(13127), read & write.
DPOS, MPOS and VPSPEED correspond to MODBUS_IEEE(10000)-MODBUS_IEEE(12198), read only.
(3) Position comparison output
Comparison output related instructions: software comparison output PSWITCH instruction, hardware comparison output HW_PSWITCH instruction (only supports pulse axis) and HW_PSWITCH2 instruction (supports both pulse axis and bus axis). when the motor position reaches the set position, operate a certain output port electric level.
Among them, some controllers of 4xx series and 3xx series support hardware comparison output, such as ZMC432, which contains 4 hardware comparison output channels, and each channel is independent (some models are not independent). The number of hardware comparison output channels is different according to different controller models. And the IO number of the output port corresponding to the special function generally starts from 0.
It can only be compared once in each system cycle, and the channel is independent. One system cycle supports multiple output ports to use hardware comparison output at the same time. If the channel is not independent, only one output port can be used in one system cycle. The system cycle can be checked through SERVO_PERIOD. The default is 1ms.
HW_PSWITCH2 and MOVE_OP exactly use the same hardware resources, so it is not recommended to use them on the same channel at the same time. If the channels are independent, they can be used on different channels at the same time.
(4) Precision output
Only controllers that support the hardware comparison output function can use the precise output function. Use the AXIS_ZSET command to set whether to enable the precise output. After opening, use the MOVE_OP command to take effect precise output. Also, please note that the output channel should select a channel that supports precise output. The number of channels supported by different controller models is different. Generally, special functions start from IO number 0.
Normal output operations need to wait for one controller cycle before execution. The precise output operation can respond within one pulse sent by the motor, which greatly improves the precision of the process. At the same time, the MOVEOP_DELAYcommand can be used to adjust the response time (advance or delay).
Generally, the precise output function can only be executed once in a controller cycle, and it needs to wait until the next cycle to enable it again. However, each precision output of the latest controller such as ZMC420SCAN is independent, and multiple ports can be used at the same time in one cycle. Whether it supports the simultaneous use of multiple precision outputs can be found in the output port description in the hardware manual.
(5) Controller example program (basic example program)
There are 5 modules for controller program:
Initialization Module: set sub program through axis parameters, IO initialize sub program.
Input Scan Module: press IN, stop relative program of inputs.
Set Sub Program through axis parameters: initialize axis parameters.
IO initializes sub program: initialize IO (OP, AOUT)
Press “on” for motion task: when the button is pressed, call to execute motion task 1.
ABOUT ZMOTION