Mittwoch, 8. März 2017

UVR 16x2

Ich habe vorübergehend eine UVR 16x2 im Haus. Diese scheint aber andere Objekt_IDs zu verwenden so dass der Code von der 1611 hier nicht anwendbar ist.

Das Gerät macht einen guten Eindruck. Ich muss allerdings zugeben, dass ich mich an das Scrollrad schon sehr gewöhnt habe. Interessanterweise konnte mein betagter BL-Net mit dem neuen Controller gar nichts anfangen.

Hierzu in Kürze mehr.

TA UVR 1611 Daten Logging über CAN auf github



Es gab so viele Anfragen den CAN code für die UVR zu veröffentlichen. Schlussendlich habe ich die CAN Teile herausisoliert um es handlicher und übersichtlicher zu gestalten. Ich hatte mit CAN einen steinigen Weg. Daher kam die Eleganz des Codes zu kurz. Zudem wurde einiges gelernt. Es ist nicht alles in den Code eingeflossen.

Trotz des holprigen Anfangs läuft es nun ganz rund und ist in Bezug auf die Usability einem CMI oder BL-Ansatz überlegen.

CAN H und CAN L angeschlossen und schon liegen die Istdaten dem Anwender zu Füssen.

Ich wünsche viel Spass

https://github.com/staircaseblog/UVR_CAN

TA UVR1611 CAN Data Logging Code on github

I got so many requests to publish code to communicate with the UVR1611 via CAN that i took some time to isolate just this piece to make it easier to share.

When i wrote this stuff i needed to learn about CANOpen without proper documentation. The pros out there might find some quirks. The initial fights with getting the CAN stuff going consumed the most time. Elegance fall short.

Why CAN and not BL-NET or CMI? Those devices do their job well, but doing web based logging is not user friendly or robust.

Check this out:

https://github.com/staircaseblog/UVR_CAN


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;
}