Omega Engineering OME-A826PG 사용자 설명서

다운로드
페이지 60
OME-A-826PG Software Manual [Win 95/98/NT] 
 
2.3.3 A826U.PAS 
 
unit A826U; 
 
interface 
 
type PSingle=^Single; 
type PWord=^Word; 
type PInteger=^Integer; 
type PSmallInt=^PSmallInt; 
 
Function  A826_AD2F(hex, Gain :Word): Single ; StdCall; 
 
implementation 
 
uses math; 
 
 
//*-----------------------------------------------------* 
//* Return voltage value or -100.0 if any error occurs  * 
//* or parameter is out of range.                       * 
//* 
Gain 
0-3 
     * 
//*-----------------------------------------------------* 
Function  A826_AD2F(hex, Gain :Word): Single ; 
Var 
    ZeroBase, VoltageRange, FullRange : Single ; 
    i : Integer ; 
 
Begin 
 
    ZeroBase  := 0; 
    FullRange := 32767; 
    VoltageRange := 10; 
     
    i := hex;  
    if i > $7FFF then 
     
i := ((Not hex) + 1) * -1 ; 
     
 
    Gain := Gain mod 16 ; 
     
 
    If (Gain < 0) Or (Gain > 3) Then 
    begin 
        result := -100; 
        exit; 
    end; 
 
    Result := ((((i - ZeroBase) / FullRange) * VoltageRange) / Power(2, Gain)); 
 
End; 
 
end. 
 
Date: Aug-15-2000             Ver: 2.2                                                                                         Page  29