PDA

View Full Version : 5 position que



menehune1
05-26-2005, 02:31 PM
Greetings everyone.

I have a project that I'm hoping to build with a Stamp. Unfortunately I've been away from Stamps for a long while (My pbasic is at ver 1.04 http://forums.parallax.com/images/smilies/smile.gif) I really need to do a refresher on programming over the summer.

I have a teaching laboratory with 16 seats. Each student has a trainer at their station and when they have completed their lab, they request the instructor to come and test them (by switching in errors on the trainer). The students currently raise their hand but the instructor may not see them and get them in the correct orderas he's walking around the lab.

Basically, something like a "now serving" sign, but with the capability to show the next five stations which are requesting service. I was figuring to wire the call buttons in an array like a 16 button phone pad and eventually have a light board which will illuminate numbers so the students and instructor can see who's next. I guess if I need to, I could just use a bell and a terminal window on a PC to keep running list of next stations. I don't know how I would add and remove numbers as they are serviced. It seems to me that I may be asking the stamp to do too much at once-wait for key presses; log and store at least five button presses; display on a tally board the current and next five stations; when serviced, remove the current number and move each number up a slot in the que.

I only have a BS2 from a BOE bot which only has 16 data lines. I'm hoping not to upgrade, but with serial out lines, keypad data lines and possibly 16 outputs, I think I will have a severe data line shortage. Is there a way to have the stamp output a serial code like hex and have an external decoder board display the data? Maybe a 1->16 demultiplexor? Or maybe even the reverse of a keypad encoder?

Post Edited (menehune1) : 5/26/2005 6:35:17 AM GMT

nick bernard
05-28-2005, 12:05 AM
each station has 1 button of the array correct?

i'd opt for my favorite io expander, the shift register.
try a 74hc165 to read the inputs with your bs2, it would only consume 3 pins. i'd also use a serial lcd to display the queue since it requires the least exteral components. an LED based display could utilize shift registers but it would be difficult to display the queue. 7-segment leds could display the queue, but it would be expensive.

rox on
nick

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Byte walks into a bar and orders a pint. Bartender asks him "What's wrong?" Byte says "Parity error." Bartender nods and says "Yeah, I thought you looked a bit off."

Tracy Allen
05-28-2005, 02:50 AM
That reminds me a thread from some time back. The guy had a "game show" where kids would press a button when they thought they could answer a question posed by the moderator, and the first to press their button got a rapidly flashing light, the second to press got a light at half speed and so on. So if the first contestant couldn't correctly answer, they could move to the second place etc. I have state machine code I came up with for this posted at...

www.emesystems.com/BS2fsm.htm#Game%20show (http://www.emesystems.com/BS2fsm.htm#Game%20show)

The neat thing is, it takes only 4 or 5 lines of PBASIC code. Implemented as a tight state machine.

Your situation is a little different, in that you want to have means to pop the ones who have been visited off the queue. That might be done with another button.

In short, I think the project is do-able on a BS2. You would need 8 lines to scan a 4x4 key matrix, or you could use one of the external keypad scanning chips that uses only one Stamp line. There is need for an additional key for your "visited" button, or you could use it as a "shift" key. For the lamps, you could add an external driver chip like the 'HC595, or one of the higher capacity Allegro chips. Those take only 3 lines from the Stamp to address lots of lights.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com (http://www.emesystems.com)

menehune1
05-28-2005, 09:06 AM
nick bernard said...
each station has 1 button of the array correct?

Yes, to keep it simple (and use proven technology) I was going to have each station's call button connect to an individual button in the keypad array.


Tracy Allen said...
The guy had a "game show" where kids would press a button when they thought they could answer a question posed by the moderator, and the first to press their button got a rapidly flashing light, the second to press got a light at half speed and so on.


I remember that program. I'll go and have a look at it.

menehune1
06-09-2005, 05:07 AM
I got my parts order in and I'm ready to hook everything up. Is there a "standard" way to hook up the keypad to the 'hc165 chip? I have Parallax's 4x4 keypad. If I'm reading the keypad's truth table correctly, I think I hook it up like this:
Keypad -> hc165 input
Pin 5 -> A
Pin 6 -> B
Pin 7 -> C
Pin 8 -> D
Pin 1 -> E
Pin 2 -> F
Pin 3 -> G
Pin 4 -> H
Or am I reading the table wrong?

Jon Williams
06-09-2005, 05:35 AM
Keep in mind that the 74HC165 is inputs only, and a 4x4 matrix keyboard relies on having one of its common inputs (e.g., a row) *stimulated* (e.g., made high) while the other set of lines (e.g. columns) scanned. You can connect eight pushbuttons to the '165 without any problems.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

menehune1
06-09-2005, 07:09 AM
Ah, so the 4x4 keypad should be directly connected to the stamp (or a keypad decoder chip), whereas up to 8 push buttons should be connected to one '165? I was wondering where the pullup resistors would connect to the keypad.

Good thing I got two '165s so I can use 16 switches :)

Hmm, I guess I could either get a 74C922 keypad decoder chip and later swap out the keypad for the '165 or I can build from the start with the '165.

The keypad goes into the parts bin for now...*sigh* I guess I bought some extra parts :(

Post Edited (menehune1) : 6/8/2005 11:20:55 PM GMT

Forrest
06-09-2005, 07:56 AM
An inexpensive way to connect the keypad is to use a 74HC595 AND a 74HC165 connected to the keypad. The 74HC595 is connected to the 4 rows while the 74HC165 is connected to the 4 columns. This setup requires 6 stamp pins (as opposed to 8 if connected directly) and 74HC595 and the 74HC165 cost about $.50 each. The 74C922 uses fewer stamp pins, but it costs around $7.50