Sonntag, 22. März 2015

Velux shutters (Dachfenster Rollo) and Raspberry Pi

Tags: Velux, Dachfenster, Rolladen, Fenster, window, roofwindow, DC, shutter

I have a couple of Velux shutters with electric drives at my roof. Thex work with around 24 Volts and work pretty ok without the control device described in here. The shutters come with two wires. If you put DC on them they either walk up or if you flip polarity they run down.

The good thing is, they seem to understand when they reach their end. Thus they don't block on high current when they are fully up or down and are subject to damage. I wasn't aware of this and thought they are pretty simple device. So i put a couple of safety loops inside this control device to prevent damage. After all, most of that is not necessary for safety, but improves convenience and ease of use massively. All those measures are implemented using current monitoring with the INA219.
  • Power Cut off when current is higher than 1200 mA
  • Limiting power in one direction to 90 seconds
  • Power Cut off on current increase (subject for improvement, currently not used)
I had a Raspberry Pi 1 with a Piface board around. Also a 8 way relay board from Sainsmart. Power supply was an old notebook power supply rated at 19 V, 4.2 Amps. I estimate that with 1.5 Amps some is on the absolute safe side. More than plenty of power. With that equipment i control 6 Velux shutters. All shutters are more or less controlled in sequence. Two relays control polarity, 6 relays control power of chosen polarity to the shutters.

The Piface is used to control  the relay board. GND, Vcc and all open-collector outputs were connected from the Piface to the Sainsmart. It worked instantly. I chose python2 library from piface since an INA219 current monitor still relies on python2. With the help of the other two relays on the piface you could go up to control 8 shutters.

Polarity Change/Wendepolschaltung

Polarity needs to be flipped and two relays are used for this. Since the relays are changers and switch between two pathes, two are enough to change polarity. Six relays remain to close the loop with the individual shutters.

In the first run a fixed timing was used to control the on/off cycles of the relays. As i wasnt shure if the shutters go on high current when reaching end positions i didnt like it really. It turned out that concerns were unnecessary. Using an INA 219 current monitor it turned out the following:
  • Current fairly low. Around 350 mA for lowering, less than 600 mA for lifting.
  • When reaching end position, current peakes up for a moment, then shutter moves a little in opposite direction and stops (Endlagenerkennung).
  • After that the current goes down to very very low level. The INA current sensor reported 22 mA. That is not the current of an unprotected DC motor and in those shutters there must be some logic detecting the end and stop power. I use the INA 219 to detect that drop down of current. Then i can determine the time how long the shutter is moving. Thus half-closing will work out of the box.
  • Starting a full open or close until detecting that the motor uses its own protection scheme i take the time, subtract 8 seconds from it for the following runs. This stops the motor pretty precisely before the shutter safety logic.

It looks like a mess, but so far it works. At the left is the INA 219 current sensor.



Connecting the INA 219

Just in case you want it, solder the 4 wires for the INA on the piface. I used GND, 5V, and the two for I2C. It is connected in between the power supply and the 8-way relay. The Adafruit INA 219 just fits right the current and the voltage used in this scenario. On the image you can see the soldered I2C wires to the piface board.


The purpose of the INA is to:
  • Detect how long the motors are active to determine the time it takes to close and open. Then a half open comes out of the box.
  • Safety loop to switch of in case current exceeds 1.2 Amps. That value might need to be adjusted,

Schematic

Connecting the piface does not need a lot of text. Wire the Sainsmart relay one-to-one to the piface. Take the 5V and GND from the piface as well. The INA 219 just sits next to the power supply. At the moment all shutters are controlled in sequence so the current monitor measures each individually.

Here the shematic. On the left the relays used as changer for polarity changing. The others are just used to close the loop with the Velux shutter motor.

Software Side

The installation of the piface is well documented. The following did the trick. Plus make sure the SPI bus is enabled (raspi-config).
sudo apt-get install python-pifacecommon
sudo apt-get install python-pifacedigitalio

The INA 219 has a python integration from https://github.com/scottjw/subfact_pi_ina219
Once i got the I2C enabled (also raspi-config) and the the dependencies with libffi and smbus-ffi right it also just worked.
sudo apt-get install libffi-dev
sudo apt-get install python-dev

sudo pip install smbus-cffi

Code is here:
https://github.com/staircaseblog/rollo




1 Kommentar: