3.5.3. Temperature in Graph Display - Parallel
Port
In this experiment we will show you how easy to display
temperature in Graph from a sensor by using command mode WR only. Build
up a circuit as shown in picture bellow. As you seen in picture, this
ADC will receive voltages from 0 to 1 volt, so the Vref must be 0.5
volt.
a. Puts 1 Timer Components, 2 Edit Component and label
on Form, as shown in picture bellow.
b.Click on Timer1 component to insert with the program
as shown bellow
procedure TGraph.Button1Click(Sender: TObject); begin timer1.enabled:=true; end;
procedure TGraph.Timer1Timer(Sender: TObject); var dataA,dataB,data:byte;temperature:real; begin timer1.enabled:=false; asm mov dx,$378 {Port Data} mov al,00000010b {Start Conversion Pulse WR=1} out dx,al ; mov dx,$378 {Port Data} mov al,00000000b {Start Conversion Pulse WR=0} out dx,al ; mov dx,$378 {Port Data} mov al,00000010b {Start Conversion Pulse WR=1} out dx,al ; mov dx,$378 {Port Data} mov al,00000010b {Drive A/B=0,to select D0-D3,from MUX74157} out dx,al ; mov dx,$379 {Port Status} in al,dx {get data D0-D3 from Mux} and al,11110000b {masking bit D0-D3 for Port Status} xor al,10000000b {Bit 7 Inverting} mov dataA,al {saving data Reg AL to variable Data} ; ; mov dx,$378 {Port Data} mov al,00000011b {Drive A/B=1,to select D0-D3,from MUX74157} out dx,al ; mov dx,$379 {Port Status} in al,dx {get data D0-D3 from Mux} and al,11110000b {masking bit D0-D3 for Port Status} xor al,10000000b {Bit 7 Inverting} mov dataB,al {saving data Reg AL to variable Data} ; end; data:=( DataA DIV 16 ) + DataB; temperature:=data*100/255; Edit1.text:=floattostr(temperature); series1.Add(temperature,'',clred); timer1.enabled:=true; end;
procedure TGraph.Button2Click(Sender: TObject); begin timer1.enabled:=false; end;
c. To run the program, you can hits F9 or RUN menu,
and then you will see a picture as shown bellow, and try to simulate
the program by sensing a temperature.