The Complete Guide to One Shot Instructions in RSLogix 5000
One shot instructions are a combination of bit instructions used while performing logical operations. They are instructions that primarily work with the last state (PLC scan) of a particular digital signal. They are useful when you want to perform a function just once for a PLC scan. Different PLC manufacturers have different names for one shot Siemens calls it a positive and negative trigger, Mitsubishi names it a rising and falling pulse. The function, however, remains the same regardless of the name. In this tutorial, we will be looking at the different types of one-shot instructions available in Allen Bradley’s Studio 5000.
The following are prerequisites for this tutorial
- Installation of Studio 5000 Logix Designer. In this tutorial, we uses V32.02.
- Installation of Studio 5000 Logix Emulate:
- RSLinx Classic software
- Basic understanding of ladder logic programming with Studio 5000 or RSLogix 5000
Why are One Shot Instructions Used
For a number of reasons, one shot instructions are employed in PLC programming. They are mostly used to trigger an output for a predetermined amount of time or predetermined number of times. This is beneficial in situations where a pulse or pulse train is necessary to carry out a particular task. For instance, a one shot command may be used in a manufacturing process to engage a valve for a predetermined amount of time and dispense a predetermined amount of fluid.
Additionally, one shot instructions are employed to prevent false triggering. When an output is activated when it was not intended to be triggered, this is referred to as false triggering. When there is noise or interference in the input signal, this can happen. By requiring the input signal to stay in the trigger state for a set amount of time before activating the output, one shot instructions can prevent erroneous triggering. This makes it possible to guarantee that the output is only activated when it is supposed to be.
One shot instructions are especially helpful when the input signal is unstable but a pulse or pulse train is needed to complete a task. A one-shot instruction might be used, for instance, in a transportation application to turn on a brake light when the brake pedal is depressed. However, the brake light might not turn on if the brake pedal is suddenly depressed and released. The brake light will be turned on if a one-shot instruction is used, even if the brake pedal is swiftly depressed and released.
One Shot (ONS) Instruction
The one-shot instructions (ONS) output a true signal on a positive edge detection. This means that for a PLC scan through the rungs, the one-shot instruction will be executed once even if the input stays true. The output remains the same until there is a change in positive edge detection. The one shot can be used for different example applications, such as
- Capturing of specific events like conveyor timing
- Flip flop applications
- Counter applications
The one shot instruction functions as an input instruction.
Navigate to Bit instruction set under at the top right where the instruction toolbar is located then pick one shot instruction as shown below
One Shot Rising (OSR) Instruction
The one shot rising instructions perform almost the same function as the ONS instruction. The OSR gives an output signal for a single PLC scan. This means that the output will stay energized until the input changes state. The OSR instruction has a dedicated signal bit that can be used for performing different digital and/or logical functions in different routines of the PLC program.
One of the differences between a one shot instruction and a one shot rising instruction is that the one shot instruction is always used at the input side in a ladder rung, while the one shot rising is primarily used at the output side of the rungs.
Definitions of One shot rising instruction
- Storage Bit
The storage bit is the bit that stores the state of the output bit of the OSR instruction. It remembers the last state of the signal for every PLC scan cycle.
- Output Bit
The output is set to true or false, depending on the storage bit. This is the bit that can be used for logic operations in multiple ladder rungs.
One Shot Falling (OSF)
The one shot falling instruction has a significant difference between both one shot and one shot rising instructions. The OSF gives an output signal on a negative edge detection when the preceding logical state instructions are true for a single PLC scan. Like the OSR, the one shot falling also has a dedicated signal bit for performing logical operations in the program. A negative edge detection is a change in signal state from 1 to 0.
PLC Programming example using One shot, One shot rising and One shot falling
To demonstrate one shot let us create an accumulator that adds 0.5 continuously and outputs the value to another memory when the start push button is toggled.
Start up RSLinx Classic, Studio 5000 Emulate and Studio 5000 Logix Designer.
Create a “StartTotal” local tag bit with a XIC instruction as shown below
Insert an ADD instruction in rung 0. Navigate to Compute/Math under the Instruction toolbar and select the ADD instruction.
Create two real tags “Accumulator” and “Var”
Source A is Accumulator tag
Source B is Var tag
‘’Dest’’ is Accumulator tag
The accumulator works in such a way that source A is continuously added to the destination for the accumulation of values. This is the same principle applied to totalizers in flow meter applications.
In rung one, use a MOV instruction to transfer the accumulator value to a new destination, "STORED VALUE."
Navigate to Move/Logical in the instruction toolbar and drag MOV onto rung 1.
Put a start value of 0.5 in “Var” tag (SOURCE B). Verify and download the program
You will notice that STORED VALUE tag is increasing continuously
Let us add a one shot instruction after the “StartTotal” button as shown in the image below
Download and run the program.
You will notice at first that when the “StartTotal” button is toggled, the “STORED VALUE” tag has a value of 0.5 and it does not accumulate. This is because of the one shot instruction after the “StartTotal” button. As a result, it was only executed once in the PLC scan because the “StartTotal” button state did not change on a positive edge (from 0 to 1).
Toggle the “StartTotal” button on and off again. This time “STORED VALUE” tag is 1.
So for every toggle of the “StartTotal” button, you get an addition of 0.5 to the accumulator.
To test for one shot falling, delete the one shot bit and insert an OSF instruction in rung 0, then create tags for the storage and output bits as shown below.
The output bit should be used with a XIC instruction in rung 1
Download and run the program.
Toggle the “StartTotal” bit on and notice the difference.
You will notice that nothing happens to the "STORED VALUE" tag, i.e., it is not accumulating because of the OSF instruction.
Toggle the “StartTotal” button off.
Toggling the “StartTotal” button off increases the STORED VALUE tag by 0.5.” Therefore, the OSF instruction becomes true for every negative edge detection from (1 to 0) during the PLC scan.
To test the OSR instruction, change the instruction from OSF to OSR and download.
Toggle the “StartTotal” button to see the change to the accumulator program.
You will notice that it behaves just like the one shot instruction (addition of 0.5 to the STORED VALUE tag for a positive edge detection); one of the differences is that the output bit can be used in different rungs at the same time for various logical operations.
One shot instructions are very important instructions that will come in handy when specific applications are desired. However, the appropriate use of them cannot be overemphasized, as the wrong use can lead to an undesirable outcome.