Dr. Arne JachensDr. Arne Jachens

PWM Control of Ventilation via I2C bus

The better approach to set the ventilation level continously is to utilize a LED dimmer:

Raspberry_PCA9530.svg
R1 = 100 kOhm, R2 = 10 kOhm

My first approach had been to replace the control panel of the ventilation and to hack the RS232 bus.

Activate the I2C bus

There are many good explanations in the web on how to bring up the I2C bus.
Essentially it takes some steps like:

sudo su
raspi-config under the "Advanced Options" enable I2C and SPI.
nano /etc/udev/rules.d/51-i2c.rules
KERNEL=="i2c*", GROUP="gpio", MODE="0660"
nano /etc/modprobe.d/raspi-blacklist.conf
#blacklist spi-bcm2708
#blacklist i2c-bcm2708
nano /etc/modules
snd-bcm2835
i2c-dev
nano /boot/config.txt
dtparam=spi=on
dtparam=i2c1=on
dtparam=i2c_arm=on

Install tools for I2C

apt-get update
apt-get install i2c-tools
apt-get install python-smbus
apt-get install libi2c-dev

Initial test of the I2C bus:
i2cdetect -F 1
i2cdetect -y 1

If it should not work, perhaps it takes one more reboot.
On first trial I only got response "UU" at address 0x1b. After some testing I finally found out, that at the RESET pin of the PCA9530, the 3.3 V potential was missing, so my dimming IC was in permanent reset. After some re-soldering, I got

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: 60 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- -- 

Patch Paul Thermos 200

To control the ventilators via my PCB, I had to patch the connections of my Paul Thermos unit.
Opening the cover with the Paul logo you"ll see: ThermosKlemmen.jpg

PaulThermosPatch.svg
Of course the transistors are on the PCB, not in the Paul connectors box.

Test the ventilation control

To set the ventilators to 50%, using address 0x60 on bus 1 you may set all registers in one run:
i2cset -y 1 0x60 0x11 0x00 0x80 0x00 0x80 0xe i
where:
0x11 auto increment flag and both output logics with pull up resistors
0x00 frequency of PWM0
0x80 PWM0
0x00 frequency of PWM1
0x80 PWM1
0x0e xxxx1110 set output0 to PWM0 and output1 to PWM1

Or set one PWM by i2cset -y 1 0x60 0x02 0x80
and read back that register
i2cget -y 1 0x60

Python interface

"""
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)