Montag, 30. Januar 2017

It runs like a charm

Not just the setup with the device overlay got dead simple. Also the CAN interface looks much more reliable than with previous RPI distributions. That is perfect.

Everybody has a spare PI somewhere. Get the MCP2515_CAN Module and a 7 pole cable to get ir CAN ready.

pi@rpicanlog:~ $ ifconfig -a
can0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 
          UP RUNNING NOARP  MTU:16  Metric:1
          RX packets:153196 errors:0 dropped:6 overruns:0 frame:0
          TX packets:81423 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:10
          RX bytes:841370 (821.6 KiB)  TX bytes:651349 (636.0 KiB)

Freitag, 27. Januar 2017

CAN Logging of the Technische Alternative UVR 1611

I ve done some CAN logging with the house control system TA UVR 1611. I am using those in my house and in the house of my friends.
We are all pretty satisfied with this controller. It gives us a maximum of control and convenience. With some logging and graphing you can plan your next energetic renovation at the place where the money is most effective.

I went through a couple of pain with getting the logging going. I started with Raspberrys and SKpang modules and ones from industrialberry. The problem was that after some time the can interface got frozen regularly. I was able to replicate this behaviour and investigated in the software - but finally gave up on this.
Also the setup was complicated. After that i switched to Beaglebones and a Serial CAN Cape. That worked instantly.

Recently i came across this https://harrisonsand.com/can-on-the-raspberry-pi/  and i was surprised about the simple setup.
Currently i am giving that a try. With the latest raspberry distribution i got it working. Note that there is just a little change compared to the referenced article. The naming in the overlay framework  may be changed so if it does not work in your case remove the "-overlay" text.

The following worked for me with the cheap 2$ MCP2512_CAN module from ebay. Check the oscillator on the module. skpang modules run at 16MHz, my cheap ebay module on 8MHz.

Put this in /boot/config.txt

dtparam=spi=on
dtoverlay=mcp2515-can0,oscillator=8000000,interrupt=25 
dtoverlay=spi-bcm2835
I was surprised. After reboot i had the can0 interface.

I will report if i can still see the freezing interface.

Install candump as in the link above and connect it using two wires to the UVR1611. The CAN bus needs termination. I tried without first but i had no luck. Dont be surprised if the bus is quite when you dont have termination resistors of 120 Ohm.

Set the bitrate on 50000. This is the default the UVR1611 comes with. So far i can warmly recommend this CAN setup.

Soon more on using libcanopen to squeeze out interesting information.

pi@rpicanlog:~/wyh_client/readViaCAN $ ./readViaCan can0 0x02 bezeichnung

{
 "eingang" : 1,
 "bezeichnung": "_Kollektor_",
 "einheit": "unbekannt"
},
{
 "eingang" : 2,
 "bezeichnung": "_Warmwasser1_",
 "einheit": "unbekannt"
},
{
 "eingang" : 3,
 "bezeichnung": "_Warmwasser2_",
 "einheit": "unbekannt"
},
{
 "eingang" : 4,
 "bezeichnung": "_SP.unten1_",
 "einheit": "unbekannt"
},
{
 "eingang" : 5,
 "bezeichnung": "_SP.unten2_",
 "einheit": "unbekannt"
}, .....

pi@rpicanlog:~/wyh_client/readViaCAN $ ./readViaCan can0 0x02 werte
{
 "zeit": 27.1.2017 16:17
},{
 "A3": "true"
}
,{
 "A4": "true"
}

{
 "eingang" : 0,
 "wert": 18.9,
 "einheit": "C"
},
{
 "eingang" : 1,
 "wert": 238.7,
 "einheit": "C"
}, ......