AN #130 - Using the AD7895-10 Bipolar AD converter |
|
Using the AD7895-10 Bipolar AD converter
This application note is written by Madhav Tenneti, Managing Director of Spectrochem Instruments Pvt. Ltd.
I have just finished interfacing an Analog Devices AD7895-10
Bipolar AD converter using BASCOM. The results were extremely good. I have
calibrated the system using a YOKOGAWA CA11 (Handy Cal) Calibrator. The AD7895
offers 192KHz conversion speed. I thought this might interest people working on
Data acquisition. I am providing the Source code, Circuit in PDF, & hex
file.
Download the Circuit AN7895.PDF
(this is not the pdf of the chip)
Download the source code and hex
file
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Ad7895
-10 Bipolar Adc %%%%%%%%%%%%%%%%%%%%%%%
'Written by... Madhav Tenneti
'Spectrochem Instruments Pvt. Ltd.
'B-23 Huda Complex, Saroornagar
'Hyderabad, Andhra Pradesh
'500 035 INDIA, Ph 91-40-24053341, 24053342 or 24146308
'URL: www.spectrochemindia.com
'Email: madhav@spectrochemindia.com
'IIC ADC using AD7895-10
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Hardware setup
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Waitms 100
$crystal = 8000000
Baud = 9600 ' Powerup delay for lcd Initilization
Config Lcd = 16 * 2 'A 16 column by 2 row LCD display
Config Lcdbus = 4 'Configured in 4 bit mode
Config Lcdpin = Pin , Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.6 , Db7 = Portb.7 , E = Portb.1 , Rs = Portb.0
Config Pind.3 = Output 'Connected to convert pin of AD7895
Config Pind.4 = Input ' Connected to data pin of AD7895
Config Pind.5 = Output 'Connected to Clk pin of AD7895
Convrt Alias Portd.3
Busy Alias Portd.2 ' The busy pin of AD7895 is
connected to Int0(PortD.2)
Enable Interrupts 'Enabling Global interrupt
Enable Int0 'Enabling INT0
On Int0 Cnvrt 'On interrupt branch to isr
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'%%%%%%%%%%%%%%%%%%%%%%% Variable Declarations
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Dim Port_data As Integer , Volt As Single , Ready As Byte , Msb_chk As Byte
Dim Tmp As Byte , I As Integer , Finl_volt As String * 8
Dim Avg1000 As Single , Temp As Single
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'%%%%%%%%%%%%%%%%%%%%%%% Sub routine declarations
%%%%%%%%%%%%%%%%%%%%%%%%%%
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Declare Sub Splash()
Declare Sub Ad7895()
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'%%%%%%%%%%%%%%%%%%%%%%%%%%% Main Program
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Waitms 100 'Delay after lcd initilization
Call Splash
Do
Call Ad7895
Temp = Avg1000 * 100
Cls
Lcd "Temp: " ; Temp
Lowerline
Lcd "Avg1000: " ; Finl_volt
Waitms 200
Print Finl_volt
Loop
End
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'%%%%%%%%%%%%%%%%%%%%%%%%%%% Sub routines
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'**********************
'*** Welcome Screen ***
'**********************
Sub Splash()
Cls
Lcd "Spectrochem"
Lowerline
Lcd " Instruments"
Wait 2
End Sub
'*************************
'*** AD7895-10 Convert ***
'*************************
Sub Ad7895()
Set Convrt
Waitms 10
Reset Convrt 'initiate Conversion
Waitus 1
Set Convrt
Avg1000 = 1 ' 1000 reading average
For I = 1 To 1000
If Ready = 1 Then
Shiftin Pind.4 , Portd.5 , Port_data , 1 , 16 'Capture 16 bit data
Msb_chk = High(port_data)
Tmp = Msb_chk And &H08 ' Check for 2's compliment
If Tmp = 8 Then
Port_data = Port_data - 4096 ' Conversion to signed data
End If
Volt = Port_data *
0.0048828 ' Applying transfer function for voltage
Avg1000 = Avg1000 + Volt
Ready = 0
Enable Int0
Set Convrt
End If
Reset Convrt
Waitus 1
Set Convrt
Next
Avg1000 = Avg1000 / 1000
Finl_volt = Fusing(avg1000 , "#.####") 'Formatting data for appropriate display
End Sub
Cnvrt: ' Interrupt service routine
Disable Int0
Ready = 1
Return
|