Heating and Ventilation Control
/HvcSendI2C
Keine Erläuterungen gefunden.
""" PWM to control Ebmpapst ventilators in Paul Thermos 200 Dr. Arne Jachens 2020-06-20 """ #import smbus from smbus2 import SMBus class HvcSendI2C: def __init__(self): self.bus = SMBus(1) # 0 = /dev/i2c-0 , 1 = /dev/i2c-1 self.ADDRESS = 96 #0x60 # address on bus, check: i2cdetect -y 1 self.REG_MODE = 17 #0x11 # auto increment flag, output logics with pull up resistors def setPWM(self,level): """ Set the ventilation level [0:1], where 1 is maximal, here both ventilation levels are set equal. """ #level percent to integer levelInt = [] for i,lev in enumerate(level): levelInt.append(int( 255*(1.0-lev) )) #compose message bytes values=[] values.append( 00 ) # frequency of PWM0 values.append(levelInt[0]) # PWM0 values.append( 00 ) # frequency of PWM1 values.append(levelInt[1]) # PWM1 values.append( 14 ) # xxxx1110 set output0 to PWM0 and output1 to PWM1 #send message self.bus.write_i2c_block_data(self.ADDRESS, self.REG_MODE, values) """ for testing """ if __name__ == "__main__": I2C = HvcSendI2C() level = [0.5, 0.5] I2C.setPWM(level)
python
php
Der gesamte Sourcecode darf gemäß GNU General Public License weiterverbreitet werden.