# Creating ladder PLC logic using force inputs and outputs

I am currently using Allen Bradley PLC and RSLogix Micro to program it. The problem is:

Create a ladder logic diagram for the following problem in which pump #1 and pump #2, alternately or simultaneously, pump liquid.

• When the level switch closes, first pump #1 turns on. If pump #1 runs more than 30 seconds, then pump #2 turns on. Both pumps continue operating until the level switch opens, indicating a lower liquid level.

• When the level switch closes again, pump #2 turns on. Note that either pump #1 or pump #2 will turn on first to discharge the liquid. Similarly, if pump #2 runs more than 30 seconds, then pump #1 turns on. Both pumps continue operating until the level switch opens, indicating a lower liquid level. Therefore, either pump #1 or pump #2 discharges the liquid, or both pumps discharge the liquid.

Use the force function to close and open the level switch and turn the pumps on accordingly to discharge the liquid level.

Use the force function to turn off (i.e., disable) one of the pumps. Now, run the program and examine if it is working properly.

The updated solution:

The question is that I am not sure if I understand the alternating process between the two pumps.

3rd attempt: The first part of the problem.

4th attempt: So I tried to insert the "flip-flop". And I understand that XOR command is used to alternatively change the value of the B3:0/1. However, when I tried to put in RS Logix the program that you provided, I could not write the address B:3.0/1. Because, it said that address should be specified to the word level. And also the BSR command is represented different in RS Logix. Is represented as in the picture below:

Assuming that the flip flop is working and the values are changing alternately I wrote the program.

Thank you so much! 5th attempt: This time the program worked. And the pumps where energized alternatively.

• Just to know, is this for a real application or it is some homework? This looks like a good case to use SFC instead Ladder since it maybe can be seen as a state machine. Also it would be a good practice to make a marshaling routine to make your program more readable and not have your contacts named directly with your IO tags. May 4 '20 at 11:01
• @ppmbb: All good suggestions but does Micro support SFC? I think we could leave marshalling until later. We'll keep the program short for now. May 4 '20 at 14:08
• i'm not sure if Micro supports SFC, but i see you managed to make it work in your ladder. And about the marshalling it's only a ST routine you should have separated of your main logic, it is to avoid to referencing your contacts as O:0 ,I:1 for example, because, let's face it, no body wants to remember those "cryptic" tags names. Anyway, i'm glad you made it work. May 4 '20 at 20:20

You appear to be lacking understanding of how a PLC program is executed. The PLC code is scanned or executed every few milliseconds and the inputs read at the start of the scan and the outputs written at the end of each scan.

Attempt 1:

Figure 1. The problems.

1. When I:0/0 turns on O:0/0 turns on in the PLC memory (but the output won't turn on until the end of the program scan).
2. Since T:4/1 has not turned on yet the program turns off O:0/0. Since this is the last occurrence of O:0/0 before END this is what get's written to the output. Remember that the last rung to affect the output "wins".
3. Same as (1) above.
4. Same as (2) above.

How to fix:

• Document your program. Assign names to your inputs and outputs, internal bits and timers.
• Draw a timing or sequence diagram. This will clarify your thinking.
• Outputs should only appear once in the program.
• (If you need to) use bit memory, B:0/0, etc.. to keep track of status internally and then use those to control the outputs at the end of the scan.

The assignment has a bit of a twist in it because the outputs have to alternate. I suggest that you ignore this bit for now. Just get it working for the first sequence. Do that first and then update your post with the new code.

• Delete rungs 0000 and 0002.
• Write the logic for pump 1 on rung 0004.
• Write the logic for pump 2 on rung 0005.

Tip: Reduce the window width before taking a screengrab so that the picture is legible in SE's 640 pixel wide image size. That way we'll be able to read it in the post.

Attempt 2:

Figure 2. This won't work because #1 Pump can never turn on.

Attempt 3:

OK, you've got that working. Now you need to make a bit "flip-flop" or alternate every time the float switch turns on. We won't use it yet - we'll just get it working. I'll give you the code for this as it's a bit tricky.

   I:0      B3:0               +XOR------------------+
---] [-----|OSR|---------------+ Source A: I:0/0     +--
0         0               | Source B: B3:0/1    |
| Dest:     B3:0/1    |
+---------------------+


Figure 3. A flip-flop created using the XOR instruction.

Have a look at the SLC 500 Instruction Set page 118 to understand the operation of the XOR instruction.

If you get that working you can now use B:3.0/1 in your output logic with simple modification to the two pump output rungs. Report back again and try to explain how you think the XOR is working.

Attempt 4:

We have a few problems:

Figure 4. A few more problems.

1. You forgot to say which PLC you're using so the instruction set may be different. You'll need to add the OSR in here. If it requires two bits then be careful not to use any that we're writing to elsewhere. I had written the address format incorrectly in Figure 3 and have corrected it.
2. For the XOR to work we need to Source B to be the same as Dest.
3. See 2.
4. Think when B3:0/0 is going to turn on and off. (Try it in your program.) Then think about what will happen the outputs when it does turn on. Will that satisfy your requirements?
5. Same as 4.

Once again, document as you go. You have omitted naming the bits. If you don't get into good habits with this you will suffer much pain in your career.

• Thank you for your response, it really helped me understand my mistake. However, I am not sure I understand the alternating part of the problem May 4 '20 at 13:11
• Let's see your fix so far. Edit your question and post the program. May 4 '20 at 13:15
• Okay, I uploaded the edit May 4 '20 at 13:26