// ResistMeasure.bcpl -- board tester hardware operation // Last modified July 7, 1980 6:21 PM get "Resist.decl" get "AltoDefs.d" get "SysDefs.d" external [ // outgoing procedures MeasureOhms; CalibrateOhms; PulseChannel; Wait; SignalOn; TesterInterrupt // incoming procedures // incoming statics OsBuffer ] static [ ohmsOffset; ohmsScale; testerOut; ticks signalOn = false signalState = false signalTimer = 0 lastSwitchState = 1 signalOnInterval = 3 // times 17 milliseconds signalOffInterval = 20 ] // --------------------------------------------------------------------------- let MeasureOhms(channel) = valof // --------------------------------------------------------------------------- // Returns the resistance for channel in ohms. // Returns the special value "open" if off-scale. [ let dac = SampleChannel(channel) resultis dac eq 255? open, ohmsOffset + (128*dac)/ohmsScale ] // --------------------------------------------------------------------------- and CalibrateOhms() = valof // --------------------------------------------------------------------------- // Calibrates the ohmmeter using the built-in 0- and 100-ohm resistors, and // then returns the result of measuring the 50-ohm resistor. [ let sample0 = SampleChannel(chanCal0) let sample100 = SampleChannel(chanCal100) ohmsScale = (128*(sample100-sample0))/100 ohmsOffset = -(128*sample0)/ohmsScale resultis MeasureOhms(chanCal50) ] // --------------------------------------------------------------------------- and SampleChannel(channel) = valof // --------------------------------------------------------------------------- [ testerOut<>OsBUF.In+1 if newIn eq OsBuffer>>OsBUF.Last then newIn = OsBuffer>>OsBUF.First if newIn ne OsBuffer>>OsBUF.Out then [ @(OsBuffer>>OsBUF.In) = char OsBuffer>>OsBUF.In = newIn ] ]