This is a model answer for each chapter’s “❓ Confirmation Questions.” Try to solve it on your own first, and if you get stuck, try following the exercises in the chapter again. For problems that can be verified with code, we recommend checking directly with
lecture/code/'s tools.
01. Environment preparation
1. How many ports does an actual robot use for Modbus TCP, and why does it use 1502 in practice?
The actual device uses standard port 502. However, in Windows, privileged ports below 1024, such as 502, may require administrator privileges, so in practice, we use 1502 (1024 or higher), which does not have any permission issues. Don't forget to add --port 1502 to each command.
2. Why is the pymodbus version fixed to 3.6.9?
pymodbus' function signatures and import paths change significantly between major/minor versions (e.g. slave= vs unit=, server API changes). The teaching code was written and verified based on 3.6.9, so some calls may fail in other versions.
3. 300.000 mm is divided into Low=-27680 and High=4. Why is Low a negative number?
In 300000 = 4 × 65536 + 37856, the remaining 37856 exceeds the 16bit signed maximum value (32767). When expressed in signed 16bit, it becomes 37856 − 65536 = −27680 and the low word becomes a negative number. (For detailed principles, Appendix B)
02. I/O communication
1. How many RI/O-s input/output channels and which models cannot be used in a 6-axis robot? 6 inputs / 4 outputs (6I/4O). Not available on SCARA and Delta robots (no robot body end wiring). Alternatively, use DI/O or MI/O.
2. What is the function of $SI[1] and $SO[3] in FI/O basic mapping?
$SI[1] = Start (program start input), $SO[3] = Fault (Error/Fault output).
(Input $SI: Start/Hold/Stop/Enable/RSR14, Output $SO: Run/Held/Fault/Ready/ACK14)
3. When going from pick and place to P2, why do you use LIN instead of PTP and place P1 50mm above P2?
This is for precision Approach/Leave** perpendicular to the workpiece. LIN (linear interpolation) ensures a straight path to prevent side collisions and dragging, and via access point P1 (+50mm above P2), the gripper descends vertically from above to safely pick up the product. PTP does not guarantee a route, making it unsuitable for close proximity.
03. Ethernet TCP/IP
1. What IPs can communicate with when the robot IP is 192.168.1.10? (192.168.1.50 / 192.168.2.50 / 10.0.1.10 / 192.168.1.200)
Correct answer: 192.168.1.50, 192.168.1.200. The first 3 octets 192.168.1 must match for the same IP domain. For 192.168.2.50, the third octet is different, and for 10.0.1.10, the first octet is different, so communication is not possible.
2. HRSS code fill in the blanks (COPEN(___, HANDLE) / empty buffer / first argument of RS-232)
① ETH (TCP/IP) ② CCLEAR (buffer clear) ③ SER (RS-232).
3. When I send the value 123, what is the actual string the other party receives and why?
{123}. This is because when transmitting the packet, the braces at-the-beginning/end { } are automatically attached and the packet is delivered in the form of {data}.
04. RS-232 serial communication
1. What does the robot TX connect to in RS-232 direct wiring, and which signal lines should be connected together? Connect the robot transmitting pin (TX) to the host's receiving pin (RX), and the robot RX to the host TX (interlaced cross/cross wiring, twisted wires in the manual). Then connect both sides Common GND together.
2. What is the first argument of COPEN in TCP/IP-and RS-232, and are the CWRITE/CREAD·packet formats the same?
The first argument is TCP/IP=ETH, RS-232=SER. The CWRITE/CREAD command and packet format ({ }, , distinction, non-format=ASCII decimal) are same. That is, only the physical layer and the first argument of COPEN are different.
3. Does it communicate with baud 9600 on one side and 19200 on the other side?
Not possible. Unlike Ethernet, RS-232 does not have speed auto-negotiation, so if the baud is different, the bit timing is misaligned, resulting in broken characters or an empty value (b''). The baud rates on both sides must be set same (+data bit, parity, and stop bit, default 8N1).
05. MODBUS Basics
1. Compare RTU vs TCP with (a) physical layer and (b) error verification, and what is HIWIN's RTU interface? (a) Physical layer — RTU is serial (HIWIN is RS485), TCP is Ethernet. (b) Error verification — For RTU, CRC is required at the end of data, and for TCP, the lower TCP layer verifies integrity, so Modbus CRC is omitted. The RTU of HIWIN robot uses RS485.
2. What is the Function Code for the following task? (SO read / Hold single write / Coil single ON / Input register read) 02 (Read Discrete Input) / 06 (Write Single Holding) / 05 (Write Single Coil) / 04 (Read Input Register).
3. Why does writing to the input register fail, and which two types of registers can the master write to? Input Register is read-only (R), and it is an area where the slave fills in measurement and status values, so the master cannot overwrite it (read-only does not have a write function code itself). The R/W registers that the master can write to are Coil(05/15) and Holding Register(06/16).
06. MODBUS SERVER (Robot=Slave)
1. What register area does the master use when command/monitor the robot? Command (write) is written to the R/W area Coil (SI/DO bit) and Holding Register (command number, parameter, trigger). Monitor (Read) reads read-only Discrete Input (SO/DI status) and Input Register (operation status, current position, command status).
2. What are the 5 steps of executing a single command and what happens if HR200 is not reset to 0? ① HR201←Command number ② HR202~←Parameter ③ HR200←1 (Execute) ④ Check IR524 is 2(Run)→1(Idle)·IR200=1(Success) ⑤ HR200←0(Reset). If you don't reset it at the end, the trigger will remain at 1 and the robot will not receive the next command and the cycle will be locked.
3. Why are Low/High words and & 0xFFFF needed when sending Z=+90.000mm to LIN?
90.000×1000 = 90000 → split_word(90000) = (24464, 1). Since Modbus writing only accepts unsigned 16 bits, each word must be encoded as & 0xFFFF. The value of +90mm does not change because both words are positive, but if the high word is negative, for example −90.000mm = (40146, −2), −2 & 0xFFFF = 65534 conversion is definitely necessary (if not present, struct.error). Gyoan's RobotMaster.write_holding processes this automatically.
07. MODBUS CLIENT (Robot = Master)
1. What area/command does In-command/surveillance use when the robot is the Master Client? How does it compare to Chapter 05?
Command is written to the R/W area Coil(MBC_WRITE_COIL)·Holding Register(MBC_WRITE_HOLDING) (e.g. gripper HR1600=1 "Open"). Monitoring reads the R area Input Register(MBC_READ_INPUT)·Discrete Input(MBC_READ_DINPUT). Chapter 05 is the receiving (Server) side of the robot, and Chapter 06 is the sending (Client) side of the robot to the other device — the same four types of registers are written in the opposite direction.
2. Difference between 'W' and 'D', what if HR204=24464/HR205=1 is read as 'D'?
'W'(Word)=1 16bit as is. 'D'(Double Word)=Combining two consecutive words into 32 bits Low word first, High word last. High×65536 + Low = 1×65536 + 24464 = 90000 (90.000° at 0.001 scale). 'D' is used for coordinates and angles exceeding 16 bits.
3. How to send real 10.5 to Modbus?
(a) Modbus registers only carry 16-bit integers, so floating point numbers cannot be entered as is. (b) Encode it as IEEE754_ENCODE(10.5)=1093140480 (32-bit integer) and transmit it as 'D', and the recipient restores it as IEEE754_DECODE(1093140480)=10.5. (c) If the word order of the other device is reversed, compensate by exchanging the upper and lower words with SWAP_WORD.
08. Monitoring & Debugging
1. What are two things to check when you don't see Modbus packets in Wireshark? (a) It may be capturing a general LAN card → Change the interface to "Adapter for loopback traffic" (if Npcap is not installed, reinstall it). (b) Non-standard port 1502 is not automatically interpreted → Right-click on the packet and select **Decode As… ** → If port 1502 is designated as Modbus/TCP, the Protocol column changes to via-Modbus/TCP.
2. How to decrypt response 04 04 00 5a 00 00?
(a) FC 04h = Read Input Registers. (b) The second 04 is the number of data bytes = number × 2 = 2 × 2 = 4. (c) 00 5a=0x005A=90, 00 00=0. (d) If you read 3 words, the number of bytes is 3×2 = 6.
3. From HR 201, what is the request/response using 111/222/333?
(a) Since there are more than two values, 10h(Write Multiple Registers). (b) 10 00 C9 00 03 06 00 6F 00 DE 01 4D (address 0x00C9=201, number 3, byte number 6, 111/222/333). (c) Response 10 00 C9 00 03 — Write response only echoes the start address + number and does not return data (bandwidth saving).
09. Comprehensive practice
1. What is the transformation that goes through before sending the coordinates given by the vision (e.g. X=123.45mm) to the robot as LIN?
ASCII string {123.45,...} → Parse and low/high word as mistake 123.45 → round(123.45×1000)=123450 → split_word(123450) → Load in Holding Register → Execute command cycle. (Negative coordinates are also automatically encoded by write_holding)
2. Why can’t gripper operation completion be judged only by IR[769]==2?
After the close action, IR769 remains at 2 (Pos). If you poll immediately on the next open action, the condition will pass before the gripper even moves. Therefore, IR[769]==2 and HR[1606]==0 (automatic reset of execution flag) must be checked together. It's a "state residue" trap, like the robot's HR[200]=0 reset.
3. What needs to be initialized to complete one cycle and process the next part?
The robot must reset the trigger with HR[200]=0 after each command to receive the next command. The gripper verifies that HR[1606] has automatically returned to 0. Parameters such as coordinates and direction can be overwritten with new values.
Appendix B. Transformation Exercise Solutions
| # | problem | hand calculation | Correct answer |
|---|---|---|---|
| 1 | raw integer of combine_word(0, 2) |
65536×2 + 0 | 131072 |
| 2 | Angle of Low=24464, High=1 (×0.001) | (65536+24464)=90000 ×0.001 | 90.000° |
| 3 | +200.000mm(raw 200000) → Low/High | 200000 = 3×65536 + 3392 | Low=3392, High=3 |
| 4 | −150.000mm(raw −150000) → Low/High | −150000 = −3×65536 + 46608, 46608−65536 | Low=−18928, High=−3 |
| 5 | 3.14 IEEE754 Encoding/Decoding |
single precision | encode=1078523331, decode≈3.1400001 (single precision error normal) |
Code verification:
python word_tools.py 200(No. 3),python word_tools.py -150(No. 4),python word_tools.py 3.14(No. 5)
← To tutorial index