Published:2011/8/16 22:16:00 Author:Phyllis From:SeekIC
By Herman Bulle
In the previous article we saw how we could implement a simple calculator using Delphi. This time we connect an external keypad to the serial port, to allow the calculator to be controlled externally. We’ll use the program from the last article (slightly modified) to put the numbers onto the display and to perform the calculations.
The external keypad, which we’ll build ourselves, consists of 16 keys in a configuration of 4 rows by 4 columns. When a key is pressed, a single row is connected to a single column. The combination of the exact row and column is unique for each key.
By activating each column in turn and then checking which row has a signal, we can determine which key has been pressed.
Before we continue with the practical side we would like to point out that the complete listing for this project would take up too much space in this magazine. The listing (project files) can be downloaded from the Elektor website from the Delphi course for March. We recommend that you download this first and load it info Delphi; this makes it easier to follow the next description.
Connecting the hardware
A CMOS type 4555 data selector is used to activate the columns (see Figure 1). This is a dual l-to-4 decoder/multiplexer. Each decoder in the IC has a 2-bit digital input and 4 outputs. Depending on the binary value of the input (00, 01, 10, 11), one of the outputs of the IC will be driven high.
The RS232 port of the computer has two output signals: DTR (Data Terminal Ready, pin 4) and RTS (Request To Send, pin 7). As a reminder we have shown the full connection details of a 9-way RS232 connector in Figure 1. These two signals are used to drive the line-selector inputs of the 4555. Before we can do this we should provide a supply voltage to the IC. Since a CMOS IC consumes very little power it is quite easy to derive the supply from these two signals. When we’re not looking for a key-press there is no need to drive the data selector inputs. We can then keep DTR at ’1’ and RTS at ’0’. It is very easy to derive a symmetrical supply of ±7.5 V (VQD =15V), using a handful of resistors, zeners and electrolytic capacitors (Rl, R2, D1-D4, CI, C2 in Figure 1). The capacitors are sufficiently large to supply a stable voltage to the IC during a complete scan period. All that’s left is to add a little protection to the inputs since the input voltage could be larger than the supply voltage. By adding a 10 kQ to the signal path the input current is kept to a safe level.
If you’re using a laptop you should first measure the RS232 output voltages, as these occasionally deviate from the official RS232 specification (some Dell laptops had outputs of only ±5 V). In this instance the zeners are no longer needed. We have also seen asymmetric outputs (+5 V/0 V), so it is worth checking this out.
Building the circuit of Figure 1 is fairly straightforward. The IC, passive components and 16 keys are easily mounted onto an experimenter’s board, and it doesn’t take long to do the wiring either. You could use an old RS232 cable for the connection to the PC, with a plug cut off from one end (Make sure that you keep the female connector on the cable, since that is required to plug into the PC). The wires can then be soldered directly to the board. As an alternative to individual keys you could also use a matrix keypad (obtainable from Conrad and many other suppliers). Often these come in sizes of 4x3, in which case two keypads can be ’connected in parallel’, using just a single column from the second one.
Reprinted Url Of This Article: http://www.seekic.com/blog/project_solutions/2011/08/16/DELPHI_FOR_ELECTRONIC_ENGINEERS__Part_3__An_external_calculator_(1).html
Print this Page | Comments | Reading(1854)
Author:Ecco Reading(30179)
Author:Ecco Reading(3461)
Author:Ecco Reading(3181)
Author:Ecco Reading(3661)
Author:Ecco Reading(5231)
Author:Ecco Reading(3248)
Author:Ecco Reading(3390)
Author:Ecco Reading(3530)
Author:Ecco Reading(3935)
Author:Ecco Reading(3707)
Author:Ecco Reading(3677)
Author:Ecco Reading(3714)
Author:Ecco Reading(6028)
Author:Ecco Reading(3692)
Author:Ecco Reading(4478)