Close

Reverse Engineering the BASIC Program

A project log for Optronic Laboratories 740A/D Spectrometer

Getting a 1990 vintage spectrometer running on something more modern than MS-DOS

Jerry BiehlerJerry Biehler 3 days ago0 Comments

I uploaded a copy of the BASIC program that ran the system. The important part was this, which I annotated what it did. With this Information and finding the interface to the spectrometer is a 48 line DIO board I was able to figure out what lines did what. 

1110 P1CW = 528: P1C = 529: P1B = 530: P1A = 531
1120 P2CW = 532: P2C = 533: P2B = 534: P2A = 535
1130 OUT P1CW, 147: OUT P2CW, 147
1140 HIMASK = 240: LOMASK = 15 '240 is 11110000 15 is 00001111'
9110 '
9115 IF SRCE% <> 1 THEN GOSUB 11000: RETURN  ' skip this sub if alt input (QE STATION)
9120 FOR I = 1 TO 450 * ms: NEXT I
9130 PORT2A = INP(P2A): PORT2B = INP(P2B): PORT2C = INP(P2C)
9140 DATAREADY = ((PORT2C AND 8) / 8) 'Bit 3'
9150 IF DATAREADY = 1 THEN 9130
9160 PORT2AHIGH = (PORT2A AND HIMASK) / 16: PORT2ALO = (PORT2A AND LOMASK)
9170 PORT2BHIGH = (PORT2B AND HIMASK) / 16: PORT2BLO = (PORT2B AND LOMASK)
9180 PORT2C1 = PORT2C AND 1 'Bit 0'
9190 EXPONENT = ((PORT2C AND 4) / 4) 'Check Bit 2, gives a 1 if high this is for exponents over 9'
9200 POWER = -(EXPONENT * 10 + PORT2ALO) 'if bit 3 high, add 10 to exponent from bits 3-0
9210 MANTISSA = PORT2C1 * 1 + PORT2BHIGH * .1 + PORT2BLO * .01 + PORT2AHIGH * .001
9220 s = MANTISSA * (10 ^ POWER): RETURN
9230 '
'9240 ' -------------------------------- 9 -------------------------------------
'9250 '
'9260 ' SUBROUTINE (9): Read 740-1C wavelength
'9270 '
'9280 PORT1A = INP(P1A): PORT1B = INP(P1B): PORT1C = INP(P1C)
'9290 PORT1AHIGH = (PORT1A AND HIMASK) / 16: PORT1ALO = PORT1A AND LOMASK
'9300 PORT1BHIGH = (PORT1B AND HIMASK) / 16: PORT1BLO = PORT1B AND LOMASK
'9310 PORT1C3 = PORT1C AND 3
'9320 W1 = (PORT1C3 * 1000 + PORT1BHIGH * 100 + PORT1BLO * 10 + PORT1AHIGH * 1 + PORT1ALO * .1)
'9330 RETURN

SUB GOTOWAVE (lambda)
 ' - BEGINNING WAVELENGTH -
 '
     L1 = 400
 OUT P1C, 112: OUT P1C, 240  ' fast/neutral
 CALL ioread(W1) 'GOSUB 9260 ' SUBROUTINE (9): Read wavelength
 IF W1 < L1 - 11 THEN GOTO forw ELSE GOTO revrs

revrs: OUT P1C, 192: OUT P1C, 224: OUT P1C, 240   ' reverse/start/neutral
 FOR I = 1 TO 10 * ms: NEXT I' delay loop
 WHILE W1 > L1 - 11
 CALL ioread(W1) ' GOSUB 9260 ' SUBROUTINE (9): Read wavelength
 WEND

forw: OUT P1C, 128: OUT P1C, 224: OUT P1C, 240   ' forward/start/neutral
 FOR I = 1 TO 10 * ms: NEXT I' delay loop
 WHILE W1 < L1 - 1.4
 CALL ioread(W1) ' GOSUB 9260 ' SUBROUTINE (9): Read wavelength
 WEND
 OUT P1C, 208: OUT P1C, 240  ' slow/neutral
 WHILE W1 < L1
 CALL ioread(W1) '  GOSUB 9260 ' SUBROUTINE (9): Read wavelength
 WEND
 OUT P1C, 160: OUT P1C, 240  ' stop/neutral
END SUB


So from this we see that the output of both the spectrometer control and the radiometer use BCD outputs and the wavelength control is commanded by the high nibble on the Port C of the controller. Ringing out the cable I find the pinouts for the two DB-25s on the boxes.

Spectrometer pinouts 
730A
Port C Bit 1 is for negative
740-1C

DB-24    IOCard.  Port/Bit
1 21 A0
2 22 A1
3 23 A2
4 24 A3
5 25 A4
6 26 A5
7 27 A6
8 28 A7
9 13 B0
10 14 B1
11 15 B2
12 16 B3
13 17 B3
14 18 B5
15 19 B6
16 20 B7
17 11 C0
18  31 C1
19 12 C2
20 32 C3
21 9 C4
22 29 C5
23 10 C6
24 30 C7
25 40 GND

And from the program we see that these are the control signals. The sequence is direction, speed or both, followed by start and the sequence is ended with "neutral" which just pushes the pins to a high idle state. 

Port C Bits 7-0, Function, Hex, Dec
11110000 Neutral (used after commands) F0 240
11000000 Reverse C0 192
10000000 Forward 80 128
11100000 Start E0 224
01110000 Fast 70 112
11010000 Slow D0 208
10100000 Stop A0 160

I had this figured out about three years ago. And then like half my projects it just sat.

Discussions