ControlLogix BSR — Kill the Bit


Introduction to ControlLogix BSR — Kill the Bit (with Bit Shift Right)

In this section, we’ll cover the ControlLogix BSR — Kill the Bit. This is a very simple game from the 1970s. Computers, such as the Altair 8800 and IMSAI 8080 have a front panel display. This LED Display shows processor status, and memory locations. Additionally, they showed the data at those memory locations. Modern LED displays that we think of today are monitors, and TV’s. In contrast, early computers had rows of LED lights that were on or off.

One of the simple games is called “Kill the Bit”. An LED scrolls across a row of 8 LED’s. The object is to hit a switch at the exact time the LED was in that location. If you are successful, the LED would shut off. On the other hand, if you “MISS”, then you would have additional LED’s to kill.

Many would argue that the ControlLogix is for industrial machines, and not for games. However, if you have a set up on your bench, ControlLogix games can make learning fun.

For this example, we’ll use a timer, oneshots, Latch/Unlatch, and the Bit Shift Left Instruction.

Create a New Project

First, we’ll create a new project. If you have not already done that, consult this post. Next, we need to add I/O Modules to your project. We will at least need an input and output module. If you are unfamiliar with how to add those modules, consult this post.

Create Your Tags

Our next step is to create the tags we will need. We’ll create a tag called “OneShots”. This will be a DINT. The reason this is a DINT is because we might end up needing more than one one-shot. Creating OneShots as a DINT is more efficient than creating multiple BOOL tags. Likewise we’ll create a tag called “Flag”. Again, even though we are only using individual bits, we’ll create this as a DINT as well.

We’ll need some other tags for the Bit Shift Left instruction to work. The BSR Timer will act as our trigger for the BSR Instruction. This will be a self-running timer which generates a pulse. Additionally, we need an Array that we can shift through. The BSRArray tag is a DINT[1]. This means that it’s dimensioned as an array, but with only one element. When you add this tag, make sure the data type is DINT[1]. BSRControl will be our workspace. This is where the BSR Instruction stores it’s status.

Write Your Logic

First, of all, let’s turn on a bit within the array. This will start the game with an initial bit to cycle.

Secondly, let’s create a self-running timer. The preset on this timer should be low enough to make the game challenging. However, if the preset is too high, the game will be too slow to have any fun. In this case, I’ve found that a good starting point is around 150ms.

Thirdly, we’ll add our BSR Instruction. Remember that we trigger this from the timer’s pulse.

Fourthly, we’ll add our logic that will toggle a bit within the array. In this case, we’ll just look at bit 0. Remember, if the user hits the switch when the bit is off, the bit will turn on. By doing this, the user will end up with an additional bit that he has to kill. Likewise, if the user hits the switch when the bit is on, the bit will shut off. Effectively, this kills the bit. Keep in mind the goal of the game is to shut all bits off.

Lastly, we will move the array onto the output module.

Final Touches

The game will work as-is. However, with the original game, the user could use any switch. Not just switch 0. To better simulate the original game, You could repeat the 3 rungs that write to the array when the operator hits a switch. You would repeat these three rungs 7 more times, incrementing the bit numbers for each of the three rungs.

Summary

In short, the purpose of this post is to show you how the BSR instruction works. You will learn and have fun doing it. We simply shift an array constantly, loading the right most bit back into the left side of the array. When the user hits switch 0 while light 0 is on, the bit is killed. However, if the user hits the switch at the wrong time, they will add an additional bit. This bit too must be killed. When all lights are out, you win the game!

For information on the BSL instruction, visit this post!

— Ricky Bryce

Leave a comment

Your email address will not be published. Required fields are marked *