|
by Yuri Magda
Start ý The
Software ý The Input Signal Handler and
Interface ý Code Concerns ý The
Design and Details ý Sources and PDF
THE INPUT SIGNAL HANDLER AND INTERFACE
The handling of an input signal is implemented
through Ports 378h and 379h of the printer and is realized in function
GetData. I used Delphiýs built-in assembler to write this function.
The function returns the result as a real number in the variable resultData.
Refer to Figure 2 as I explain how GetData works.
 |
| Figure 2ýThe LTC1286 operating
sequence can be seen here. |
The first thing you must do is initialize
the LTC1286 chip. Itýs necessary to bring *CS high (1) for a short
period (see lines 50ý57 of the program code in Listing 1). After that
itýs possible to start conversion. The conversion is initiated on
the falling edge of *CS and will require 14 clock cycles to complete.
The serial data is transferred through Dout synchronously
with the falling edge of the clock.
Note that the MSB (B11) is available
after the falling edge of the third clock cycle, B10 after the fourth,
and so on. The resultData will hold the result of conversion as the
value:
B11 ý 211 + B10 ý 210
+ ý + B0 ý 20
The conversion procedure is realized
in lines 58ý77 of the program code in Listing 1.
After all is said and done, itýs necessary
to multiply the resultData by 0.0012 (1.2/1000) and return a final
result back to the basic program (lines 78ý79).
The interface part of the program is
written using Delphi. I arranged four buttons, TButton, a one-line
editor (TEdit), label (TLabel), and timer (TTimer), on the main application
form (see Photo 2). The program code for the event handlers (buttons
and timer) is shown in lines 82ý107 of the program code in Listing
1. Those of you who have experience with programming on Delphi can
easily understand this piece of code.
PREVIOUS
NEXT
Circuit Cellar provides up-to-date information for engineers. Visit
www.circuitcellar.com for
more information and additional articles.
For subscription information, call (860) 875-2199, subscribe@circuitcellar.com
or subscribe online.
ýCircuit Cellar, the Magazine for Computer Applications. Posted with
permission. |