Home > electrical-training-simulator > PLC programming lessons > lesson 4
PLC Programming Lesson 4: FIFO Event Recorder
Record event data into a FIFO stack and play it back in the same order
Lesson objective: Create an event recorder using a First In First Out (FIFO) data stack. Record up to 20 event values, inspect the stored data in the N7 integer file, manually play the events back, and then verify timed automatic playback.
I/O and Event Recorder Requirements
Lesson 4: In this lesson we will create an event recorder using a First In First Out (FIFO) data stack. The data stack uses the FFL and FFU instructions. We will begin with the physical I/O addressing scheme and the memory file used to store the event-recorder data.
| Address | Name | Device |
|---|---|---|
| I:1/0 | Start_PB | N.O. push button |
| I:1/1 | Stop_PB | N.C. push button |
| I:1/2 | Record Event | N.O. push button |
| I:1/3 | Manual Playback | N.O. push button |
| I:1/4 | Auto Playback | Toggle switch |
| I:3/00-15 | Event Input Data | Toggle switches |
| O:4/00-15 | Playback Display | Green bulbs |
| Address Range | File | Purpose |
|---|---|---|
| N7:10-N7:30 | N7 Integer File | Data stack memory |
Example Requirements:
- Use a standard start/stop station with a seal-in and a virtual control relay to enable or disable continuity on the rungs that address physical I/O.
- The event recorder will be capable of recording up to 20 events. Each event is represented by a 5-bit data word in this exercise, although an event data word can be up to 16 bits. The event values will be stored in the N7 integer data file from N7:10 through N7:30.
- Use toggle switches on the I:3 input module to set the desired event data.
- Use a normally open push button to record the event data currently appearing on the I:3 inputs.
- Use a normally open push button for manual playback, one event at a time, in the same order the events were recorded.
- Use a toggle switch for automatic playback. When closed, the recorded events will be played back one at a time at 3-second intervals until the event recorder is empty.
Review the FIFO Instructions
In this example we will use XIC, XIO, OTE, TON, FFL, and FFU instructions. If you are unfamiliar with any of them, select Help > Instruction Help. Clicking the FFL stack instruction in the instruction table opens help for that instruction.
The help page provides a description of the instruction, explains its parameters, and shows an example of how it is used. Review any unfamiliar instructions before continuing.
Build the Event Recorder
Once you are familiar with the FIFO instructions and the TON timer, create or load the application program shown below. Use the addressing shown in the lesson and use R6:0 for the Control field of both the FFL and FFU instructions. Use a virtual relay at O:10/0 for the seal-in rung.
Add a TON timer with a 3-second preset. This timer controls the interval between recorded events during automatic playback when the I:1/4 Auto Playback toggle switch is closed. The I:1/3 Manual Playback push button plays one event at a time. Both playback modes reproduce the event data in the same order in which it was recorded.
Open the 2D I/O Interface and configure the switch types listed in the Physical I/O table. For Slot 1, change bits 00 through 03 to the required push-button types.
Open Comms and select Upload to upload the program and go ONLINE. Press the normally open I:1/0 Start_PB to latch the seal-in rung. You can now use the I:3 toggle switches together with the I:1/2 Record Event push button to record the 20 event values.
For this exercise, use only bits 00 through 04 of the I:3 input module. The 20 event values follow a binary up-count pattern. Leave a toggle switch OPEN when the corresponding bit is 0 and CLOSED when the bit is 1.
Record the Event Data
Step 1: To record the first event, place the first data word on the I:3 switches. Close the switch for bit 00 so that input is 1. Bits 01 through 04 remain open because the first event data word contains zeros in those positions.
Step 2: Press the I:1/2 Record Event push button. The value currently on the I:3 switches is stored at the first event-recorder address, N7:10.
Repeat the two-step procedure for the remaining 19 event data words.
Next, open the N7 integer table and confirm that the event values were stored. Minimize the 2D interface if needed, then use the Project Tree and select Data Files > Integer.
When the N7 Integer file opens, set the Radix to Binary if it is not already displayed that way. Navigate to the N7:10 through N7:17 area to view the first eight stored event values.
Manual Playback
To play the events back one at a time in the same order they were entered, minimize the Integer table and press the I:1/3 Manual Playback push button.
The first event value, 0 0 0 0 1, appears on Slot 4 at output addresses O:4/00 through O:4/04. The green output bulbs display the event word being played back.
Press the Manual Playback push button four more times while watching the Slot 4 green bulbs. After the fifth event is played, the binary value for 5, 0 0 1 0 1, should be displayed.
Automatic Playback
Next, verify the Auto Playback function. Maximize the N7 Integer table again so you can watch the FIFO data stack unload the remaining recorded values at 3-second intervals.
Close the I:1/4 Auto Playback toggle switch. Watch the remaining event values play back and appear on the O:4 green output bulbs until all recorded events have been played.
When the remaining event data has finished being played back, OPEN the I:1/4 toggle switch to stop the T4:0 playback-rate timer.
Finally, record additional event values while leaving the Integer table open. Watch how the values are loaded into the event recorder and observe the way the data stack changes when the FFL and FFU instructions execute.
Need access to the required simulator? PLCLogix 500 Simulator | PLCLogix 5000 Simulator