imemotor, and Controlsguy
I took the liberty of adding some rung comments to Controlsguy's code (I hope he doesn't mind)
Now you can see some different styles of programming Controlsguy Vs. PLCnut.
Questions?
PLC 05
// Rung 1
// Address 0
STR X0
OUT Y0
// Rung 2
// Address 2
STR X0
AND X1
OUT Y1
// Rung 3
// Address 5
#BEGIN COMMENT
"This rung sends the PLC scan to the subroutine every half second"
""
"The next bit of text is a quote from Controlsguy"
""
"Quote:"
"""I wanted to only set the pump bits and the alarm output once every second or so to "
"avoid chattering the outputs, and would have done so inline, skipping it with a GOTO and "
"LBL but the 05 doesn't support it, so that's in an SBR as well."""
#END
STR SP4
GTS K2
// Rung 4
// Address 8
END
// Rung 5
// Address 9
#BEGIN COMMENT
"imemotor,"
""
"This is a subroutine because it's after the ""end"" statement it is scanned only one time"
""
"This section that Controlsguy has written only gets scanned during the first PLC scan after "
"a powerup or a PLC transition from stop to run. "
""
"On larger programs this kind of programming can make the PLC much faster."
""
"He has placed some values for setpoints here also like LD k1000 then do you see the "
"""out"" underneath? this is one of your setpoints to compare against."
""
""
""
#END
SBR K1
// Rung 6
// Address 11
ANLGIN K0 K0 K2 K0 V200
// Rung 7
// Address 49
#BEGIN COMMENT
"The values in this rung are just a guess. You have not given us any info on your "
"temperature probe & transmitter and your pressure sensor and transmitter. So that we can "
"help you scale them."
""
"You can also write to the PLC from the HMI to these setpoints the PLC will overwrite them "
"on powerup or a stop to run transition."
""
"So in you HMI if you wite a value to ""V210"" this will be your new setpoint"
#END
STR SP1
LD K1000
OUT V210
LD K3000
OUT V211
LD K4000
OUT V212
LD K200
OUT V213
// Rung 8
// Address 58
RT
// Rung 9
// Address 59
#BEGIN COMMENT
"The next bit of text is a quote from Controlsguy"
""
"Quote:"
"""I wanted to only set the pump bits and the alarm output once every second or so to "
"avoid chattering the outputs, and would have done so inline, skipping it with a GOTO and "
"LBL but the 05 doesn't support it, so that's in an SBR as well."""
#END
SBR K2
// Rung 10
// Address 61
#BEGIN COMMENT
"I still think you need to check your VFD manual out for info on preset speeds."
""
"These are normally done in a binary matrix"
""
"Fan speed 1out Fan speed 2out Fan speed 3out VFD preset speed #"
"ON off off = preset 1"
"off ON off = preset 2"
"ON ON off = preset 3"
"off off ON = preset 4"
"ON off ON = preset 5"
"off ON ON = preset 6"
"ON ON ON = preset 7"
""
#END
STR V200 V210
ANDN V200 V211
OUT Y2
// Rung 11
// Address 66
STR V200 V211
ANDN V200 V212
OUT Y3
// Rung 12
// Address 71
STR V200 V212
OUT Y4
// Rung 13
// Address 74
STRN V201 V213
OUT Y5
// Rung 14
// Address 77
RT
// Rung 15
// Address 78
NOP
#BEGIN ELEMENT_DOC
"X0","On/Off switch","",""
"X1","Pump_Permissive","",""
"Y0","""System On""","","Indicator Light"
"Y1","Pump On","",""
"Y2","Fan speed 1","",""
"Y3","Fan Speed 2","",""
"Y4","Fan Speed 3","",""
"Y5","Alarm Output","",""
"V200","Channel 1","","Analog input"
"V201","Channel 2","","Analog input"
"V210","S.P. 1","",""
"V211","S.P. 2","",""
"V212","S.P. 3","",""
"V213","S.P. 4","","Low Pressure"
#END