|
|
|
Application Note AN-1
|
By Magnus Pettersson August 30, 1996 Audience Opinion Meter Introduction ADB I/O can be used to get user input from remotely placed keypads to the Mac. This can be used in behavioural experimentation, audience opinion measurements and elections in classroom setups but also in other applications like entry control of rooms in combination with electric door locks. Example: 20 people sitting in a room could each have a keypad with three buttons. Each button would return a value that would let these 20 people "vote" on how they feel about something that they are watching (e.g. a TV show, a lawyer, a commercial, etc.) Implementation ADB I/O has 4 analog inputs that can be used in this application. The method used is to have the keypads generate an analog voltage that correspond to the combination of buttons pressed. Each keypad can have up to 5 buttons. Using 4 ADB I/O units up 16 keypads could be sampled by one Mac. By adding some circuitry to each ADB I/O, up to 32 keypads could be attached to one Mac. The circuit in figure 1 will allow eight keypads to be attached to one ADB I/O. Since 4 ADB I/Os can be attached to one Mac, 4 similar circuits will allow a total of 32 keypads to be used.
FIGURE 1. Block Diagram
|
|
The Keypad The keypad is a box with 5 pushbuttons. A LED indicates when voting is in progress. A 3.5 mm stereo phono receptacle is used to connect the cable to the Mac.
PHOTO 1. Keypad box. Inside the keypad is the circuit in figure 2. Across pin 1 and 3 of the connector J1 a voltage of +9V is applied. The LED D1 will turn on indicating that a vote is in progress and that the user should press a button. Pressing one or several of the buttons SW1 to SW5, a current dependent of the combination of resistors R2 to R6 is fed to pin 2 of J1. This current will be translated to a voltage on the ADB I/O across the pull-down resistors on Port B. By using shielded twisted pair cable between the keypad and the ADB I/O the design will have high noise immunity and cable length could reach 20 meters. The twisted pair should connect to pin 1 and 2 of J1 and the shield to pin 3.
FIGURE 2. Keypad circuit.
The keypad can be easily assembled with soldered wires without any special circuit boards.
PHOTO 2. Inside Keypad |
|
Multiplexer At the Mac the circuit in figure 3 will handle the multiplexing of 8 keypads to 4 analog inputs. To handle up to 32 keypads, 4 circuits can be used The multiplexer consists of one relay with 4 changeover contacts. A fly back diode across the relay coil will protect the ADB I/O relays from voltage spikes. A 9V DC adapter will provide voltage for the relay and the keypads. The Pull-Up/Pull-Down-Jumpers of ADB I/O port B should be positioned for Pull-down for all four channels. Before a vote is started ADB I/O Port B should be configured as 4 analog inputs. To start a vote channel 1 of port A is set high. Thus +9V will be fed to the keypads and the LEDs will turn on, indicating that the participants should press a button (or combinations of buttons). Now, the ADB I/O port B is read and the values are saved. Next, channel 2 of port A is set high. The relay will switch in the next group of four keypads and the ADB I/O port B is read again and the values are saved. This procedure is then repeated for the other 3 circuits. The sample rate of 32 keypads will thus be (11ms * 2 + 11ms) * 4 = 132ms. This assumes that the sampling is done in a tight loop which will disable the use of the mouse and keyboard during the sampling.
FIGURE 3. Multiplexer schematic. |
|
Software The values read from the keypad would ideally have a linear characteristic. But due to the 10k measurement resistor on Port B the actual values will be lower and not linear. Linearity could be achieved by using an operational amplifier to receive the current from the keypads. That is not necessary though, since a linearisation algorithm can be implemented in software.
|
FIGURE 4. Transfer function. |
|
By using the values in table 1 in a conversion table, values representing all the button combinations 0 to 31 can be obtained. Using +9V as supply voltage to the keypads the measured values will range between 0 an 222. By traversing the table and finding a value * 9 that equals (with some margin) the analog value, the table index will give the linearised value. This conversion algorithm can certainly be improved with binary search, table look up or by using a linearising formula etc., however not covered in this application note. |
0 TABLE 1. conversion table. |
|
The code fragments in listing 1 coded in HyperTalk illustrates how an experiment can be executed.The result will be a field of 32 values, one for each keypad. The values will be between 1 and 31 representing the combination of buttons pressed on the keypad.Single button presses will have the following values.Button 1 will have value 1, Button 2 will have value 2, Button 3 will have value 4, Button 4 will have value 8, Button 5 will have value 16.
LISTING 1. HyperTalk code fragment.
References 1. Danielsson - Bengtsson. "Digital Teknik" 1989. 2. Hemert. "Elektronik, Digitalteknik" 1981 Acknowledgements Thanks to Lloyd K. Komatsu and Grant Spofford for original idea and interest in this application. |
| Note: The ADB I/O is no longer made or sold. These ADB I/O pages are hosted by Kaj Bjorkman as a favor to Sven Grenander (the founder and former Head Drone of BeeHive Technologies, Inc.)
Please let other ADB I/O users know that these archival pages are again available. |