ComfilePLC Product Concept
ComfilePLC is a SoftPLC that works on ComfilePi (There is no PC version or MCU version.)
Basically, it supports Rpi's GPIO, and supports Remote I/O that can be connected to i2c.
**
Then, We can have a new type of iot PLC that was not in the existing market is born.
PLC that allows online editing without going to the field
PLC that can be edited in the field without a laptop or PC
PLC that can be operated while viewing the NODE-RED Dashboard with a smartphone
CODESET
Ladder diagram convert to mnemonic and then to make a codeset.
The codeset will downloaded to PLC and saved in EEPROM.
PLC MCU reads and executes the codesets in eeprom in sequence.
Overview
Code(Hex) | Kind |
10~ | Parameter Constant value |
30~ | Math |
50~ | Output Coils |
60~ | Input |
80~ | Compare |
A0~ | Function |
C0~ | WORD/DWORD Direct Address |
F0~ | BOOL Direct Address |
Mnemonic | Code(Hex) | Explain |
STARTLD | 96(60) | Start Ladder |
LOAD | 97(61) | -! !- Normal Open |
LOADNOT | 98(62) | -!/!- Normal Close |
AND | 99(63) | -! !- |
ANDNOT | 100(64) | -!/!- |
OR | 101(65) | -! !- |
ORNOT | 102(66) | -!/!- |
ANDLOAD | 103(67) | |
ORLOAD | 104(68) | |
DF | 105(69) | Rising Edge |
DFN | 106(6A) | Falling Edge |
-|P|- Convert to LOAD(OR /AND), DF
-|N|- Convert to LOAD(OR /AND), DFN
Compare -| |-
Mnemonic | Code(Hex) |
LOAD= | 128(80) |
LOAD> | 129(81) |
LOAD< | 130(82) |
LOAD>= | 131(83) |
LOAD< = | 132(84) |
AND= | 133(85) |
AND> | 134(86) |
AND< | 135(87) |
AND>= | 136(88) |
AND< = | 137(89) |
OR= | 138(8A) |
OR> | 139(8B) |
OR< | 140(8C) |
OR>= | 141(8D) |
OR< = | 142(8E) |
Both expressions can be used
= D0 100 D0 = 100
---| |-- ---| |---
Compare instruction can't use —|/|— Symbol.
Output --( )
Mnemonic | Code(Hex) | Explain |
PUSH | 80(50) | |
READ | 81(51) | |
POP | 82(52) | |
OUT | 83(53) | -( ) |
SETOUT | 84(54) | -(S) |
RESETOUT | 85(55) | -(R) |
Funtions --[ ]
Bit : Bit Direct Address (X,Y,M,K,F,C,T)
Reg : Direct Address (D,DD,KD,KDD,C,T,KC,KT)
Const/Reg : Constant or Direct address
Label : Real address of EEPROM(codeset)
Code | Instruction | Parameter | Description | Example | Example Description |
160(A0) | FLASHER | Bit Const/Reg | Flash Output | FLASHER Y0 100 | Y0 on 100ms and off 100ms forever |
161(A1) | DEBOUNCE | Bit Const/Reg | Debounce Output | DEBOUNCE Y0 100 | during 100mS input ON then Y0 is ON |
162(A2) | TOGGLE | Bit | Reverse Output | TOGGLE Y0 | If Y0 is Off then make On |
163(A3) | CTU | C Const/Reg | Up Counter | CTU C0 100 | |
164(A4) | CTD | C Const/Reg | Down Counter | CTD C0 100 | |
165(A5) | CTUD | C Const/Reg Bit | Up & Down Counter | CTUD C0 100 X1 | X1 is Down Counter Input |
166(A6) | TON | T Const/Reg | On Timer | TON T0 100 |
167(A7) | TOFF | T Const/Reg | Off Timer | TOFF T0 100 |
168(A8) | TMON | T Const/Reg | Momentary Timer | TMON T0 100 |
169(A9) | INC | Reg | INC D0 | D0+1 → D0 |
170(AA) | DEC | Reg | DEC D0 | D0-1 → D0 |
171(AB) | MOV | Const/Reg Reg | MOV D0 D8 | D0 → D8 |
172(AC) | FOR | Const/Reg Reg | FOR 10 D0 | Repeat 10 time, D0 store current number |
173(AD) | NEXT | | Convert to NEXT label | |
174(AE) | CALL | Label | | |
175(AF) | RETURN | | | |
176(B0) | JUMP | Label | | |
177(B1) | NOP | Label | | |
178(B2) | FN | Const/Reg Const/Reg … | FN 3 D0 D10 | Special instruction #3 (The number of parameters is variable. Minimum 1, maximum 16. Insert null indicating the end of the parameter) B2 03 C0 00 00 C0 0A 00 00 |
MATH
Mnemonic | Code(Hex) | Explain |
+ | 48(30) | Add |
- | 49(31) | Sub |
* | 50(32) | multiply |
/ | 51(33) | division |
MOD | 52(34) | Mod |
« | 53(35) | Bit Shift Left |
» | 54(36) | Bit Shift Right |
AND | 55(37) | Bit operation AND |
OR | 56(38) | Bit operation OR |
XOR | 57(39) | Bit operation XOR |
D0 = D1 * 2 also can use. (same as MATH D1 * 2 D0)
D0 = D1 * D2 * 2 (same as MATH D1 * D2 D0, MATH D0 * 2 D0) Parentheses cannot be used, Operates sequentially from the beginning without operator priority.
PARAMETER
Constant value
Type | Code(HEX) | Example |
BIT 0 | 16(10) | —! 0 !— convert to LOAD 10 |
BIT 1 | 17(11) | —! 1 !— convert to LOAD 11 |
BYTE | 18(12) | 18, BYTE |
WORD | 19(13) | 19, LOW_BYTE, HIGH_BYTE |
DWORD | 20(14) | 20, LOWLOW_BYTE, LOWHIGH_BYTE, HIGHLOW_BYTE, HIGHHIGH_BYTE |
Direct Address | 21(15) | |
Index Address | 22(16) | D(D10) convert to 22 21 192 21 192 10 0
Cannot be used twice D(D(D10)) X |
Bit Modifier | 23(17) | D10.1 convert to 23 21 192 10 0 x
x=BitPostion(0~31) |
Byte Modifier | 24(18) | D10.H covert to 24 21 192 10 0 x
x: 1=H, 0=L |
Word Modifier | 25(19) | DD10.H covert to 25 21 194 10 0 x
x: 1=H, 0=L |
Direct Address (BOOL)
Kind | Code(Hex) | Example | Conver to | range |
X | 255(FF) | X100 | 21, 255, Address_Low, Address_High | 0~31, 100~131, … 900~931 |
Y | 254(FE) | Y100 | 21, 254, Address_Low, Address_High | 0~31, 100~131, … 900~931 |
M | 253(FD) | M100 | 21, 253, Address_Low, Address_High | 0~999 |
F | 252(FC) | F100 | 21, 252, Address_Low, Address_High | 0~999 |
C | 251(FB) | C100 | 21, 251, Address_Low, Address_High | 0~999 |
T | 250(FA) | T100 | 21, 250, Address_Low, Address_High | 0~999 |
KC | 249(F9) | KC100 | 21, 249, Address_Low, Address_High | 0~99 |
KT | 248(F8) | KT100 | 21, 248, Address_Low, Address_High | 0~99 |
K | 247(F7) | K10 | 21, 247, Address_Low, Address_High | 0~99 |
Direct Address (WORD / DWORD)
Kind | Code(Hex) | Example | Conver to | Description | range |
D | 192(C0) | D100 | 21, 192, Address_Low, Address_High | | 0~999 |
KD | 193(C1) | KD100 | 21, 193, Address_Low, Address_High | Retain | 0~99 |
DD | 194(C2) | DD100 | 21, 194, Address_Low, Address_High | | 0~999 |
KDD | 195(C3) | KDD100 | 21, 195, Address_Low, Address_High | Retain | 0~99 |
CC | 196(C4) | C100 | 21, 196, Address_Low, Address_High | (hidden) Count Content | 0~999 |
KCC | 197(C5) | KC100 | 21, 197, Address_Low, Address_High | (hidden) Count Content Retain | 0~99 |
TC | 198(C6) | T100 | 21, 198, Address_Low, Address_High | (hidden) Count Content | 0~999 |
KTC | 199(C7) | KT100 | 21, 199, Address_Low, Address_High | (hidden) Count Content Retain | 0~99 |
About C,T
When used in a function, C becomes CC, T becoms TC.
Symbol | Original | to CODE |
–[ ] | TON T1 100 | 166 21 198 1 0 19 100 00 |
When used in a input(BOOL) symbol, C becomes C, T becoms T.
Symbol | Original | to CODE |
–! !– | T1 | 250 1 0 |
About FOR..NEXT
---[FOR 5 D0]
FORREPEAT:
---[MOV 10 D0]
---[BREAK] ; JUMP TO EXITFOR
---[Next] ; D0=D0-1, if D0 < 10 JUMP to FORREPEAT
EXITFOR:
Literal
Decimal | Hexadecimal | Hexadecimal(2) |
0 | 16#00 | 0x0 |
37 | 16#25 | 0x25 |
12534 | 16#30f6 | 0x30f6 |
Timer value | Convert to | Description |
T#100 | 100 | mS |
T#0.1S | 100 | Sec |
T#1S | 1000 | Sec |
T#1M | 60000 | Minute |