I've been tasked with designing a buzzer system for a game show. Each user is given a pushbutton that turns on a light, sounds a buzzer, and locks out the other players from pressing their lights. There is also a reset that when held for 1 second will turn off the lights of the players so a new round can start.
Below are images of my solution to this.
On top of that, I was asked to figure out what happens if two players press their buttons at identical times. Would the same person always win? How would I make it so a random person would win if that happens.
I need help figuring out a ladder logic implementation to randomize a winner. Also, an answer to would the same person always win? I think the players whose logic rung is lowest would always win in the case of an exact tie because of it being the latter statement to execute in the cycle.
In Ladder, as the name suggests, processes one line at a time, from top to bottom. Considering the PLC process: (1) Read inputs > (2) Process the program > (3) Update outputs. In your program, if two or more buttons are pressed at the same time, the first button processed (from top to bottom) will be the winner, that is, if buttons 2 and 3 are pressed at the same time, button 2 will always be the winner.
A solution to resolve this is to include the closed contact of the other buttons in series, creating an interlock, and include a Rising Edge processing for the Normal Open contacts of the buttons, so that it is only analyzed in the first cycle.
This will lead to a "no winner" situation if 2 or more buttons are pressed at the same time. So, knowing this situation, you can trigger a process to choose a winner using a ramdomic number.
I don't know what your PLC is, I couldn't recognize it from the images, so I mounted it on an Omron CP2E that I have here. Unfortunately this CP2E doesn't have a random number generator function (I would have to create one and ended up generating it manually just for testing), but I think the program below will give you a good idea (obviously the symbology and memory are different), just take a look If your PLC has a generator and put it in place of D0
, if it doesn't, you can research some ideas, such as using the PLC's cycle time or another source to have adequate entropy.
In this case, I am suggesting a generator for numbers between 0 and 100, and you may need to fine-tune this to find the best index to distribute the probabilities appropriately according to the number of buttons pressed, adjusting the range from 0 to 100 for each one. For example, I adjusted it so that if two buttons have been pressed, the probability range is between 0-50
for one button and 50-100
for the other, now if 3 buttons are pressed, the range is 0-33
/ 33-66
/ 66-100
, obviously this isn't perfect, but given the extremely low probability of three buttons being pressed at the same time, this might be an acceptable solution.
Another point to note is to include a flag to "Do not process" the buttons any more, until the cycle is reset, this will prevent someone from pressing the button more than once and this will lead to undesirably turning on another lamp.
Some Tips...
T1
configured to 1,0 s.