Readers Tips and Computer Answers July 1992

Contents (Readers tips)

This month Shane Devenshire shares a spreadsheet formula for anyone wanting a negative percentage to appear with brackets and J D Coup explains why your PC joystick might be ignored and offers a fix.

Contents (Computer Answers)

Where can you read about the CUA standard, what goes on behind the scenes with a Centronics interface and how to you manage without an Amiga to run Scala?


Computer Answers July 1992

CUA Standard

Is the CUA (Common User Access) standard a publication, and if so where can it be obtained?

Peter Dawson

It is published by IBM and can often be found bundled with packages like Microsoft's Windows Software Development Kit.

It comes in two volumes with the IBM part numbers SC26-4583-0 (Basic Interface Design Guide) and SC26-4582-0 (Advanced Interface Design Guide). The advanced guide was updated last year.

Peter Jacobs and James Wilde


Centronics Interface details

I'm trying to get a detailed specification on the hardware used in the standard parallel port interface used on PCs, sometimes known as a Centronics interface. I'm looking for some sort of published standard, like IEEE or ANSI for such details as voltage levels, timing etc. I've tried a number of places, libraries etc. without luck.

Jeffrey Graham

The Centronics interface takes its name from the printer manufacturer who first started using it. It is not an official standard, for this reason, and there are a number of different flavors out there. The differences normally relate to the combination of signals implemented (many makers choose a subset) and the maximum loading and timing values for the signals themselves. In practice, most makers implement a common core of the useful pins and allow enough slack for the timings and loadings to make the system reliable.

The table shows the pins as they are implemented on the 36 Way Amphenol connector found on the back of standard Centronics printers. IBM decided to be different and used a 25 way miniature D-connector for their parallel port (up until then this was the standard for serial ports instead) but most of the important pins still appear in the same order.

All signals are at TTL level (0-1V means off and +4-5V represents on). Buffering tends to allow up to 6m of cable between units, though the normal recommendation is 1-2m. Originally the signal wires should have been twisted pairs with individual returns, though this is seldom the case with cheap modern cables.

Data can be passed using one of two possible methods of synchronisation - BUSY or ACKNLG. BUSY is the easiest to implement; basically you wait for BUSY to go low (if necessary), assemble the data on pins 2-9, wait 0.5uS for it to stabilise, pull STROBE low for 0.5uS, wait another 0.5uS and then start again.

Using ACKNLG you ignore BUSY but can expect a 12uS low pulse from the printer after it has digested your byte. Once you have received this you can assemble and STROBE the next byte, but you must also check ERROR or risk your data ending up in the bit bucket. This is not necessary if you are using BUSY for synchronisation as this will remain high if any form of printer error exists.

The choice of synchronisation method is left to the computer. If you use BUSY you can safely ignore ACKNLG and vice-versa.

PE (if implemented) will come on simultaneously with ERROR and BUSY so you only need to read it if you wish to differentiate between this and other errors. If the printer is off-line this is also considered an error condition.

Note that the pulse times given are to appear at the printer's end of the cable, not on the computer's interface. You can normally get away with a 0.2uS rise time on all the signals.

The best source of information specific to the IBM PC's parallel port for the low level programmers point of view is probably the Technical Reference Manual published by IBM.

Frank Leonhardt


Centronics Socket Connections

PinNameDescription
1STROBE0.5uS pulse low when data is valid, otherwise high.
2-9Data 0-7The data pins, active high.
10ACKNLG*Pulsed low by the printer for 12uS after data is read.
11BUSY*High when printer is unable to accept data.
12PE*High when paper is empty.
13+5V*Useful voltage
14AUTO FEEDWhen low, automatically Line Feed after Carriage Return.
15NC
160VLogic ground
17Case GNDThe earth, used for screening.
18NC-
19-30GNDReturn for pins 2-9
31RESET50uS low to reset printer.
32ERROR*Low means the printer needs attention.
33GND-
34NC
35
+5V* -
36SLCT INDevice select codes are only valid when this is high.
* All signals marked this originate from the printer. All others are inputs or GND.


Scala for the PC?

Having seen Scala on the Amiga, which PC package comes closest infunction, ease of use, and price please?

Peter Jacobs None really. It is one of the few examples, like Macs for DTP, where the application should govern the hardware used.

You could look at AutoDesk animator, or Director on the Mac but neither approach the VFM the Amiga offers for desktop video.

Simon Rockman

Computer Answers can be contacted on:

