====== Using a Script to Output Keypad Data to Console ====== {{ reference:test-and-measurement:analog-discovery-2:pmod-kypd-output-to-console:pmod-kypd-top.png?400 |}} {{ reference:test-and-measurement:digital-discovery:pmod-kypd-output-to-console:kypd-workspace.png?400 |}} ===== Introduction ===== This project streams key press data from the Pmod KYPD. The presses are displayed on the console in WaveForms' //Script Editor// instrument. The script can be used in any project that requires input from the Pmod KYPD. The Pmod KYPD uses pull up and pull down resistors to determine which rows and columns have closed switches, correlating to button presses. See the {{/reference/pmod/pmodkypd/pmodkypd_sch.pdf|Pmod KYPD Schematic}} for the KYPD circuit diagram. The Discovery device detects button presses by scanning through DIO pints 0-4. Those pins are set as open drains, meaning that when the Discovery activates a certain pin, it provides a path to ground. Otherwise, inactive pins provide a high impedance (high Z). If a key is pressed, DIO pins 4-7 will detect a logic low signal on the row that was selected. By correlating the row and column to an array containing the possible characters, the script prints the key presses. ---- ===== Inventory ===== * A Discovery Device with Digital I/O: * [[https://digilent.com/shop/digital-discovery-portable-usb-logic-analyzer-and-digital-pattern-generator/|Digital Discovery]] * [[https://digilent.com/shop/analog-discovery-studio-a-portable-circuits-laboratory-for-every-student/|Analog Discovery Studio]] * [[https://digilent.com/shop/analog-discovery-2-100ms-s-usb-oscilloscope-logic-analyzer-and-variable-power-supply/|Analog Discovery 2]] * //An Analog Discovery (Legacy) can also be used.// * [[https://digilent.com/shop/pmod-kypd-16-button-keypad/|Pmod KYPD]], a 16-button keypad * {{reference:test-and-measurement:analog-discovery-2:pmod-kypd-output-to-console:script-keypad-output-to-console.zip|Keypad Output to Console Workspace ZIP Archive}} ---- ===== Setup Instructions ===== ==== 1. Hardware Setup ==== This script requires that Pmod KYPD be connected to the Discovery device's DIO Pins as seen in the image to the right. Finish the hardware setup by plugging the Discovery device into the computer. {{reference:test-and-measurement:analog-discovery-2:pmod-kypd-output-to-console:pinout.png?400|}} ---- ==== 2. Software Setup ==== Download and extract the WaveForms workspace from the {{reference:test-and-measurement:analog-discovery-2:pmod-kypd-output-to-console:script-keypad-output-to-console.zip|Keypad Output to Console Workspace ZIP Archive}} (also linked in the inventory section, above). ---- Open WaveForms. Upon launch, WaveForms will generate a prompt asking to switch to the device used with the workspace. As this is the device originally used when the workspace was created and archived, select **No**. Navigate to //Settings → Device Manager// in the menu bar at the top of the window, to check that the active device is your Discovery. {{reference:test-and-measurement:digital-discovery:pmod-kypd-output-to-console:device-manager.png|}} ---- Open the //keypad// workspace, found in the folder extracted from the archive, in WaveForms. {{reference:test-and-measurement:digital-discovery:pmod-kypd-output-to-console:open-kypd-workspace.png?600|}} ---- ==== 3. Running the Script ==== Once the connections are made, open the workspace in WaveForms. Press the **Run** button ({{reference:test-and-measurement:analog-discovery-2:pmod-kypd-output-to-console:run-button.png|}}) in the Script window. The //Script Output// pane will show the key presses as they're detected. The script is designed so that each time a key is pressed, only a single key press is registered. {{ reference:test-and-measurement:analog-discovery-2:pmod-kypd-output-to-console:kypd-output.png?600 |}} ---- ===== Final Notes ===== For more guides and example projects for your Test and Measurement device, please visit its Resource Center, which can be found through this wiki's [[test-and-measurement:start]] page. For technical support, please visit the [[https://forum.digilent.com|Digilent Forums]]. {{tag>project digital-discovery analog-discovery-2 analog-discovery analog-discovery-studio}}