• No results found

Adding City Water

Batching Steps

Step 1 Adding City Water

We need to initiate Step 1. Before we do that, thought, we need to add another permissive bit.

We will call that bit “System Ready”.

We know that if the system is enabled but not currently batching, it is ready to begin a batch. We need insert a new rung and create a “System Batching” and “System Ready” bit.

Insert a new rung and program it as shown in Rung 0002.

You can see how Rung 0002 should look in the picture below. The “System Ready” bit will be on when the system is enabled, but not batching.

To actually initiate the batch and hold the batch in Step 1, we are going to use the Output Latch (OTL) instruction. This instruction works in conjunction with the Output Unlatch (OTU)

instruction. The instructions will work on the same bit address, but are typically found on different rungs.

The batch will be started when the operator pushes the Start Batch button. We will latch that bit and label it Step 1.

As a side note, I am going to skip a few addresses in the B3 file. It is always a good idea to leave a gap here and there in the event that you need to add a bit later. It doesn’t affect the operation of the program, but it makes the data files more organized and easier to troubleshoot.

Insert a new rung at the bottom of the ladder. We need an XIC for the System Ready bit and an XIC for the Start Batch pushbutton at the beginning of the new rung.

Click and drag the XIC (examine if closed) tool button from the User menu to the left side of the new branch. Type in the address B3:0/2 and press enter.

To save some typing, you can copy and paste instructions. Highlight the Start Batch instruction in Rung 0001.

Press CTRL-C.

Click on the rung number for Rung 0003.

Press CTRL-V. The instruction is duplicated on Rung 0003. Copy and paste bit in the same way Click and drag the OTL (output latch) tool button from the User menu to the right side of the new branch. Type in the address B3:0/10 and add the descriptor “Batch Step 1”.

However, what if the button is pressed if the system is already batching and in another step? To prevent that from happening, we will make sure that the only way the system can enter Step 1 is if it is not in another step already. Add a series of XIO instructions. Address them from B3:0/11 to B3:0/14. Type in the appropriate descriptors. Verify the rung.

You can see how RSLogix handles rungs that are too long to be displayed on one side. You can compensate for this by maximizing the LAD 2 window, or stretching it to the left. Remember that if you want to return to the default view, choose Window > Arrange > Default Project.

You may wonder why we chose not to use the OTL output latch instruction in Rung 0001. Many times, it is a matter of personal choice; sometimes a “traditional” latch rung is better than using an OTL. In Rung 0001, we were able to keep all the logic affecting the System Batching bit on one rung. This makes it easier to read and a little more condensed. Some people view a traditional latch as a bit safer. It’s your call, though.

Analog Inputs

Before we continue with Step 1, we need to program the Mixing Tank Scales and the Ultrasonic Level Sensor. Since the logic associated with these devices is not necessary tied to Step 1, but common to the entire program, let’s put them in a sub-routine.

We do this by right-clicking on “Program Files” in the Project menu on the left and choosing

“New”. The Name is limited to 11 characters, so we will call it ANALOG. The description will be

“Mixing Tank Scales and Level Sensor”. Click OK.

That reminds us that we did not name LAD 2. Let’s do that right now. Right-click on LAD 2 and choose Rename. We will call it MAIN.

LAD 2 is, by default, the program that will run when the SLC is first powered up. Like subroutines in other programs like Visual Basic or C, we need to tell the main program to execute the sub-routine.

We need to put a JSR (jump to subroutine) instruction in LAD 2. In this case, it really doesn’t matter where it is placed, but putting it at the top makes sense.

Insert a rung at the top of the ladder. In the Instruction menu, click on the right arrow until the

“Program Control” tab is shown. Click on the tab.

Drag the Jump to Subroutine (JSR) tool button to your new rung. Type in a “3” to tell the instruction to go to LAD 3.

Add the descriptor “Mixing Tank Scales and Level Sensor”. Verify the rung.

In the Project menu, double-click on LAD 3 – ANALOG. This opens the new ladder file you just created. Insert a new rung.

We are going to enter an instruction in a new way. Double-click on 0000 for Rung 0000. This opens up the ASCII editor.

Type SCP in the box and press enter. SCP stands for “Scale with Parameters”. It allows you to take an analog input from a sensor and scale it to the output units you want.

Before we start scaling, let’s take a moment to see how the Allen-Bradley NI4 converts a 0-10VDC signal to a number. The NI4 is an analog-to-digital processor that takes the 0-10VDC signal and converts it to a number between 0 and 16384.

The NI4 will yield a number from 0 to 16384 that is directly proportional to the 0 to 10VDC signal that is applied at the input.

In other words, zero volts on the input of the NI4 means that the NI4 will provide 0 as a value to the PLC. Ten volts on the input will yield 16384. Five volts on the input will yield half of 16384, or 8192, and so on.

The SCP instruction starts out looking like this.

Each of the six parameters (Input, Input Min., Input Max., Scaled Min., Scaled Max. and Output) has two fields associated with them. Each field is currently filled with a question mark. The first field is a value that you assign. The second field is the actual value returned by the processor.

Related documents