-
Notifications
You must be signed in to change notification settings - Fork 3
/
help
executable file
·261 lines (178 loc) · 6.69 KB
/
help
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
The default UI for version 2.0 onwards is command line based.
This is just a std prompt where the PLC's internal state in YAML format is monitored, while PLC commands can be issued.
Supported commands:
START
start plc loop
STOP
stop plc loop
HELP
display help message
QUIT
close the UI
EDIT <sequence><index><key: value>
Edit a configuration for any input, output or other sequence block. The key: value pair can be any of the parameters in the configuration of the specific block.
FORCE<sequence><index><value>
This will force a value on a sequence block for debugging purposes.
UNFORCE<sequence><index>
Reverts the FORCE command.
LOAD<filename>
Load configuration in yml file
SAVE<filename>
Save current configuration, if filename given save as yml file otherwise default config.yml
Program Structure
The program file consists of two sections: init section, and PLC task section,
separated by the keywords "LD" or "IL".
Initialization
In the init section, you can write the initialization state of the plc, in the
format <VARIABLE> <INDEX> <VALUE> separated by tabs.
Supported variables are:
Text variables
Up to 16 character comments.
I: comment associated with input[index]
Q: comment associated with output[index]
M: comment associated with memory register[index]
T: comment associated with timer register[index]
S: comment associated with timer register[index]
Integer variables
Non negative numbers.
MEMORY: initial value of register[index]
TIME: number of time cycles timer[index] takes to increase its value by 1.
PRESET: preset value of timer[index]
BLINK: number of time cycles blinker[index] takes to change state.
Unique value variables:
Boolean variables which, if they are not set, are presumed to work with their
default values. So it only makes sense to initialize them in their non-default
states.
COUNT: setting this to DOWN means register[index] works as an downcounter.
COUNTER:setting this to OFF means register[index] is just a boolean variable.
DELAY: setting this to ON means timer[index] is a T-ON counter. default is T-OFF
LD task
Everything after the keyword "LD", is supposed to be in Ladder diagram format.
The version of LD PLC-EMU supports, consists of the following operators and
operands, in a diagram of maximum 1024 characters wide, and random lines long.
Operators
These are the accepted symbols that can exist along with the operands.
'-' propagates a boolean state horizontally, from left to right.
Thus, it works as a logical "AND".
'+' changes line and can join states of up to 3 different lines,
like a logical "OR" .
'|' propagates a state vertically, both ways between aligned "+" nodes.
'!' negates the state of the following operand like a logical "NOT"
'(' open contact. this propagates a state directly to an output. the following operand must be an output.
')' negate contact. this propagates the opposite of a state to an output. the following operand must be an output.
'[' set coil. if this is ON, thestate of an output is set. the following operand must be an output.
']' reset coil. if this is ON, thestate of an output is reset. the following operand must be an output.
';' end of line. anything after that is considered "comments".
Blank characters interrupt lines, so be careful.
Input operands
These can appear anywhere in a line before a '(', followed by a valid
non negative index. Valid values of indexes are dependant on the operand and
the configuration. This means, that if you have 16 timers and 64 inputs, you
can write t14 and i62, but not t45 or i567.
In every cycle, their values are polled and propagated to the diagram.
Accepted symbols (case sensitive) are:
'i' digital input state
'q' digital output state
'r' rising edge of digital input
'f' falling edge of digital input
'm' pulse state of counter
't' output of timer
'b' output of blinker
'c' true, if serial input byte equals following index
Output operands
These symbols must follow operator '(' and be followed by a valid index.
Each output operand should appear only once.
'Q' digital output
'M' pulse of counter
'T' timer
'W' write following number to serial output.
Example of a valid Program file:
I 1 My button
I 3 My other button
Q 1 My led
Q 2 My other led
M 1 My bool variable
M 4 My up-counter
T 1 My on-timer
S 3 My blinker
MEMORY 4 654
COUNT 4 DOWN
COUNTER 1 OFF
TIME 1 500
PRESET 1 20
DELAY 1 ON
BLINK 3 40
LD
r1---------!m1----------(Q0 ;rising input 1 and not pulse of counter 1 contacts
;output 1
t1---+
b3---+---i2-----+ ;timer 1 or blinker 3 or falling edge of input
| | ;3 and input 2
| | ;sets pulse of counter 4.
f3---+ +--------[M4
c255------------+--------(T1 ;command 255 starts timer 1 and sets output 2
+--------[Q1
b1-----------+-----------]T1 ;blinker 1 stops timer 1,
| ;resets pulse of counter 4 and output 1
| ;and writes byte 99 to serial output
+-----------]Q1
+-----------]M4
+-----------(W99
IL task
Alternatively, you can use the keyword "IL" (or F5 in the editor window)
to define a IEC61131-3 compatible Instruction List program.
Currently, subroutines are not implemented.
Just like standard Instruction List, all instructions store their result to an
internal Accumulator register, while "ST" stores the Accumulator's value to its operand.
A line of an IL program, shall follow the format:
[label:]<operator>[<modifier>[%<operand><byte>[/<bit>]]|<label>][;comment]
Supported Operators are:
) close parenthesis (pop instruction from stack)
S set output
R reset output
AND
OR
XOR
LD load
ST store
ADD
SUB subtract
MUL multiply
DIV divide
GT >
GE >=
NE <>
EQ ==
LE <=
LT <
JMP jump to label
Modifier symbols recognized are:
( open parenthesis (push instruction to stack)
! negate
? conditional
Operands are the same as in LD, with the difference that it is assumed that
they are Words (unsigned Integers), unless noted otherwise with the symbol '/'.
As defined in the IEC standard, each instruction supports its own set of data types
and modifiers, according to the following scheme:
Instruction Modifiers Data Types
) N/A N/A
S N/A BOOL
R N/A BOOL
AND !,( BOOL/WORD
OR !,( BOOL/WORD
XOR !,( BOOL/WORD
LD ! BOOL/WORD
ST ! BOOL/WORD
ADD ( BOOL/WORD
SUB ( BOOL/WORD
MUL ( BOOL/WORD
DIV ( BOOL/WORD
GT ( BOOL/WORD
GE ( BOOL/WORD
NE ( BOOL/WORD
EQ ( BOOL/WORD
LE ( BOOL/WORD
LT ( BOOL/WORD
JMP ? CHARACTER STRING
You can write a text file with the initialization and task program externally
and then load it into PLC-EMU, or use the curses interface to edit and save it.