In this experiment we will show you how easy to display
temperature 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 TADC.Timer1Timer(Sender: TObject); var dataA,dataB,data:byte;temperature:real; begin 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*5/255; Edit1.text:=inttostr(data); Edit2.text:=floattostr(temperature); 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.