def i2c_test(self): try: i2c = Ah_I2C(0x00) version = i2c.get_vi2c() bus = i2c.getPiI2CBusNumber() return (version, bus) except: return ('?', True)
def get(self, adresse): self.id = adresse self.i2c = Ah_I2C(adresse) self.get_versionCode() time.sleep(0.100) self.get_infoConfig() time.sleep(0.100) self.get_skeletonPosition() time.sleep(0.100) self.get_state() time.sleep(0.100) self.get_mode() time.sleep(0.100) self.get_limitBW() time.sleep(0.100) self.get_limitFW() time.sleep(0.100) self.get_offset() time.sleep(0.100) self.get_deadBand() time.sleep(0.100) self.get_kpPunch() time.sleep(0.100) self.get_kdDumping() time.sleep(0.100) self.get_kiStretch() time.sleep(0.100) self.get_currentMaxSet() time.sleep(0.100) self.get_protectionGoSet() time.sleep(0.100) self.get_temperatureMaxSet() time.sleep(0.100) self.get_positionCurrent() time.sleep(0.100) self.get_speedCurrent() time.sleep(0.100) self.get_currentCurrent() time.sleep(0.100) self.get_temperatureCurrent() time.sleep(0.100) self.get_protectionCurrent() time.sleep(0.100) self.get_portD() time.sleep(0.100) self.get_pinA2() time.sleep(0.100) self.get_pinA3() time.sleep(0.100) self.get_contactBWFW()
def __init__(self, adresse): self.i2c = Ah_I2C(adresse) self.vi2c = self.i2c.get_vi2c() self.id_ref = {"type": int(), "size": 2, "min": 3, "max": 119} self.id = adresse self.versionCode_ref = { "read": 0x2B, "write": 0x3B, "type": float(), "size": 4, "step": 0.01 } self.versionCode = 0 self.infoConfig_ref = { "read": 0x2C, "write": 0x3C, "type": bytearray(), "size": 15 } self.infoConfig = "A Saisir" self.skeletonPosition_ref = { "read": 0x2D, "write": 0x3D, "type": bytearray(), "size": 4 } self.skeletonPosition = "???" self.state_ref = {"read": 0x2F, "type": bytes(), "size": 1} self.state_list = {0x00: "Initialisation"} self.state_list[0x01] = "Prêt" self.state_list[0x10] = "Erreur suite blocage arbre" self.state_list[0x11] = "Erreur > seuil Courant" self.state_list[0x12] = "Erreur > seuil Température" self.state_list[0x20] = "Errreur carte MC" self.state_list[0x30] = "Arrêt suite contact FW" self.state_list[0x35] = "Arrêt suite contact BW" self.state = 0x00 self.mode_ref = { "read": 0x2E, "write": 0x3E, "type": bytes(), "size": 1, "min": 0, "max": 3 } self.mode_list = {0: "Mode Interactif"} self.mode_list[1] = "Mode roue libre" self.mode_list[2] = "Mode PID Position" self.mode_list[3] = "Mode PID Vitesse" self.mode = 0 self.limitBW_ref = { "read": 0x20, "write": 0x30, "type": int(), "size": 2, "min": 350, "max": 750, "step": 1 } self.limitBW = self.limitBW_ref["min"] self.limitFW_ref = { "read": 0x21, "write": 0x31, "type": int(), "size": 2, "min": 750, "max": 1150, "step": 1 } self.limitFW = self.limitFW_ref["max"] self.offset_ref = { "read": 0x22, "write": 0x32, "type": bytes(), "size": 1, "min": -127, "max": +127, "step": 1 } self.offset = 0 self.deadBand_ref = { "read": 0x23, "write": 0x33, "type": int(), "size": 2, "min": 0, "max": 400, "step": 1 } self.deadBand = self.deadBand_ref["min"] self.kpPunch_ref = { "read": 0x24, "write": 0x34, "type": float(), "size": 4, "min": 0, "max": 655.35, "step": 0.01 } self.kpPunch = self.kpPunch_ref["min"] self.kdDumping_ref = { "read": 0x25, "write": 0x35, "type": float(), "size": 4, "min": 0, "max": 655.35, "step": 0.01 } self.kdDumping = self.kdDumping_ref["min"] self.kiStretch_ref = { "read": 0x26, "write": 0x36, "type": float(), "size": 4, "min": 0, "max": 655.35, "step": 0.01 } self.kiStretch = self.kiStretch_ref["min"] self.currentMaxSet_ref = { "read": 0x28, "write": 0x38, "type": bytes(), "size": 1, "min": 1, "max": 50, "step": 1 } self.currentMaxSet = 4.0 self.protectionGoSet_ref = { "read": 0x29, "write": 0x39, "type": bytes(), "size": 1, "min": 10, "max": 255, "step": 1 } self.protectionGoSet = 20 self.temperatureMaxSet_ref = { "read": 0x2A, "write": 0x3A, "type": bytes(), "size": 1, "min": 1, "max": 255, "step": 1 } self.temperatureMaxSet = 102 self.positionCurrent_ref = { "read": 0x40, "write": 0x50, "type": int(), "size": 2, "min": self.limitBW, "max": self.limitFW, "step": 1 } self.positionCurrent = 750 self.speedCurrent_ref = { "read": 0x41, "write": 0x51, "type": bytes(), "size": 1, "min": 0, "max": 255, "step": 1 } self.speedCurrent = 0 self.currentCurrent_ref = {"read": 0x42, "type": bytes(), "size": 1} self.currentCurrent = 0 self.temperatureCurrent_ref = { "read": 0x43, "type": float(), "size": 4 } self.temperatureCurrent = 0.0 self.protectionCurrent_ref = {"read": 0x44, "type": bytes(), "size": 1} self.protectionCurrent = 0 self.portD_ref = {"read": 0x45, "type": bytes(), "size": 1} self.portD = 0x00 self.pinA2_ref = {"read": 0x46, "type": int(), "size": 2} self.pinA2 = 0 self.pinA3_ref = {"read": 0x47, "type": int(), "size": 2} self.pinA3 = 0 self.contactBWFW_ref = {"read": 0x48, "type": bytes(), "size": 1} self.contactBWFW = 0