Hi,
der DS2450 16bit 1Wire ADC kannst Du als Wandler nehmen. Diesen kannst Du Dir auch als kostenloses Sample von Michrochip zuschicken lassen. Mit diesem kannst Du eine Auflösung von 16 bit erreichen. Wichtig ist hier nur Dein Platinenlayout, dieses muss sehr genau und gut entwickelt sein , um eine gute Wandlung hinzubekommen (Rauschminimierung, Wandlergenauigkeit).
Hier ist mein verwendeter Code in Bascom:
Code:
Declare Sub Crc_get()
Const 1w_readmem = &HAA
Const 1w_writemem = &H55
Const 1w_convertch = &H3C
Const 1w_readrom = &H33
Const 1w_matchrom = &H55
Const 1w_skiprom = &HCC
Const 1w_searchrom = &HF0
Const 1w_conditsrc = &HEC
Const 1w_ovdrvskprom = &H3C
Const 1w_ovdrvmtchrom = &H69
Const 1w_vccoperation = &H40
1wreset 'reset the device
1wwrite 1w_skiprom 'Skip ROM
1wwrite 1w_writemem 'Write Memory
1wwrite &H1C 'Write to 001C
1wwrite &H00
1wwrite 1w_vccoperation 'VCC Operation keeps device active!!
Crc_get 'Read in 2 bytes 16bits
Crc_dummy = 1wread(1) 'read dummy byte
1wreset 'reset the device
'Write to locations beginning at 00 08
1wwrite 1w_skiprom 'Skip ROM
1wwrite 1w_writemem 'Write Memory
1wwrite &H08 'Write to 00 08
1wwrite &H00
' Set up Channel A for 16 bit resolution
1wwrite &H00 '16 bit resoultion
Crc_get 'Read in 2 bytes 16bits
Crc_dummy = 1wread(1) 'read dummy byte
' 5.12 Volt range
1wwrite &H00 '5.12 Volt Range
Crc_get 'Read in 2 bytes 16bits
Crc_dummy = 1wread(1) 'read dummy byte
' Set up Channel B for 16 bit resolution
1wwrite &H00 '16 bit resoultion
Crc_get 'Read in 2 bytes 16bits
Crc_dummy = 1wread(1) 'read dummy byte
' 5.12 Volt range
1wwrite &H01 '5.12 Volt Range
Crc_get 'Read in 2 bytes 16bits
Crc_dummy = 1wread(1) 'read dummy byte
' Set up Channel C for 16 bit resolution
1wwrite &H00 '16 bit resoultion
Crc_get 'Read in 2 bytes 16bits
Crc_dummy = 1wread(1) 'read dummy byte
' 5.12 Volt range
1wwrite &H01 '5.12 Volt Range
Crc_get 'Read in 2 bytes 16bits
Crc_dummy = 1wread(1) 'read dummy byte
' Set up Channel D for 16 bit resolution
1wwrite &H00 '16 bit resoultion
Crc_get 'Read in 2 bytes 16bits
Crc_dummy = 1wread(1) 'read dummy byte
' 5.12 Volt range
1wwrite &H01 '5.12 Volt Range
Crc_get 'Read in 2 bytes 16bits
Crc_dummy = 1wread(1)
'( Set up Channel C for output 1
1wwrite &HC0 'Output Open/Output OFF C0 is OFF 80 is ON
Crc_get 'Read in 2 bytes 16bits
Crc_dummy = 1wread(1) 'read dummy byte
' 5.12 Volt range
1wwrite &H00 'Doesn't matter space keeper
Crc_get 'Read in 2 bytes 16bits
Crc_dummy = 1wread(1) 'read dummy byte
' Set up Channel D for output 0
1wwrite &HC0 'Output Open/Output OFF
Crc_get 'Read in 2 bytes 16bits
Crc_dummy = 1wread(1) 'read dummy byte
' 5.12 Volt range
1wwrite &H00 'Doesn't matter space keeper
Crc_get 'Read in 2 bytes 16bits
Crc_dummy = 1wread(1)
')
'*******************************************************************************
'------------------ D S 2 4 5 0 ---------------------
1wreset 'reset the device
1wwrite 1w_skiprom '&HCC Skip ROM
1wwrite 1w_convertch '&H3C Begin Conversion
1wwrite &H0F 'Convert Mask 0000|DCBA ie 0F=0000|1111
1wwrite &H00 '0 'Preset Mask Set=D Clear=d DdCcBbAa ie 55=0101|0101
Crc_get 'Read in 2 bytes 16bits
Waitms 6 'use formula to calculate exact duration for channels
1wreset 'reset the device
1wwrite 1w_skiprom 'Skip ROM
1wwrite 1w_readmem 'Read Memory
1wwrite &H00 'Read Channel A
1wwrite &H00 'Address 0000 and 0001
For I_x = 1 To 4
Lowbyte(i_x) = 1wread(1)
Highbyte(i_x) = 1wread(1)
Waitms 5
Adval_adc1 = Makeint(lowbyte(1) , Highbyte(1)) 'PSG 500
Adval_adc2 = Makeint(lowbyte(2) , Highbyte(2)) 'CDG 45
Adval_adc3 = Makeint(lowbyte(3) , Highbyte(3)) 'PCG 400
Adval_adc4 = Makeint(lowbyte(4) , Highbyte(4))
'Print Adval_adc1 ; Spc(3) ; Adval_adc2 'IKR
Next
Leider gibt es den AD nicht in Dip Version, nur in SMD.
Gruß MAT
Lesezeichen