leo2@cix.compulink.co.uk
uab1018@dircon.uucp
Telephone 081-429 3047.

Readers Tips June 1992

Negative display format for Lotus 123.

I was recently asked if there was a way to display negative percentages in bracket without displaying the minus sign. This was to show percentages to two decimal places with all the numbers right aligned in the cell. I devised the following formula to solve the problem:

@IF(A1&gr=0,A1,@REPEAT(" ",@CELL("WIDTH",B1)-(@LENGTH(@MID(@STRING(A1,2),1,10))+5))&"("&@MID(@STRING(A1*100,2),1,10)&"%)")

This formula assumes that you have the numbers you want to display as percentages in column A and the formulae to show the percentages in column B. The following example illustrates the results:

AB
.550.00%
.2525.00%
-.5(50.00%)
-.25(25.00%)

This technique works with Lotus 2.x, 3.x and Lotus 1-2-3 for Windows, as well as Quattro. Excel users need only define a number format as follows:

Choose Format, Number and move to the Format Box. Here replace the displayed format with 0.00%;(0.00%) to accomplish the result shown above.

Shane Devenshire, Walnut Creek, California.


Joystick Problems

Recently, when I bought a joystick for my PC (for my son's use, honestly), I was annoyed to find it did not work. The message from the first game we tried was that there was no games port attached to the computer (though this was not the case). However, when I tried the joystick with other games, "Hey Presto", it worked! A bit of investigation show that the problem was caused by the equipment word.

This equipment word is located in low memory and is set every time the machine is booted. It includes bits indicating the number of printers installed, the initial video mode and a bit to indicate whether a games adaptor is installed. On my machine, and others I have tried, the games bit was not set even though a games card and joystick are installed.

As the equipment word is in RAM it is a simple matter to fix, even if you don't have an assembler or computer. Just type in the following commands via debug and a program can be produced that can be called from AUTOEXEC.BAT. The program is tiny (only 17 bytes long) and is not even a TSR so there is no loss of precious RAM.

Proceed as follows:

Run DEBUG from the DOS prompt and enter the following. Note that the '-' is DEBUG's prompt and you should not type it again yourself.

-D 0040:0010 L 2

Debug will respond with four numbers in the format:
0040:0010 ## ##
^
Look at the third hex digit; if it is even then the equipment word is saying that no games adaptor is fitted. (Even hex digits are 0, 2, 4, 6, 8, A, C and E).

If your number is odd then type QUIT as this is not your problem (see below). If is even then continue as follows:

-A 100
This starts assembling a program at the correct starting address for a .COM file. The prompt will change to the format below, where the '#' characters vary from system to system.

####:0100 Enter the code shown in Listing 1. Again, the prompt has been shown and should not be typed. Also, the comments listed against each line should be omitted.

=================Listing 1==========================

####:0100 MOV AX,0040 Set the Data Segment to the low end of DOS
####:0103 MOV DS,AX
####:0105 MOV BX,0010 Set BX to address of equipment word
####:0108 MOV AX,[BX] Get contents of equipment word into BX
####:010A OR AX,1000 Set games port bit
####:010D MOV [BX],AX Put equipment word back
####:010F INT 20 Return control to DOS.
####:0111

================End Listing 1=======================

At the last line simply hit the return key to go back to the minus prompt. Now type the following to set the IP register to the start of the program.

-R IP
IP ####
:

If the number printed (####) is not 0100 then enter 0100 and press return; otherwise just press return. To test the program enter 'G' at the minus prompt. You should get a message to indicate that it terminated normally and you can check to see that it worked by entering 'D 0040:0010 L 2' as described above. The third digit should now be odd; if it is not then retype the program and try again. Assuming all is well then set the BX register to zero and the CX register to the length of the program in the same way the IP register was set above:

-R BX
BX ####
:0000
-R CX
CX ####
:0011
Then we give the program a name (I have chosen JOY.COM) and write it out to disk with:

-N JOY.COM
-W

Writing 00011 bytes
-

The program has now been saved in the current directory and debug should be quit by typing QUIT at the '-' prompt. Simply issue the command JOY before playing your troublesome game or included in your AUTOEXEC.BAT file.

If the suggestion above fails to solve your problem there is another cause which, although rarer, is more difficult to fix. The joystick requires an interrupt 15h service 84h routine which is simply not present on early versions of the ROM BIOS. If this appears to be your problem then it may be possible to write a TSR handler to emulate it, though this is outside the scope of this article!

J D Coup,
Reading.


Computer Answers Archive Next edition Previous edition