if not rate in adxl355.ODR_TO_BIT: print("Can only do the following data rates: {:s}".format( sorted(adxl355.ODR_TO_BIT.keys()))) exit(-1) # init spi interface spi = spidev.SpiDev() bus = 0 device = 1 spi.open(bus, device) spi.max_speed_hz = 5000000 # important - ADXL 355 has mode SPOL=0 SPHA=0 spi.mode = 0b00 # init adxl355 acc = adxl355.ADXL355(spi.xfer2) acc.start() acc.setrange(adxl355.SET_RANGE_2G) print("{:b}".format(adxl355.ODR_TO_BIT[rate])) acc.setfilter(lpf=adxl355.ODR_TO_BIT[rate]) print("{:08b}".format(acc.read(adxl355.REG_FILTER))) acc.setfilter(lpf=adxl355.SET_ODR_62_5) datalist = [] t0 = time.time() tc = time.time() msamples = mtime * rate mperiod = 1.0 / rate
spi1.open(bus1, device1) spi1.max_speed_hz = 5000000 # important - ADXL 355 has mode SPOL=0 SPHA=0 spi1.mode = 0b00 # init spi interface for lis3dhh spi2 = spidev.SpiDev() bus2 = 0 device2 = 0 spi2.open(bus2, device2) spi2.max_speed_hz = 5000000 # important - lis3dhh has mode SPOL=1 SPHA=1 spi2.mode = 0b11 # init adxl355 acc1 = adxl355.ADXL355(spi1.xfer2) rate = 1000 acc1.setfilter(lpf=adxl355.SET_ODR_1000) # set data rate to 1khz # init lis3dhh acc2 = lis3dhh.LIS3DHH(spi2.xfer2) IDX_ADXL355 = 0 IDX_LIS3DHH = 1 # measure both for mtime seconds msamples = {} msamples[IDX_ADXL355] = mtime * rate msamples[IDX_LIS3DHH] = mtime * 1100 mperiod = {} mperiod[IDX_ADXL355] = 1.0 / rate