Buzzer game

kam

Member
Hi all,

I've got a new task. I'm to design a controller for a quiz game. You know have four tables and every one of em has a buzzer, who ever presses the button first gets the chance to answer.

The thing initially in my mind was to write a comparator, like:

if input1 =1 & input 2 to 5 = 0 then high output 1
if input2 =1 & input 1,3,4, 5 = 0 then high output 2
if input3 =1 & input 1,2,4, 5 = 0 then high output 3
if input4 =1 & input 1,2,3, 5 = 0 then high output 4
if input5 =1 & input 1,2,3, 4 = 0 then high output 5

thats all fine, but the thing is that its not a parallel check, what if button 1 was presses before the others and the loop check was past it and circling through the rest... and during that time someone else pressed button 4, he gets the hit, not 1... kinda makes it unjust to the rest...

I did learn about digital logic, maybe if I use a latch/flip-flop or a shift register or something to store all the inputs in there and use a picaxe to look for an interrupt, then the 1st register to have set the register can send the data to the chip... also if it is possible, that the chip that sets the interrupt can also be taped to the enable of the other chips, that way anytime a register is hit, it can set the interrupt and disable the other chips, making it the only one! =D

Ok, that seems possible, but i'm pretty sure there's another way... something much simpler... there's gotta be...

Alright, I'm all ears (eyes that is)
 

Colinpc

New Member
I suppose you could tie all inputs low and switch high with each input applied to a diode OR to the interrupt pin. This way any button being pressed would cause the interrupt service routine to be run. This would then look at which input was high.

Fred
 

eclectic

Moderator
@Kam

A possibility to work with.
Using either “simple”logic or interrupt.

When I press switch 3, Pin 1 is either high or low.

If I press first, how can I stop the others?

The commands could take
less than 1/1000 second.
 

Attachments

SilentScreamer

Senior Member
This might just be me but if you put "setfreq m8" the amount of time that it takes to run those commands in a loop will be so tiny it wouldn't realisticallly happen. Or have I misunderstood the question?
 

boriz

Senior Member
Something like this would prolly do it:

Code:
do
    do : loop until pins>0
    pins=pins
    pause 2000
    pins=0
loop
The inside loop will continue forever until an input goes high. When this happens (one of the buttons is pressed), one of the bits in PINS gets set and the loop exits, thus preventing any further button tests. Then this (input) PINS value is copied to the (output) PINS port where it illuminates an LED or drives a bell or whatever, then after a two second pause the output’s are reset to all LOW, then the process repeats.
 

boriz

Senior Member
Or you could replace the pause with a button down test, so that the light/bell will remain on (blocking other buttons) until the button is released. Something like this:

Code:
do
    do : loop until pins>0
    pins=pins
    do : until pins = 0
loop
 

Andrew Cowan

Senior Member
Don't worry about it - button presses will be much longer than 1/1000 seconds.

You'll need and 'endif' at the end of each of your if statments.

A
 

hippy

Ex-Staff (retired)
I too would suggest reading 'pins' as that reads all inputs in parallel, then you look for which bit was set. If there's more than one I'd suggest 'cheat', run a round-robbin scheme so the person who got the last draw in their favour doesn't get it next time.

Do
b0 = pins
Loop Until b0 <> 0

That makes sure the pins are latched ( in b0 ) and unchanged thereafter when any button is pressed.

Then you can just check which of bit0, bit1 etc is held. It's too late for me today to show a round-robin scheme in action.
 

kam

Member
Thanks guys!

Good ideas, I'll get onto it and make up a prototype, send the results as soon as i finish...

The round-robin scheme, I didnt get it... perhaps when you get a chance to explain later on...

Thanks again everyone!:)
 

hippy

Ex-Staff (retired)
Round-robin scheme; efectively giving each person their go in turn, but in this case also used as a draw settlement.

There's a 'flag' which the winner of the last round played gets to hold. After a round and a result comes in, the flag is moved clockwise (say) until it reaches a person who buzzed; they are considered the winner.

The flag may go full-circle and end up with the person who was holding it but if there are two or more winners someone else will get it other than the last round's winner. Note the flag is moved first, then a winner is checked for.

Do
b0 = pins
Loop Until b0 <> 0

Do
b1 = b1 * 2
If b1 = 0 Then : b1 = 1 : End If
b2 = b0 & b1
Loop Until b2 <> 0

Whoever is indicated by b1 is the winner
 
Last edited:

kam

Member
Problem Number 2...

I just got a new 20M and was trying to perform a "hello world test" on it... you know as an initiation test... but I cant seem to download the program.

The comms link is fine; I tested it with a firmware check in the options page. This is done by a serial comms with the chip and if that returns a result it means that the comms is working... so that should mean that the download should work too.

My code is:

Code:
abcd:
Sertxd("Hello World!",cr,lf)
pause 250

goto abcd
is there something i'm missing here?

I've used a serial download adaptor for breadboards... its available on microzed. I've powered it up from a 7805 with the capacitor as indicated in the diagram... this has been standard practice for many of my circuits, which worked BTW. what else could it be...

Has anyone ever had a problem with a USB to serial dongle? if so then maybe thats it...
 

kam

Member
Its the standard Prolific serial dongle... it used to work just fine... i went to the system settings and changed the baud rate from 9600 to 4800 as one would expect it to communicate on that rate as standard... but it still doesnt work...

It programs to a few bars and then stops and gives an error message, saying something like the device was disconnected, or the power supply was too low (I'm using a 7805 with a capacitor ) and its all the same... just something thing i'm missing...
 
Top