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.

Before you begin: Access to the PLCLogix 500 or PLCLogix 5000 training simulator is required to complete the hands-on lesson series. Complete Lessons 1-3 first if you are new to PLCLogix. The screenshots and addressing in this lesson use PLCLogix 500. Focus: XIC, XIO, OTE, TON, FFL, FFU, integer data files, event recording, and manual/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.

Physical I/O
AddressNameDevice
I:1/0Start_PBN.O. push button
I:1/1Stop_PBN.C. push button
I:1/2Record EventN.O. push button
I:1/3Manual PlaybackN.O. push button
I:1/4Auto PlaybackToggle switch
I:3/00-15Event Input DataToggle switches
O:4/00-15Playback DisplayGreen bulbs

 

Data File Memory
Address RangeFilePurpose
N7:10-N7:30N7 Integer FileData stack memory

 

Example Requirements:

  1. 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.
  2. 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.
  3. Use toggle switches on the I:3 input module to set the desired event data.
  4. Use a normally open push button to record the event data currently appearing on the I:3 inputs.
  5. Use a normally open push button for manual playback, one event at a time, in the same order the events were recorded.
  6. 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.

Select FFL in Instruction Help when you need a reference for the FIFO Load 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.

The FFL help page explains the instruction and the parameters used by the FIFO data stack.

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.

Build the FIFO event recorder and configure the 2D I/O Interface to match the lesson I/O assignments.

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.

Go online and latch Start_PB before recording event data.

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.

Use bits 00-04 to enter the 20 event values shown in the binary count table.

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.

The first event word is placed on the I:3 inputs and stored by pressing Record Event.

Repeat the two-step procedure for the remaining 19 event data words.

After entering the remaining event words, the event recorder is ready for the N7 data-file check.

 

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.

Select the N7 Integer file under Data Files in the Project Tree.

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.

Binary radix makes the individual bits of each recorded event word easy to inspect.

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.

The first FIFO event is unloaded and displayed on the Slot 4 output bulbs.

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.

After five manual playbacks, the Slot 4 bulbs should display the binary value for 5.

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.

Reopen the N7 Integer table so the remaining FIFO data can be observed during automatic playback.

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.

Automatic playback unloads the remaining event values at the 3-second timer interval.

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.

Keep the Integer table open while recording more events to observe the FIFO data stack changing in real time.
Self-assessment: There is no separate online test for this lesson. Your completed event recorder and its correct simulated behavior are the assessment. Verify that events are recorded in the N7 data stack and played back in the same order using both manual and automatic playback.
Assigned by an instructor or supervisor? Save your finished PLC program and share it with them when you complete the lesson.

Need access to the required simulator? PLCLogix 500 Simulator   |   PLCLogix 5000 Simulator