beautypg.com

Sample program – Measurement Computing Personal488 rev.3.0 For DOS & Windows 3.Xi User Manual

Page 104

background image

II. SOFTWARE GUIDES - 8. Driver488/DRV

8I. Turbo Pascal

Personal488 User’s Manual, Rev. 3.0

II-89

VAR sp: INTEGER;
Writeln(‘Interrupt detected at signal ‘,Signal);
Writeln(IeeeOut,’SPOLL’);
Readln(IeeeIn,sp);
IF sp=0 THEN BEGIN
Writeln(‘Non-SRQ Interrupt!’); Halt
END;

Next we Serial Poll the 195 to determine its status. If there were other devices on the bus that could be
generating the

SRQ

, each of them would be have to be checked in turn.

VAR st195: INTEGER;
Writeln(IeeeOut,’SPOLL 16’);
Readln(IeeeIn,st195);
IF (st195 and 64)=0 THEN BEGIN
Writeln(‘Non-195 SRQ!’); Halt
END;

Bit

DIO7

, with a value of

64

, is returned as true (

1

) in the Serial Poll response of those devices

requesting service. In our simple example, we expect that the 195 is the only possible cause of an

SRQ

,

and if not, there must be some error.

Now that we have identified the device that is requesting service, we can further examine the Serial
Poll status to classify the request:

IF (st195 and 32)=0 THEN BEGIN {
ERROR is not set}
IF (st195 and 1) 0 THEN Writeln(‘Overflow’);
IF (st195 and 2) 0 THEN Writeln(‘Buffer Full’);
IF (st195 and 4) 0 THEN Writeln(‘Buffer 1/2 Full’);
IF (st195 and 8) 0 THEN Writeln(‘Reading Done’);
IF (st195 and 16) 0 THEN Writeln(‘Busy’)
END ELSE BEGIN {ERROR is set}IF (st195 and 1) 0 THEN
Writeln(‘Illegal Command Option’);
IF (st195 and 2) 0 THEN Writeln(‘Illegal Command’);
IF (st195 and 4) 0 THEN Writeln(‘No Remote’);
IF (st195 and 8) 0 THEN Writeln(‘Trigger Overrun’);
IF (st195 and 16) 0 THEN Writeln(‘Failed Selftest’)
END;

The action taken depends, of course, on the design of the system, but in this example, simply displaying
a message is adequate.

Sample Program

BEGIN
VAR IeeeOut, IeeeIn: TEXT;
VAR Response: STRING;
VAR Reading: STRING;
VAR
voltage: REAL;
code: INTEGER;
VAR
sum: REAL;
i: INTEGER;
VAR r: ARRAY[0..1699] of CHAR;
Assign(IeeeOut,’IeeeOut’); Rewrite(IeeeOut);
Assign(IeeeIn,’IeeeIn’); Reset(IeeeIn);
RawMode(IeeeOut);
RawMode(IeeeIn);
IOCTL; {Invoke IOCTL procedure}
Writeln(IeeeOut,’RESET’);
Writeln(IeeeOut,’FILL ERROR’);
Writeln(IeeeOut,’HELLO’);
Readln(IeeeIn,Response);
Writeln(Response);
Writeln(IeeeOut,’STATUS’);