Na sadzie masz napiecie ujemne i dodatnie w sumie na ads1115 nie pamiętam czy tez mierzy takie ,ale na pewno ads1110 sie nadaje.
Tu masz kod do ads1115 z sieci,ale dziala. Troche chyba w nim chyba zmieniałem w czasie testow.
- 'ADS1115 16Bit A/D Wandler
- '
- Dim N As Byte
- Dim High_byte(4) As Byte
- Dim Low_byte(4) As Byte
- Dim Ads_high(4) As Byte
- Dim Ads_low(4) As Byte
- Dim Volt(4) As Single
- Dim Wert(4) As Integer
- 'Adresse ADS1115 Adresspin = low
- Const Ads1115_write = &H90
- Const Ads1115_read = &H91
- 'Const Ad_wert = 1.024 / 32767 '1024
- 'Const Ad_wert = 2.048 / 32767 '2048
- 'Const Ad_wert = 4.096 / 32767 '4096
- Const Ad_wert = 6.144 / 32767 '6144
- 'High Byte
- 'Bit 15 Operational status
- 'When writing
- 'No effect = &B0xxxxxxx xxxxxxxx
- 'Start a single conversion = &B1xxxxxxx xxxxxxxx
- 'When reading
- 'Device is currently performing a conversion = &B0xxxxxxx xxxxxxxx
- 'Device is not currently performing a conversion = &B1xxxxxxx xxxxxxxx
- 'Bit 14..12 Input Multiplexer configuration
- 'Ain0+Ain1= &Bx000xxxx xxxxxxxx default
- 'Ain0+Ain3= &bx001xxxx xxxxxxxx
- 'Ain1+Ain3= &Bx010xxxx xxxxxxxx
- 'Ain2+Ain3= &bx011xxxx xxxxxxxx
- 'Ain0+GND= &Bx100xxxx xxxxxxxx
- 'Ain1+GND= &Bx101xxxx xxxxxxxx
- 'Ain2+GND= &Bx110xxxx xxxxxxxx
- 'Ain3+GND= &Bx111xxxx xxxxxxxx
- 'Bit 11..9 Gain amplifier configuration
- 'FSR 6.144V= &Bxxxx000x xxxxxxxx
- 'FSR 4.096V= &Bxxxx001x xxxxxxxx
- 'FSR 2.048V= &Bxxxx010x xxxxxxxx default
- 'FSR 1.024V= &Bxxxx011x xxxxxxxx
- 'FSR 0.512V= &Bxxxx100x xxxxxxxx
- 'FSR 0.256V= &Bxxxx101x xxxxxxxx
- 'FSR 0.256V= &Bxxxx110x xxxxxxxx
- 'FSR 0.256V= &Bxxxx111x xxxxxxxx
- 'Bit 8 Device operating mode
- 'Continuous-conversion mode = &Bxxxxxxx0 xxxxxxxx
- 'Single-Shot mode = &Bxxxxxxx1 xxxxxxxx default
- '------------------------------------------------------------------------
- 'Low Byte
- 'Bit 7..5 Data Rate
- ' 8SPS= &Bxxxxxxxx 000xxxxx
- ' 16SPS= &Bxxxxxxxx 001xxxxx
- ' 32SPS= &Bxxxxxxxx 010xxxxx
- ' 64SPS= &Bxxxxxxxx 011xxxxx
- '128SPS= &Bxxxxxxxx 100xxxxx default
- '250SPS= &Bxxxxxxxx 101xxxxx
- '475SPS= &Bxxxxxxxx 110xxxxx
- '860SPS= &Bxxxxxxxx 111xxxxx
- 'Bit 4 Comparator Mode
- 'Traditonal = &Bxxxxxxxx xxx0xxxx default
- 'Window = &Bxxxxxxxx xxx1xxxx
- 'Bit 3 Comparator polarity
- 'Active low = &Bxxxxxxxx xxxx0xxx default
- 'Active high= &Bxxxxxxxx xxxx1xxx
- 'Bit 2 Latching Comparator
- 'Nonlatching = &Bxxxxxxxx xxxxx0xx default
- 'Latching = &Bxxxxxxxx xxxxx1xx
- 'Bit 1.0 Comparator queue and disable
- 'Assert after one conversion = &Bxxxxxxxx xxxxxx00
- 'Assert after two conversiosn = &Bxxxxxxxx xxxxxx01
- 'Assert after four conversions = &Bxxxxxxxx xxxxxx10
- 'Disable Comparator = &Bxxxxxxxx xxxxxx11 default
- High_byte(1) = &B11000000
- High_byte(2) = &B11010000
- High_byte(3) = &B11100000
- High_byte(4) = &B11110000
- Low_byte(1) = &B00000000
- Low_byte(2) = &B00000000
- Low_byte(3) = &B00000000
- Low_byte(4) = &B00000000
- '******************* Hauptprogramm *************************************
- Do
- For N = 1 To 4
- Gosub On_ads1115 'ADS1115 auslesen
- Wert(n) = 256 * Ads_high(n) : Wert(n) = Wert(n) + Ads_low(n)
- Volt(n) = Ad_wert * Wert(n)
- Locate N , 1 : Lcd " "
- Locate N , 1 : Lcd Fusing(volt(n) , "#.######") ; " Volt"
- Waitms 250
- Next
- Loop
- End
- '***************** Ende Hauptprogramm **********************************
- On_ads1115:
- I2cstart
- I2cwbyte Ads1115_write
- I2cwbyte &B00000001
- I2cwbyte High_byte(n)
- I2cwbyte Low_byte(n)
- I2cstop
- I2cstart
- I2cwbyte Ads1115_write
- I2cwbyte 0
- I2cstart
- I2cwbyte Ads1115_read
- I2crbyte Ads_high(n) , Ack
- I2crbyte Ads_low(n) , Nack
- I2cstop
- Return