Specifications

App-10
Appendix 3 Recreating Ladder Programs
Appendix 3.2 Example of creating a structured program
Appendix 3.2 Example of creating a structured program
This section shows an example of creating a sequence program same as the program created in
GX Developer using GX Works2.
The following examples explain the method for creating a structured program same as the data
receive program for a Q-compatible serial communication module, using the structured ladder/
FBD and ST languages.
The following shows the original program.
(1) Replacing devices with labels
Replace devices of the original program with labels.
Replace input/output devices with global labels. For devices such as internal relays, replace
them with local labels.
Table App. 3.2-1 Examples of replacement from devices to labels
Device Purpose
Label
Data type Label name
X3 CH1 reception data read request Bit CH1ReadRequest
X4 CH1 reception abnormal detection Bit CH1AbnormalDetection
D0
Control data
Reception channel
Word (unsigned)/16-bit
string [0] to [3]
ControlData
D1 Reception result
D2 Number of reception data
D3
Number of allowable reception
data
D10 to D109 Reception data
Word (unsigned)/16-bit
string [0] to [99]
ReceiveData
D110 to D209 Reception data storage area
Word (unsigned)/16-bit
string [0] to [99]
Data
M0 Data
reception
completion
flag
Completion flag
Bit [0] to [1] Completion
M1 Status flag at completion
M100 Abnormal completion flag Bit AbnormalCompletion
X100 Abnormal completion flag reset command Bit ResetAbnormalCompletion
Clear the reception result and receive data count
storage device to 0.
With normal completion, the receive data within the
allowable receive data count (user specified) is read
from the receive data storage area in the buffer memory.
Once the INPUT instruction is executed, the user
specified read completion signal (M0) turns ON for
1 scan.
The reading of receive data and switching of the
ON/OFF status are performed by the programmable
controller CPU.
The abnormal completion flag is reset by an external
command.
Specify the receive channel.
Specify the allowable receive data count.