Dumb question on PLC program operation.

todster

Active Member
How does the board step through the program. It's hard for me to write a program without understanding how it is stepped through. Does it step through then set outputs, is it event driven or ...... The PLC's I program step through the program and then the outputs are set based on the logic. No out put should be reused because the last time the output is used is the state it will be set to at the end of scan. I'm new to these and this style of PLC programming so bear with me please.
TIA
 
Currently I have a wood/oil furnace controlled by an Allen Bradley SLC 5/04. Analog for this is extremely expensive. I purchased a CAI board and would like to learn to program it. To interface this with the PLC would be expensive and difficult so I'm thinking of replacing the PLC with this. I'm used to ladder logic so this will present a learning challenge. I'll post my ideas below and am open for suggestions, ideas and comments. I do not expect to have the program written for me but could use some help on it and especially on getting started.

Inputs: TEMP (8): living room temp (T2), humidity (H1), duct temp (T1), room a temp (T3), room B temp (T4), middle duct temp (T5), Return air temp (T6), outside air temp (T7), reserved (T8)
Inputs: Digital (8): Duct over temp. Fan lo. Fan hi, Chimney hot, Oil gun on feedback.
Analog (3): fuel oil level sending unit (A1). ::: Hot air flow MAP sensor (A2), Return air flow map sensor (A3) (for plugged filter indicator (O8))
Outputs (8): Low speed fan (O1), Hi Fan (O2), Oil on (O3), draft fan on (O4), vent fan to crawl space (5),
Logic:
Heat mode:
OilMode, if toggled (Var1) on then it is on. If time is early morning wakeup then oil on if Var1=1 else use 0. 0 is default mode which is wood. Wood mode is a draft fan.
Wakeup: 5m to 7am
When room is cool, enable heat mode. When duct is warm turn fan on lo and inhibit hi, if duct gets hot, inhibit lo and turn on hi and disable heat mode. If duct overheats inhibit lo and hold hi, disable heat mode and set alarm. If chimney is hot then alarm.
If duct inlet air vacuum is high set plugged filter alarm.
Humidifier controlled by humidity. (would be nice to have this vary according to room temp)

Create dash gauges for fuel, inlet vacuum, duct temp, duct pressure, plenum temp, room temp.

Definitions: Heat mode is either oil gun or draft fan. Need way to determine which it will be. Possible toggle? Gun to be used for startup and mornings. Could also be forced on for 5 minute increments to augment wood.
Lo speed is duct temp from 110F-130F
High speed is 130F-150F
Hot is 150F-165F
Overheat is 175F+
Notes: Hi and lo on fan can never be on at the same time or the motor will burn up.
Default in any overheat situation whether true or due to shorted sensor will be fan to hi and draft/oil off. This will also trigger an alarm and an email.
 
WebControl's PLC program will run from start to end, then all over again and again.
Normally you can initialize some variables right after START, the put a label as your main logic. Before END, you can jump to the main logic without re-initialize all your variables.
In this way, your PLC logic will loop forever, but your variables only initialize once during power up. This will give you chance to not set TTL output high when certain condition not
meet.

You can set TTL output in your logic once all the condition meet. It is better has a subroutine to turn each TTL output, so that you can check condition to stop the TTL output in emergency case.

You can call another subroutine from within a subroutine, up to 8 times.(8 level of stack limitation).
 
Are the output bits set during scan or after each scan? Typically with a PLC I can also use an output bit as an input and it appears I cannot do that here?
Is it possible to access an integer at the bit level ie if I want to toggle the 3rd bit on and off such as xxxx1100 or xxx1000?
Also it is awesome to see that CAI responds on this forum. With Allen Bradley, The software often costs more than the PLC and you need a pricey contract to get answers to questions.
 
No. You don't have limit of total 64 sub. You can have 8 levels callsubs from first level of PLC logic. But you don't have limit of how many sub. The limitation is 2000 lines of PLC logic in the 3.2.13 and above firmware.
 
Question on operand optional part with "and" . If no option is stated such as
And Var1 Var2
Is this line skipped if result is 0
and this line executed?

