Dienstag, 31. März 2015

Velux shutters and Raspberry Pi (rollo.py) in action


Here the illustration of the shutter controller. Here you see two shutters and on all shutters the same action is performed when up/half/down button is pressed on the piface.

No timing needs to be configured manually since all end positions and travel times are detected using monitoring the current on first action. Only the shutters have to be wired that all go in same direction on same polarity.

The code is super easy and just one little piece of python which covers all. No messing around with hardcoding shutter timings etc.

Samstag, 28. März 2015

Logging the UVR 1611


Tags: UVR 1611, BL-Net, blnet, python, logging, Technische Alternative, Raspberry, Beaglebone, UVR 16x2

I wrote that i have many of them and checking outside if the programmed control loops work as expected is important for me. So i was digesting another piece of code i found on the net called dlogg (http://d-logg-linux.roemix.de/index.php?article_id=7) and put it into python for some fun.

That code talks to a BL-NET - basically a device bridging the CAN bus of the UVR and Ethernet.

Each UVR 1611 is able to provide two frames to log on the blnet. The blnet can log up to 8 frames. The code checks how many frames it can grab and then gets them in sequence. All is concatenated together and put into a protocol buffer.

And this is what i am going to do with it.

Give me a week to continue reporting on this. Back in mid April 2015.

Freitag, 27. März 2015

good tools - good fun

I was quite inactive on this blog and it just reminded me when i was working on my staircase there the blog name comes from.

In the meantime we worked literally down a couple of tools and the cheap pieces are not worth the money. Swabians say the don't have enough money for cheap things. That was true for a lot of things we worked down or they declared being out of order before being worked down.

Since we do lot of things on our own u need to rely on your tools. Without any regret i can tell that the ones i have are worth the money. I will never give back my Mafells, Feins, Duss, Hilti. Not cheap but worth bargaining for ;-). Same on house installation, pipes and controlling all this - Technische Alternative UVR1611 - always.

I operate 8 of those at different locations and have one spare (never needed so far). One new UVR 16x2 is also there. But in case i need the spare, change personality in 5 minutes for the scenario they are used in and then continue operation.

So far i have one exception to my rule. This is an Aldi Dreieckschleifer - maybe even a clone of a real brand. That one gives its best to stay with me.

Next: More on the TA UVR1611 and data logging

How to use rollo.py

Finally there is the current python code to control the shutters. It works like this:
  • define additional shutters if you need in the main section. E.g. r4=Rollo(4) where 4 is the id of the relais. Note that relais with id 0 and 1 is already in use by the polarity changer.
  • run as sudo python rollo.py: i havent set a user permission to use I2C other than root. So this is for I2C/SPI device access.
  • The four switches on the piface board have handlers on them. Button 0 is for all shutters up, 1 for all down, 2 for all to half and button 3 to switch all outputs to 0. To stop ongoing actions button 3 might be pressed multiple times (a TODO so to say)
On first use the shutters are not calibrated. On first use each shutter moves up and down once to take the time to open and close the shutter. When this is done, the actual request is served. For all the shutters the same action is performed (up/down/half).
Because every shutter is calibrated individually you can run shutters with different length and close times.
The INA 219 is really a very helpful vehicle for this. I haven't expected this.

It works pretty ok but for making it perfect i guess the current has to act as another switch off criteria, nut just for detecting strange situations. Also it needs to connect to an AMQP exchange to be controlled from outside as well.

Have fun and report your experience or ideas to make it better.

rollo.py

Here the code. In the meantime i put it on github. So much more convenient.

https://github.com/staircaseblog/rollo

This is what you are most likely interested in:
https://github.com/staircaseblog/rollo/blob/master/rollo.py


If you are interested in current a Velux shutters draws have a look into this. All measurements in seconds and mA.

https://github.com/staircaseblog/rollo/blob/master/current.txt

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




Setzstufen

While the steps are solid oak, the step riser/ Setzstufen are covered with some nasty glue which does not want to go off. We decided to do them in white and put a thin layer of white coated wood/MDF on them. We found such material. The backside of our swedish cupboards we kicked out had such material...