There are always numerous ways to accomplish tasks in programming, but a quick review of the
Allen Bradley bit shift instructions should surely point to them as an ideal tool for use in this
particular process. In the bottle line simulation, we are faced with detecting and tracking
a few Boolean details having to do with the bottles entering the line. Sensors are provided to
detect the presence of a new bottle, the bottle size, and whether the bottle is fully intact.
Essentially 3 Boolean states describing the properties of each bottle that enters the line.
If we analyze the various ways that we might process these bottles, it should quickly become
apparent that we will have ample information for making such decisions, assuming we keep
track of it.
A single BSR or BSL instruction can be used to track a single Boolean state (0 or 1) which
in-turn can describe a unique property of a product. In the initial exercise you will be asked to
track the 3 Boolean values describing each bottle entering our process line. The Boolean states
will be referred to as "Exists", "Large", and "Broken" and these states are to be tracked by you,
utilizing 3 separate BSL (bit shift left) instructions. It can be argued that "Exists" need not
be tracked (=correct), as bottles continuously enter the line, and therefore must exist. We will
even use this fact to strobe our BSL instructions and cause a shifting of our tracked information.
Later when you start diverting broken bottles to scrap however, they will no-longer Exist. These
missing bottles could be detected after they are scrapped by using the "Broken" state, but for
now I want you to track all 3 states using 3 separate bit arrays.
Exercise #1 -- Tracking the bottles
Create a program which allows the operator to start and stop the process using the available
panel mounted switches. When the process is running, the main conveyor should be energized,
and bottles should continuously enter and exit the line. For these exercises please utilize
the bits in word B3:0 if and when single bits such as flags etc. are required.
Utilizing LS1 (Exists), strobe 3 BSL instructions to shift 3 separate bit arrays consisting
of two 16 bit words each. Please use files #B3:2, #B3:4, and #B3:6 for this purpose. By
restricting you to these particular files in the binary table, it will be much easier for you, and
your instructor to monitor what is happening with your program using the data table display.
Test your program out, and using the Data Table display monitor, take note of how the bits
representing "Exist", "Large", and "Broken" are being shifted within their appropriate bit arrays.
You may find that it will be necessary to slow the scan rate using the slider
in the PLC panel to see this activity clearly. If your program is operating correctly, you should
now have a means of determining the properties associated with each bottle that passes down the
Exercise #2 -- Utilizing the Boolean Data
If you paid careful attention to the bits being shifted along in each bit array, you would have
likely noted that there is an offset between each of these 3 arrays. This is due to
the fact that the 3 limit switches are located exactly 2 bottle widths apart. In order to use
LS1 to strobe the data from all 3 switches at the same time, this spacing is actually critical,
and must be an exact multiple of a bottle width. The number of bottle widths in-turn determines
the offset we encounter within our arrays.
We cannot easily compensate for this offset when using a BSL instruction as the switch data
will always load into bit 0 of the array. There may be ways to overcome this, but for these
exercises it will be your responsibility to compensate for these offsets. You will have to
adjust for this whenever you employ any of these bits to determine a particular bottle's
Modify your program so that all Large bottles are diverted to the lower conveyor located on the
right hand side of the simulation. This is to be accomplished by utilizing the appropriate bit in the
"Large" bit array to invoke the transfer. Also, please ensure that the bottles are not damaged in
If you are successful in completing the above, you should be well prepared to deal with the task
of diverting broken bottles to scrap
Exercise #3 -- Boxing the Broken Bottles
To add a little interest to the simulation, I've decided to have you grind up the broken bottles
that occasionally come down the line. Of course it is your responsibility to ensure that the ground
glass is placed into boxes, and to bring new boxes into place as required.
The cost of providing cardboard boxes can be significant over time. For this reason it is essential
that you fill each box to it's maximum capacity, and do so without spillage. Since a small bottle
only produces 2/3 as much ground glass as a large bottle, you will have to adjust for this
difference in your program logic.
In creating the logic for this exercise, you may find that you are faced with initializing variables
or clearing counters etc. each time you edit and then restart your program. Just to make it a little
easier to find this logic, I would ask that you add the following rung to the top of your program.
There is no sense cluttering up your program with logic that only executes once each time
it is run, so please place this logic into a subroutine where it is out of the way, yet
Once you have come up with a solution for the scrap problem, then you are now entering the home
Exercise #4 -- Fill and Cap the Bottles
There aren't many details that need to be explained about the filling operation. Energizing the
fill tube solenoid O:2/6 will cause the fill tube to extend and enter the positioned bottle. You then
must make a choice of discharging a large or small quantity of product into the bottle utilizing the
appropriate charge solenoid O:2/7 or O:2/8. Once again, the Boolean data contained in the bit arrays
will be used in determining the correct action to be taken.
The bottle capping station control should be just a matter of capping each bottle that comes along.
The capping ram solenoid O:2/9 must be energized to extend the ram, but you need not adjust for bottle
size with this particular capping equipment. Attempting to cap a bottle that does not exist will cause
little harm, but is a waste of caps, plus adds to clutter on the plant floor. Due to the foregoing,
ensure that you only cap bottles that actually exist.
I will leave issues such as when to stop and start the line to you. Keep in mind however, that we
want to maintain the highest level of production possible with the equipment at our disposal.
Once you have the filling and capping operations operating at maximum efficiency, we can then
move on to the job of keeping the operator fully informed of the production details.
Exercise #5 -- Tracking the Production Numbers
The operator control panel has been equipped with four, quad-digit LED display units which were
included so that the operator might easily view current production counts etc... In order to reduce the
number of PLC output signals required to control this many displays, it was decided to multiplex the four
display units, and 4 manufactured quad-digit display units complete with built-in latches were
selected for this purpose...
The 16 data inputs of each quad-display unit were wired to a shared 16-bit data bus, and these shared
data lines were in-turn wired to a 16-bit output card addressed as O:4... Four spare outputs from card
O:2 were then wired to control the strobe (latch enable) line of each individual quad-display unit;
one output for each of the 4 quad-display units...
To view a wiring diagram, plus obtain further insight into multiplexing 7-Segment displays, please
select the following link:
Interfacing to 7-Segment Displays
.... includes Bottle Line wiring details
The multiplexed displays may be individually written to by placing the BCD representation of the
number to be displayed into output card O:4, and then strobing the appropriate latch enable line
from low to high, and then back to low again... The data is allowed to enter and pass through the
built-in latches of the selected display unit when it's latch enable line is taken high, and the
data is latched, or effectively frozen when the latch enable line is taken low... Once low, further
changes to the data input lines will be ignored, and the display will continue to display the numeric
representation of the data held in the latches... The display will continue to show the same numerals
until the latch enable is again taken high, or power is lost...
Your task, should you accept this assignment [grin], is to update the multiplexed displays with the running
totals of the large and small bottles produced, bottles scrapped, and boxes filled. The rate at which
the updates take place, should be high enough that single counts are not skipped, but not so high as
to burden the PLC unnecessarily.
This particular task of updating the LED displays lends itself well to modularization, and ideally
should be executed in a subroutine. Even if you call this subroutine unconditionally each scan, there
are still benefits to this approach. Placing this logic where it will be out of the way, yet readily
accessible can make for a much less cluttered, and easier to read program.
The task of writing the subroutine will be left to you, and there are many methods that might be
employed to accomplish the task. One possibility is to employ a self-resetting timer, and then
write to each display unit at a unique but regular time interval.. You might first send the desired BCD
data to card O:4 and enable the selected display's latch enable at the same time... Follow this by
disabling the same latch enable at the next time base interval, and you would then be set to repeat
the same sequence for the next display unit... If you do use a timer, remember that the subroutine will
need to be unconditionally called (as shown above) on each scan, in order for a subroutine located timer
to be updated properly
Once you have the completed the foregoing, all that should be left is to handle the details. Allowing
the operator to set the count of bottles to be processed might be a feature worth implementing. Reviewing
your program and making certain that it is clearly documented is a must. Adding something new such as
tracking equipment run time is an option.
Exercise #6 (Optional!) -- Just a small Modification
In the introduction to this series of exercises for the bottle line, I stated that "There are always
numerous ways to accomplish tasks in programming". In order to prove the statement was accurate, I'm
now going to ask that you modify your program so that BSR (bit shift right) instructions are used in
place of BSL. At the same time, I also want you limit yourself to the use of just 2 bit arrays for
tracking the bottle properties.
If only the "Large" and "Broken" bit arrays are used, you should still be able to determine if a
bottle exists by examining the "Broken" property of the bottle. This of course assumes that the broken
bottle has been diverted to scrap, and therefore no-longer exists.
While you are making the required modifications, carefully review the AB documentation for
the BSR instruction, and see if you can come up with a way of eliminating the offset we had in the
previous bit arrays.