mindsensors / PiStorms

PiStorms code, libraries and setup.
http://www.mindsensors.com/content/78-pistorms-lego-interface
29 stars 17 forks source link

Calling `activateCustomSensorI2C` on too many ports causes issues #42

Closed seth10 closed 7 years ago

seth10 commented 7 years ago

The explorer program made you use BAS1. I wanted to support all ports, so I changed it to

psm.BAS1.activateCustomSensorI2C()
psm.BAS2.activateCustomSensorI2C()
psm.BBS1.activateCustomSensorI2C()
psm.BBS2.activateCustomSensorI2C()

However, this causes issues. BAS1 and BAS2 work pretty reliably, but the bank B sensor ports are very spotty. Often the calls to GetFirmwareVersion, GetVendorName, or GetDeviceId would fail.

Having too many ports set to this mode can cause issues with load on the I2C bus. It is some electrical issue, a resistive issue, something with capacitance and the load on those lines. We currently do not know exactly why, but now this behavior is documented.

seth10 commented 7 years ago

A program to help test this issue might look something along the lines of the following:

import time
from mindsensors_i2c import mindsensors_i2c
from PiStorms import PiStorms
psm = PiStorms()

a = mindsensors_i2c(0x22 >> 1)

#psm.BAS1.pssensor.setType(0)
#psm.BAS2.pssensor.setType(0)
#psm.BBS1.pssensor.setType(0)
psm.BAS1.activateCustomSensorI2C()
psm.BAS2.activateCustomSensorI2C()
psm.BBS1.activateCustomSensorI2C()
psm.BBS2.activateCustomSensorI2C()

while not psm.isKeyPressed():
    time.sleep(0.01)
    print a.GetFirmwareVersion()