Freitag, 24. Februar 2017

Alpha Testers for UVR Data Logger

I sent out a couple of CAN loggers today for some alpha testers. This model does not scale well, but for those interested i might prepare some ready to run sd-cards for a fair amount.
Sources might be included.

UVR 16x2

I get a UVR16x2 next week. Development for the new controller starts soon.

Montag, 20. Februar 2017

IndustrialBerry CAN Module

I found in my box CAN modules from IndustrialBerry. As mentioned in a previous post, i had a vendetta with the CAN stack based on MCP2515. At that time i had freezing connections every couple of hours. So i put the modules in one of the boxes you put things in you don't know excactly what to do.

I copied the SD card of a can logger and adjusted just a single thing, the frequency of the oscillator. The PiCAN and the IndustrialBerry i had so far run with 16 MHz. The 2$ ebay modules run with 8 MHz. The interrupt stayed the same.

dtparam=spi=on

# CAN Parameter
dtparam=spi=on
dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25 
dtoverlay=spi-bcm2835

Just to make sure once more. The setup is just taking the latest Raspian image and adjusting the content in /boot/config.txt as shown above - very easy.

The IndustrialBerry module is a Pi Hat sitting properly on the Pi. This it is much more organized than the loose cabling of the 2$ modules. Second benefit, the Pi and a CAN module fit in most Pi cases due to their standard Hat size.

The latest install instruction on IndustrialBerry is in line with the setup procedure showed here using dtoverlay.

I got my module a while ago from this site.
http://www.industrialberry.com/

Sonntag, 19. Februar 2017

CAN Code Part I

Lets look into some parts of the code. I dont know how many parts this will be :-) Lets do it pragmatically so not a lot of CAN background before. The function is about detecting if a certain node on the CAN bus is a UVR 1611 controller. Three parameters are downloaded from a potential 1611 controller. Vendor, product and version. If those three match than the function returns 1611 (int). If any of the three mycanopen_sdo_upload_exp functions fail, the last comparison fails as well.

Note that the verbindungsAufbau and verbindungsAbbau is crucial. The verbindungsAufbau function uses the CAN node id you configured your controller. The function returns a temporary node ID this controller is listening to. The cob_id is a temporary alias for this controller which is required to access its object dictionary. The object dictionary is accessed using the mycanopen_sdo_upload_exp function. After accessing the object dictionary this alias is released.



//public
int Uvr_Can::isUVR_c(int to_node_id) { 

    boost::mutex::scoped_lock lock(can_if_mtx_);

    uint32_t vendor = 0, product = 0, version = 0, identifier = 0;
    int ret = 0, cob_id = 0;

    //cob_id = verbindungsAufbau(sock_, self_node_id_, to_node_id);
    cob_id = this->verbindungsAufbau_c(to_node_id);

    mycanopen_sdo_upload_exp(sock_, cob_id, 0x1018, 0x01, &vendor);
    mycanopen_sdo_upload_exp(sock_, cob_id, 0x1018, 0x02, &product);
    mycanopen_sdo_upload_exp(sock_, cob_id, 0x1018, 0x03, &version);

    mycanopen_sdo_upload_exp(sock_, cob_id, 0x23e2, 0x01, &identifier);

    verbindungsAbbau(sock_, self_node_id_, to_node_id);

    if(vendor == 0x000000CB && product == 0x0000100B && identifier == 128) ret = 1611;

    return ret;
}

Component Overview of Web based logging

The setup is very similar to an IoT architecture. Remote devices are PIs with CAN interfaces. They collect and forward measurements to a concentrator. This is a one way route by intent. The protocol used is AMQP. Multiple sinks are connected to the  AMQP source. A monetdb database used for handling DB request from the node.js application server. Another sink is the range checker which runs independent from the DB. Another stream goes to a development system. Here an Apache Spark system is attached. There was already a function to calculate the correlation between sensors and outputs to detect unwanted hydraulic dependencies. This function moves out of being served of the in-memory monetdb into Apache Spark.

