def __init__(self, slave, channelCount, resolution, name): I2C.__init__(self, toint(slave), name) ADC.__init__(self, channelCount, resolution, 4.096) self._analogMax = 2**(resolution-1) config = self.readRegisters(self.CONFIG, 2) mode = 0 # continuous config[0] &= ~self.CONFIG_MODE_MASK config[0] |= mode gain = 0x1 # FS = +/- 4.096V config[0] &= ~self.CONFIG_GAIN_MASK config[0] |= gain << 1 self.writeRegisters(self.CONFIG, config)
def __init__(self, slave, channelCount, resolution, name): I2C.__init__(self, toint(slave), name) ADC.__init__(self, channelCount, resolution, 4.096) self._analogMax = 2**(resolution - 1) config = self.readRegisters(self.CONFIG, 2) mode = 0 # continuous config[0] &= ~self.CONFIG_MODE_MASK config[0] |= mode gain = 0x1 # FS = +/- 4.096V config[0] &= ~self.CONFIG_GAIN_MASK config[0] |= gain << 1 self.writeRegisters(self.CONFIG, config)
def __init__(self, slave, resolution, name, gain=1): self.__address = toint(slave) self.resolution = toint(resolution) self.initResolution = toint(resolution) - 1 self.name = name self.gain = toint(gain) self.channelCount = 4 self.byteCount = 3 #pass the integer of the chip address to I2C.__init__ I2C.__init__(self, self.__address) #pass the ADC channel, resolution, and vref to ADC.__init__ ADC.__init__(self, self.channelCount, self.initResolution, vref=5) #setBitRate and set_pga must follow I2C and ADC init() #The I2C bus must be set up first. self.setBitRate(self.resolution) self.set_pga(self.gain) # set the gain
def __init__(self, chip, channelCount, resolution, name): SPI.__init__(self, toint(chip), 0, 8, 10000) ADC.__init__(self, channelCount, resolution, 3.3) self.name = name self.MSB_MASK = 2**(resolution-8) - 1
def __init__(self, chip, channelCount, resolution, name): SPI.__init__(self, toint(chip), 0, 8, 10000) ADC.__init__(self, channelCount, resolution, 3.3) self.name = name self.MSB_MASK = 2**(resolution - 8) - 1
def __family__(self): return [DAC.__family__(self), ADC.__family__(self)]