User guide

- 57 -
1835
GOSUBGOSUB
GOSUBGOSUB
GOSUB 1455 ‘ Delay between characters
1840
NEXTNEXT
NEXTNEXT
NEXT CMD
1845
RETURNRETURN
RETURNRETURN
RETURN
1850 ‘
1855 ‘
+——————————————————————————++——————————————————————————+
+——————————————————————————++——————————————————————————+
+——————————————————————————+
1860 ‘
||
||
|
Routine to receive a response from the DV-III |Routine to receive a response from the DV-III |
Routine to receive a response from the DV-III |Routine to receive a response from the DV-III |
Routine to receive a response from the DV-III |
1865 ‘
+——————————————————————————++——————————————————————————+
+——————————————————————————++——————————————————————————+
+——————————————————————————+
1870 RESP$ = “”
1875
WHILEWHILE
WHILEWHILE
WHILE RIGHT$(RESP$,1) <> CR$ ‘ Wait for a carriage return
1880 ‘ If data in input buffer, retrieve it
1885
IFIF
IFIF
IF
LOCLOC
LOCLOC
L O C(1) > 0
THENTHEN
THENTHEN
THEN RESP$ = RESP$ +
INPUT$INPUT$
INPUT$INPUT$
INPUT$(
LOCLOC
LOCLOC
L O C(1),#1)
1890
WENDWEND
WENDWEND
WEND
1895
RETURNRETURN
RETURNRETURN
RETURN
1900 ‘
1905 ‘
+——————————————————————————++——————————————————————————+
+——————————————————————————++——————————————————————————+
+——————————————————————————+
1910 ‘
||
||
|
Routine to parse response to an R command |Routine to parse response to an R command |
Routine to parse response to an R command |Routine to parse response to an R command |
Routine to parse response to an R command |
1915 ‘
+——————————————————————————++——————————————————————————+
+——————————————————————————++——————————————————————————+
+——————————————————————————+
1920 HEXRESP$ =
MID$MID$
MID$MID$
M I D $(RESP$,2,4) ‘ Extract characters 2-5
1925
GOSUBGOSUB
GOSUBGOSUB
GOSUB 1990 ‘ Convert to decimal
1930 TORQUE = (DECIMALNUM - ZEROOFFSET)/100 ‘ Subtract zero offset from torque
1935 HEXRESP$ =
MID$MID$
MID$MID$
M I D $(RESP$,6,4) ‘ Extract characters 6-9
1940
GOSUBGOSUB
GOSUBGOSUB
GOSUB 1990 ‘ Convert to decimal
1945 TEMPERATURE = (DECIMALNUM - 4000)/40 ‘ Calculate temperature
1950 VISC = (100/RPM) * MODMULT * SMC * TORQUE ‘ Calculate viscosity
1955 SSTRESS = MODMULT * SMC * SRC * TORQUE ‘ Calculate shear stress
1960 SRATE = SRC * RPM ‘ Calculate shear rate
1965
RETURNRETURN
RETURNRETURN
RETURN
1970 ‘
1975 ‘
+——————————————————————————++——————————————————————————+
+——————————————————————————++——————————————————————————+
+——————————————————————————+
1980 ‘
| Hex to decimal conversion of a 4 digit hex string || Hex to decimal conversion of a 4 digit hex string |
| Hex to decimal conversion of a 4 digit hex string || Hex to decimal conversion of a 4 digit hex string |
| Hex to decimal conversion of a 4 digit hex string |
1985 ‘
+——————————————————————————++——————————————————————————+
+——————————————————————————++——————————————————————————+
+——————————————————————————+
1990 HEXRESP$ = “&H” + HEXRESP$ ‘ Append hexadecimal identifier
1995 DECIMALNUM =
VALVAL
VALVAL
V A L(HEXRESP$) ‘ Convert hex string to a decimal value
2000 ‘ If overflow, take the complement
2005
IFIF
IFIF
IF
SGNSGN
SGNSGN
S G N(DECIMALNUM) = -1
THENTHEN
THENTHEN
THEN DECIMALNUM = 65536! + DECIMALNUM
2010
RETURNRETURN
RETURNRETURN
RETURN
2015 ‘
2020
+——————————————————————————++——————————————————————————+
+——————————————————————————++——————————————————————————+
+——————————————————————————+
2025 ‘
| Routine to clear the com port input buffer || Routine to clear the com port input buffer |
| Routine to clear the com port input buffer || Routine to clear the com port input buffer |
| Routine to clear the com port input buffer |
2030 ‘
+——————————————————————————++——————————————————————————+
+——————————————————————————++——————————————————————————+
+——————————————————————————+
2035
WHILEWHILE
WHILEWHILE
WHILE
LOCLOC
LOCLOC
L O C(1) > 0 ‘ If data in input buffer
2040 DUMMY$ =
INPUT$INPUT$
INPUT$INPUT$
INPUT$(
LOCLOC
LOCLOC
L O C(1),#1) ‘ Dump it out
2045
GOSUBGOSUB
GOSUBGOSUB
GOSUB 1455
2050
WENDWEND
WENDWEND
WEND
2055
RETURNRETURN
RETURNRETURN
RETURN
2060 ‘
2065 ‘
+——————————————————————————++——————————————————————————+
+——————————————————————————++——————————————————————————+
+——————————————————————————+
2070 ‘
| Routine to close communications channel || Routine to close communications channel |
| Routine to close communications channel || Routine to close communications channel |
| Routine to close communications channel |
2075 ‘
+——————————————————————————++——————————————————————————+
+——————————————————————————++——————————————————————————+
+——————————————————————————+
2080
CLOSECLOSE
CLOSECLOSE
CLOSE #1
2085
RETURNRETURN
RETURNRETURN
RETURN
Running this program from within
GWBASIC© GWBASIC©
GWBASIC© GWBASIC©
GWBASIC© produces output as shown on the next page.