02. I/O Communication
I/O communication toggles a single wire ON/OFF so the robot and a partner device (PLC·machine·sensor) exchange signals. The robot turns an output ($DO) on, the partner reads it as input; the partner turns a response on, the robot reads it as input ($DI). This handshake is the foundation of all automation. We classify HIWIN's five I/O types and reproduce one pick-and-place grip/ungrip handshake as a pure-Python state machine.
What you'll learn
- 1Distinguish HIWIN's five I/O types and know channel counts·variables
- 2Design a handshake with $DO[n]=TRUE output and WAIT FOR $DI[n]==TRUE
- 3Read the FI/O default mapping (Start/Hold/Stop/Enable, Run/Held/Fault/Ready)
- 4Reproduce the two pick-and-place handshakes (grip·ungrip) as a Python state machine
Introduction
"One wire = one signal." The robot turns $DO on, the partner reads it; the partner turns a response on, the robot reads $DI. This handshake is the core. With no wiring or ports, you practice the logic on one PC.
Key concepts
1) The five I/O types
| Type | Vars | Channels (6-axis) | Notes |
|---|---|---|---|
| DI/O digital | $DI/$DO | 24I/24O | general signals to PLC·machine·sensor |
| SI/O fieldbus | $SI/$SO | 128I/128O | CC-Link/Profinet/EtherNet/IP option card |
| FI/O functional | (fixed) | 8I/8O | Start·Hold·Stop·Enable·RSR |
| RI/O robot | $RI/$RO | 6I/4O | end-of-arm wiring. not on SCARA·Delta |
| MI/O module | $MI/$MO | 32I/32O | group several I/O for monitoring |
Channel counts vary by model. The numbers above are for 6-axis articulated robots (e.g. RA605); always check your robot·controller manual.
2) I/O commands and FI/O mapping
Output is `$DO[n]=TRUE/FALSE`; input wait is `WAIT FOR $DI[n]==TRUE` (a blocking command that stops on that line until true). Functional I/O has fixed pin functions: $SI[1]=Start·[2]=Hold·[3]=Stop·[4]=Enable·[5~8]=RSR / $SO[1]=Run·[2]=Held·[3]=Fault·[4]=Ready·[5~8]=ACK.
3) CN6 wiring (NPN)
Digital I/O exits the controller's CN6 port to a terminal block toward the PLC·sensor. Both input and output are NPN (sink) — ON when the signal line is pulled to 0V (GND). Mixing with PNP devices won't work, so match the wiring style.
Core example
Physical I/O can't be created on a PC, so we reproduce the robot↔PLC signal logic as a pure-Python state machine (signals mimicked with a dict).
def handshake(do_pin, do_value, di_pin):
robot_set_do(do_pin, do_value) # $DO[n]=TRUE/FALSE
plc_respond(do_pin, di_pin) # later, $DI[n]=TRUE response
robot_wait_for(di_pin) # WAIT FOR $DI[n]==TRUE
handshake(do_pin=6, do_value=True, di_pin=1) # GRIP → $DI[1] grip done
handshake(do_pin=6, do_value=False, di_pin=4) # UNGRIP → $DI[4] ungrip doneOn real hardware (HRSS), these two handshakes are part of a pick-and-place program between PTP/LIN moves. P1/P3 are +50mm approach points above P2/P4 so the tool descends vertically onto the workpiece, avoiding collisions.
Common mistakes
Q. WAIT FOR passes immediately instead of waiting.
A. The input is stuck ON (often reversed NPN/PNP wiring). Set CN6 wiring to NPN (sink); in code, reset that $DI bit to False before the next handshake.
Q. I turn $DO on but the partner doesn't react.
A. Wrong output channel/number or no external 24V applied. Recheck the channel number and terminal-block power.
Q. I get an error that $RI/$RO or $SI/$SO doesn't exist.
A. RI/O isn't supported on SCARA·Delta — use DI/O·MI/O. SI/O needs a Fieldbus option card installed.
Summary
- Learned the five I/O types' variables·channels·commands
- $DO output → partner response → WAIT FOR $DI handshake is the base pattern of all automation
- FI/O has fixed pin functions (Start/Hold/Stop/Enable, Run/Held/Fault/Ready)
- From the Modbus lessons on, these signals are exchanged as coil/register bits in software
Exercises
- Run the pick-and-place cycle and confirm GRIP/UNGRIP handshakes run in order
- Remove the $DI reset to reproduce WAIT FOR passing immediately, and explain why
- From the FI/O table, write down the pin numbers for Start/Enable/Ready
All lecture materials and example code (with simulators, homework, and answers) are openly available on GitHub.
View on GitHub ↗