home *** CD-ROM | disk | FTP | other *** search
- Performing PX-8 Analog-to-digital Conversions on the PX-8
-
-
-
- The PX-8 analog to digital conversion operations are performed under
- control of the 7508 slave CPU. Most, but not all, of these A/D operations
- can be handled with just one BIOS call that makes all the Z80/7508
- communication involved transparent to the user. However, temperature
- sensing with the A/D converter is not handled by this call and requires
- some extra programming, which will be discussed later. The special A/D
- converter used in the PX-8 is a uPD 7001C.
-
- The mnemonic ADCVRT is used for this BIOS call, and it provides a common
- entry point for reading certain specific bytes of input data, such as an
- external analog voltage input, the bar code reader input voltage, the
- internal battery voltage, the DIP switch settings, and the power switch
- status. Note that the last two items do not involve the A/D converter as
- you would expect.
-
-
- A/D Specifications
-
- The A/D converter (uPD 7001C) specifications are:
-
- Input level: 0 to 2.0 V
- Resolution: 6 bits/32 mV
- Channels: Four channels, two of which are available to the
- user. Two other channels are used internally to
- detect battery voltage and temperature.
- Conversion time: 140 us
- Max. input voltage: 0 - 4.5 V
-
-
- ADCVRT call description
-
- The ADCVRT subroutine call is setup as follows:
-
- Entry Point: WBOOT + 6F
-
- Entry Parameters:
-
- Register C = 0 ; selects A/D channel 1 (input from A/D input jack)
- Register C = 1 ; selects A/D channel 2 (input from bar code reader
- connector)
- Register C = 2 ; selects DIP SW1
- Register C = 3 ; selects battery voltage
- Register C = 4 ; selects power switch status
-
- When any other value is set in Register C, the routine returns without
- doing anything.
-
-
- Return Parameters:
-
- Upon return from the ADCVRT call, register A will contain the data byte
- requested on entry as illustrated below.
-
- Bit - 7 6 5 4 3 2 1 0 ;Register A bits
- --------------------------------------
- Data - MSB LSB ;A/D channels 1 & 2
- Data - 8 7 6 5 4 3 2 1 ;DIP SW1
- Data - MSB LSB ;Battery voltage
- Data - TRIG PWSW ;Power switch
-
- For an A/D channel 1 or 2 request, bits 2 to 7 will all be 1 if the input
- voltage is greater than 2.0 V. If the input voltage is negative, bits 2 to
- 7 will all be 0.
-
- For a DIP SW1 status request, each bit returned denotes the corresponding
- switch on/off status.
-
- For a battery voltage request, bits 2 to 7 will all be 1 if the input
- voltage is greater than 5.7 V. The greater than 2.0 V battery voltage is
- compensated for by a special divider circuit that prevents the A/D device
- from seeing more than the 2.0 volts at its input. The ADCVRT routine then
- returns a value in the A register that can be related to the actual voltage
- of the battery by a linear formula.
-
- For a power switch status request, bit 0 = 1 indicates that the Power
- switch is On, while bit 0 = 0 indicates that it is Off. Bit 1 = 1
- indicates that the TRIG status of the analog connector is On, while bit 1 =
- 0 indicates that it is Off.
-
- A practical use of the ADCVRT call is presented by the source listing for
- the program BATTERY.ASM written by Bob Diaz, and available on the EPSON
- B.B.S. Running this program on the PX-8 produces a graphic display of the
- actual battery voltage of your unit. As you will notice, the simplest part
- of the program is the actual ADCVRT call, while the rest of the program
- deals with binary to ASCII conversions and screen display.
-
-
- 7508 CPU communications
-
- For cases where no BIOS Call is provided, the programmer should keep in
- mind that communication with the 7508 CPU must take place across a serial
- interface that requires handshaking protocol. The discussion below will
- illustrate this.
-
- Since all A/D converter operations are controlled by the 7508 slave CPU,
- the Z80 never writes or reads directly to or from the A/D converter. The
- Z80 program merely sends commands to and reads data from a register in the
- 7508 I/F. When a one byte command is stored in this register, it is then
- serially passed to the 7508 CPU, which in turn recognizes and executes the
- specific command. The result of the 7508 command execution is then
- serially passed back to the same I/F register for subsequent readback into
- the A register of the Z80.
-
- As described above, the ADCVRT call does all this for you for the specific
- cases it was designed to handle. There is one A/D feature that this call
- does not handle, however. This is the temperature sensing feature.
-
- The following example of temperature sensing will further illustrate how to
- communicate with the 7508 chip.
-
- I/O address 06H points to the SIOR (Serial I/O Register) in the 7508 I/F,
- where a one byte command to the 7508 chip is sent. For sensing temperature
- this command is 1CH; for battery voltage reading it is 0CH. This parallel
- byte is then serially transferred to the 7508 as soon as the RES RDYSIO bit
- (bit 1 of CMDR address 01H) is set to a 1. Setting this bit to a 1 resets
- the RDYSIO bit (bit 3 of STR address 05H) and signals the 7508 to read the
- SIOR serially. While this command is being executed by the 7508, the
- RDYSIO bit (Serial I/O Ready) stays low indicating that the 7508 command is
- still executing. When the execution is finally complete, the result is
- passed serially by the 7508 back to the SIOR. A Z80 input command can now
- read this result and process it as needed.
-
- To obtain a temperature reading perform the following routine in Z80 code:
-
- LD A,1CH ;1CH is the temperature sense command
- OUT (06H),A ;Output 1CH to the SIOR
- LD A,02
- OUT (01H),A ;Set RES RDYSIO bit to 1 to reset RDYSIO
- ; at this point the command is being sent to 7508
- RDY:
- IN A,(05H) ;Read RDYSIO bit. Low=7508 busy
- BIT 3,A ;test it
- JP Z,RDY ;if busy, loop until 7508 op complete
- ; when here, SIOR contains result of requested command
- IN A,(06H) ;Read the raw temperature data
-
- The data byte that is now in register A must be converted into a meaningful
- form with a nonlinear translation formula. This formula is too complex
- to detail at this time. However, a very rough linear approximation, as
- extracted from the PX-8 technical manual, could be constructed from the
- five values below.
-
- If A reg = 60H then temperature = 50 degrees Centigrade.
- If A reg = 80H then temperature = 40 degrees Centigrade.
- If A reg = A0H then temperature = 32 degrees Centigrade.
- If A reg = C0H then temperature = 25 degrees Centigrade.
- If A reg = E0H then temperature = 18 degrees Centigrade.
-