j0h

Download PLC Instructions

j0h
Feb 24th, 2026
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Latex 4.50 KB | None | 0 0
  1. \documentclass[]{article}
  2.  
  3. %opening
  4. \title{Maintenance Protocol download notes}
  5. \author{System Controls Group}
  6.  
  7. \begin{document}
  8.  
  9. \maketitle
  10.  
  11. \section*{Summary of Successful PLC Program Download Implementation}
  12.  
  13. \subsection*{Overview}
  14.  
  15. This work established a verified method for downloading a compiled \texttt{.zld} user program into an IDEC FC6A PLC using the Maintenance Protocol over a USB CDC serial interface. The implementation was validated against packet captures and confirmed through execution on physical hardware.
  16.  
  17. The objective was to reliably transfer program memory, ensure integrity via checksum validation, and return the PLC to RUN mode.
  18.  
  19. \subsection*{Protocol Layers Identified}
  20.  
  21. Two related but behaviorally distinct protocol modes were identified:
  22.  
  23. \subsubsection*{Maintenance Protocol (Documented)}
  24.  
  25. The Maintenance Protocol, described in \texttt{fc4a\_protocol\_im.pdf}, is used for general-purpose commands such as:
  26.  
  27. \begin{itemize}
  28.     \item Writing individual bits (e.g., \texttt{M8000})
  29.     \item Reading PLC status (\texttt{RS})
  30. \end{itemize}
  31.  
  32. Frame format:
  33.  
  34. \[
  35. \texttt{ENQ (0x05) + ASCII body + BCC + CR}
  36. \]
  37.  
  38. Reply format:
  39.  
  40. \[
  41. \texttt{ACK (0x06) or NAK (0x15) + ASCII body + BCC + CR}
  42. \]
  43.  
  44. \subsubsection*{USB Download Dialect (Observed)}
  45.  
  46. Packet captures from Q3Download revealed a specialized download sequence used for program transfer. Although framing is structurally similar to Maintenance Protocol, behavioral differences exist in sequencing and data handling.
  47.  
  48. Download commands include:
  49.  
  50. \begin{itemize}
  51.     \item \texttt{Ri} (initialization)
  52.     \item \texttt{WPn} (segment declaration)
  53.     \item Hex-encoded data blocks
  54.     \item \texttt{W;n} (final segment declaration)
  55.     \item \texttt{Ru} (status polling / finalize)
  56. \end{itemize}
  57.  
  58. \subsection*{Checksum (BCC) Rule Variations}
  59.  
  60. Correct interpretation of the BCC (Block Check Character) was critical.
  61.  
  62. \subsubsection*{Maintenance Request BCC}
  63.  
  64. Maintenance requests exhibited two possible checksum modes:
  65.  
  66. \begin{itemize}
  67.     \item XOR over ASCII body only
  68.     \item XOR over ENQ + ASCII body
  69. \end{itemize}
  70.  
  71. The correct mode was determined dynamically by detecting NAK responses (error code \texttt{10}) and retrying with the alternate rule.
  72.  
  73. \subsubsection*{PLC Reply BCC}
  74.  
  75. For all observed PLC replies (both maintenance and download dialect):
  76.  
  77. \[
  78. \textbf{BCC = XOR(start byte + ASCII body)}
  79. \]
  80.  
  81. The start byte (ACK or NAK) must be included in the XOR calculation.
  82.  
  83. Failure to include the start byte caused false BCC mismatch errors during early testing.
  84.  
  85. \subsection*{NAK Interpretation}
  86.  
  87. NAK frames (start byte 0x15) return structured error bodies.
  88.  
  89. Example:
  90.  
  91. \[
  92. \texttt{01010}
  93. \]
  94.  
  95. The final two digits represent communication error codes. Code \texttt{10} indicates a data format or checksum mismatch.
  96.  
  97. NAK responses were essential for diagnosing:
  98.  
  99. \begin{itemize}
  100.     \item Incorrect BCC calculation
  101.     \item Incorrect command format
  102.     \item Missing required sequence steps
  103. \end{itemize}
  104.  
  105. \subsection*{Verified Download Sequence}
  106.  
  107. Successful program transfer required the following ordered procedure:
  108.  
  109. \begin{enumerate}
  110.     \item Stop PLC execution (\texttt{M8000 = 0})
  111.     \item Read status (\texttt{RS}) for verification
  112.     \item Send \texttt{Ri} initialization command
  113.     \item Send \texttt{WPn} with segment 1 length
  114.     \item Transmit hex-encoded data blocks (736 bytes each)
  115.     \item Poll using \texttt{Ru} until ready
  116.     \item Send \texttt{W;n} for final segment
  117.     \item Transmit final segment (340 bytes)
  118.     \item Final \texttt{Ru}
  119.     \item Restart PLC (\texttt{M8000 = 1})
  120. \end{enumerate}
  121.  
  122. \subsection*{Program Data Observations}
  123.  
  124. \begin{itemize}
  125.     \item The first 72 bytes of the \texttt{.zld} file represent container/header data and are not transmitted.
  126.     \item PLC instructions are 2-byte words.
  127.     \item Full transfer blocks are 736 bytes (0x2E0).
  128.     \item Final segment size observed: 340 bytes (0x0154).
  129. \end{itemize}
  130.  
  131. \subsection*{Conclusion}
  132.  
  133. Successful implementation required:
  134.  
  135. \begin{itemize}
  136.     \item Distinguishing Maintenance Protocol behavior from download dialect behavior.
  137.     \item Implementing correct BCC rules for both request and reply directions.
  138.     \item Using NAK error codes to guide protocol correction.
  139.     \item Reproducing the exact sequencing observed in packet captures.
  140. \end{itemize}
  141.  
  142. The system now reliably writes a ZLD user program into PLC memory and restores operational state. This establishes a validated foundation for formal documentation and future automation.
  143.  
  144.  
  145.  
  146.  
  147. \end{document}
  148.  
Advertisement
Add Comment
Please, Sign In to add comment