BZ Var1 Var2 Do_This
How does this work if I use the optional (a) or am I am totally misunderstanding it?
Again I'm sorry for being dense but I am used to ladder logic and being able to use the individual bits in an interger variable for storage and directly read and write those bits when ever I want.
 
Question on operand optional part with "and" . If no option is stated such as
And Var1 Var2
Is this line skipped if result is 0
and this line executed?

BZ Var1 Var2 Do_This
How does this work if I use the optional (a) or am I am totally misunderstanding it?
Again I'm sorry for being dense but I am used to ladder logic and being able to use the individual bits in an interger variable for storage and directly read and write those bits when ever I want.

AND can have three parameters, the 3rd one store the AND result. However, if you don't specify that, then yu can use BZ or BNZ to check the zero flag.
BZ and BNZ can have one or two parameters. If your previous result was stored in VAR1 or RAM1, you can write
BZ VAR1 DO_THIS
or
BZ RAM1 DO_THAT
DO_THIS is a label to jump to.

Those two solid state relays you sepcified should work fine with WebControl TTL output.

Hope this helps.
 
I'm looking at the 3.2.13 manual and it has this example on page 26:

checkOP3:
AND AIP1 AIP3 RAM1
TSTGT RAM1 1024
BNZ l1
TSTEQ IP4 1
BNZ l2
RET

Is the AND a misprint? It should be add? Anding these 2 will only yield a 0 or a 1 in Ram1?
 
WebControl AND, OR and XOR are all based on whole number, not bitwise.
AND AIP1 AIP3 RAM1 will AND the values from AIP1 and AIP3, store the result into RAM1.
Since AIP max value is 1024, two different AIP could be greater than 1024.

To answer your question, AND is not misprint.
 
This is how I should understand it? Value
----------------------------------------------------------------
integer1 0 0 1 1 3
integer2 0 1 0 1 Operation Name 5
----------------------------------------------------------------
logand 0 0 0 1 and 1
logor 0 1 1 1 or 7
logxor 0 1 1 0 xor 6

1024 is max value and is 10000000000.
With this in mind, I could actually refer to individual bits in a var by simply masking with the AND funtion. IE.. for the 3rd bit to test if it is set I could do this
And var1 4
BNZ (do this if 3rd bit is a1)

If var1 was 27 the result would be 0.
 
I think you are correct, AND 1024 and 1024 will be 1024, it will not be greater than 1024.
TSTGT RAM1 1024 should be TSTGT RAM1 1000 or something it can be greater than the AND value.
Microsoft Windows has a calculator in its accessories. In that calculator, you can select view as programmer.
Then you can do AND, OR, XOR calculation from that. 32bit is DWORD.
 
I use calc for this all the time. Conversion to from oct, bin and dec is easy. My tests with and have shown that it does not act as a mask and it does not follow the rules I posted above. I see it only putting a 0 or a1 in the var.
I tried this test as well
AND 4 12 var6

The contents of var6 is 1. It should have been
0100
1100
------
0100
instead of
0001

START
set var1 0
set var2 0
set var3 0
set var8 0
set var5 0
AND 4 12 VAR6
SET RAM8 1
AND 12 12 VAR7
AND T1 T2 VAR4
END Outputs
1

2

3

4

5

6

7

8
TTL Output Bits
0​

1​

0​

0​

0​

0​

0​

0​
32 Bit Signed Vars
0​

0​

0​

1​

0​

1​

1​

0​

version 3.02.14

I'm learning slow but I'm seeing things that aren't as they should be. This completely changes how I need to program.

obviously When it comes to entering a reply WYSIWYG does not apply.
 
You are correct. Actually the logic AND result is boolean. I mistakenly calculated the logical AND using bitwise AND from calculator.
The user guide says that AND is "Logical AND's a with b and optionally puts boolean result into d. Zero bit updated."

Should we consider adding bitwise AND? What would be best short name for bitwise AND? ANDB = Bitwise AND?
 
Back
Top