There are thoughts to move to Amazon AWS IoT framework and service for store & forward. Compelling is the device handling and the simplicity of the service.


Ranges and Alarming of UVR Web Logging

For those who already visited www.uhvauerr.de and used demo/demo to see a sample UVR 1611 controller and its live data may have discovered a "Messages" Tab. Here events will go in which should be raised to the owner.
In the previous post you see that you can adjust the color in the diagram and switch on range checking. The output of range checking will go into messages tab. I 've set up an account with sipgate to send SMS messages programatically. A few lines of code glue needs to go into to have it working for all users.


Dienstag, 7. Februar 2017

Descriptions of Inputs/Outputs

 There is one peculiar thing i haven't found out yet.

You can attach the in-out sensor and actor names of the UVR 1611. When you traverse the structure for the lets say the input sensor 1 there is a reference to a text field which belongs to sensor 1 and is the user given name. The thing is that when i read this string it looks _ (underscore) take the role of a space. In the web based logging a user can overwrite the sensor name if he likes. But the name reported is still available when opening the dialog to Adjust Sensors

For the time being i can live with that.


This is part of the data structure i maintain for a system. In the image below you see a setup where two UVR 1611 are logged in a single view. The naming and the allowed threshold are maintained for the entire system (where a system refers to everything what can be logged on this CAN bus)

{"aktiv":0,"variablen":[{"roh":"Pumpe-Solar1_","key":"2_1_a1","name":"Kollektor 1 Pumpe","range":[0,0],"allowed_range": [30,40], "rangewarning_active":true,"color":"#ff9900"},{"roh":"Ladep.SP._","key":"2_1_a2","name":"Ladepumpe","range":[0,0],"allowed_range":[30,40],"rangewarning_active":false,

Plug and play character of UVR 1611 CAN Logging

I was asked what it takes to get CAN logging running. Note that i had a logging using bl-net running for some time. I installed that at my brother in law but messing with ip-addresses behind a firewalled network is not among the things i like to do. Thanks to CMI there is a convenient shortcut.

Less is more and i was happy about each component and each thing which has not to be configured to address reliability and a good user-experience.

So what does it take to wire up a CAN logger? Here is a quick ingredient list:
  • Raspberry Pi (all Pi's tried apart from RPi Zero)
  • 7 pole female-female jumper cable
  • MCP2515_CAN Module 
  • Power Supply
  • 8GB uSD card
  • Everything else is optional
My CAN client code lives in a hosted git archive. The code is comprised of some python and some C++ helpers for CAN sniffing and querying the controllers. Installing this by hand isn't actually in line with my expectation on simplicity. There are a couple of libraries used such as rScada libcanopen. Then python archives as well as utils have to be installed first before compiling.

I think in a first run there will be a complete image file including the distribution. So download an image, copy it on SD, plug in and run.

The recipe would then just to put the components together, attach it to ethernet, CAN_H and CAN_L and thats it.

Comments welcome

Freitag, 3. Februar 2017

Web based logging of TA UVR 1611

I run a couple of TA UVR 1611 controllers. In the house of a family member it is installed to do logging and run the solar system. I installed one at this place because the heat pump system does not work very reliably and putting pressure on the one who installed it works so much easier if you have it documented. As time comes, the controller will take over further responsibilities, e.g. solar.

In the house of my father i take care of the heating but i am not onsite. I control this system using TA CMI, but i do the logging myself because it is so convenient.

All those UVR 1611 controllers have the CAN Logger attached. The logger pulls every two minutes the data from the controller, packages it and sends it via a messaging protocol to www.uhvauerr.de . Visit this site. It has a demo user to log in to an active system.

There is a service running which makes it easy to inspect the data. Now there is work waiting to be done to create more reports about cumulated time of active pumps, switched on burners etc. to judge the effectiveness of  a renovation.