Menu

Home Heating Automation - Getting Started (a few Questions from a true Rookie)

Anonymous
2019-12-17
2020-01-01
  • Anonymous

    Anonymous - 2019-12-17

    Hello Stefan,

    I was amazed by your ScriptCommunicator (SC), I do like the concept and the flexibility the environment offers. (Being familiar with C/C++ makes the scripts still readable for me.) I am considering using the SC for a small home heating automation project my son and I wanted to do (i.e. start) for fun over Christmas holidays. In the first instance (which we should hopefully complete over Christmas), we would like to have measured temperatures (i.e. process variables) visualised on a system diagram drawing and logged into a file (all on a Windows PC). Later on, some kind of Web visualisation with a possibility to change controller parameters should be implemented (running 24/7 on a Raspberry Pi or similar).

    Looking for an effective way to achieve first goal (temperatures being displayed on a system diagram + datalogging), I got an impression that SC would be exactly the right tool for the job. I understand that later on (i.e. for a Web server running on an embedded system) we later might need to move on to FHEM or similar purpose built environment.

    Let me shortly describe the hardware environment:
    An oil powered heater (i.e. a boiler) and a mixer (for floor heating) are controlled by a Kieback & Peter HRP 20 controller. The controller has RS232 connection and the communication protocol is known to me. Using the protocol process variables can be read and controller parameters can be set. I am able to communicate with the controller using a terminal program.

    The protocol:
    To initiate communication, the following message is to be sent to the controller:
    <stx>G0 0000 Terminalprog.__ 128 0 1.04 A 0.0.0 2 KPT001<cr><etx>D270
    where:
    <stx>, <cr>, <etx> etc. are representing by their ASCII byte equivalents:
    "D270" is the checksum calculated using CRC-CCITT (XModem).</etx></cr></stx>
    </etx></cr></stx>

    The controller acknowledges received line with:
    <syn>< ACK>
    and replies with:
    G0 0000 Ich_bin_ein_HRP 81 1 3.67GB 0 16 1 HRP001<cr><etx>852E
    (852E is again the checksum)
    </etx></cr></syn>

    Each controller reply line has to be acknowledged by <syn>< ACK>. (Failing to acknowledge controller reply causes the controller to repeat the last line sent, up to a total of 5 lines, after which the communication needs to be reinitialised).</syn>

    The controller replies to queries sent. Additionally, each minute, the controller sends current date & time (this needs to be acknowledged, as well, by a <syn><ack> pair).</ack></syn>

    The queries have the following structure:
    <stx><cr><etx><xmodem sum="" check="">
    An example command to read the boiler supply temperature looks like this:
    p0 16 b6
    with:
    16 - being the controller address, and
    b6 - being the address where the mentioned temperature is stored.
    The full query, accordingly:
    <stx>p0 16 b6<cr><etx>3EED</etx></cr></stx>
    </xmodem></etx></cr></stx>

    The controller replies with:
    <syn><ack>
    <stx>p1 16 b6 55.2 108 08 00 Boiler supply<cr><etx>9445
    55.2 is the temperature (in deg C).
    etc
    </etx></cr></stx></ack></syn>

    I am trying to figure out how to start with the worker and GUI part.

    The worker thread would have the following tasks:
    1. Initialise the communication (one time)
    2. In a time loop (e.g. every minute):
    2.a Build and send queries to the controller
    2.b Parse received replies, attempt to reinitialise communication, should the controller fail to reply to a query
    2.c Acknowledge each reply line with <syn><ack>
    2.d Store parsed values in a file
    3. Acknowledge each time information line with <syn><ack> (asynchroniously)</ack></syn></ack></syn>

    The GUI thread:
    1. Load and display system drawing picture (initially)
    2. Print current temperatures when new values are received through the worker thread

    I would need your advice:
    1. Would SC be your environment of choice for the application? If yes:
    2. How should we start, could you suggest/provide a template?
    3. What would be the most practical way to calculate XModem checksum_

    Best regards,
    Nikola

     
  • Anonymous

    Anonymous - 2019-12-17

    I am attaching my post as a text file, as the smart formatting for (closing) tags messed it up a bit. Sorry for the inconvenience caused.

    Regards,
    Nikola

     
  • Stefan Zieker

    Stefan Zieker - 2019-12-17

    Hi Nikola,

    1.) Yes, I developed ScriptCommunicator for those type of 'small' projects.
    But you don't need an extra GUI Thread. Every GUI element runs in the main thread (every WorkerScript runs in his own thread).
    But if you want two threads this would be not a problem because ScriptCommunator starts every Worker Script in a separate Thread and has a Inter Worker Script Communication functionality.
    2.) You should have a look at the manual and the example Worker Scripts first.
    3.) I'm not sure but I think the xModem checksum is a CRC16 (ScriptCommunicator has a build in function to calculate a CRC16). If not then you have to implement this by yourself.

    Regards,
    Stefan

     
  • Stefan Zieker

    Stefan Zieker - 2019-12-17

    Hi Nikola,

    I read your post again. Do you want to execute your program on a Raspery Pi (I never tried to run ScriptCommunicator on a Raspery Pi)?

     
  • Anonymous

    Anonymous - 2019-12-17

    Hi Stefan,
    Thanks for your reply. I agree, I need to understand the basics first. What makes the task somewhat (too) complicated for me, as a total newbie, is having a bit challenging communication protocol, with multiple types of events to react to .

    Of course, your confirmation that it can be achieved with the ScriptCommander is a great help. Given the protocol and the "project" description, do you have a suggestion which scripts in the examples would be the most useful?

    Regarding your last question about the target system:
    During the first stage, the script will be executed on a Windows PC (to keep the things as simple as possible). At a later stage, we will try to have the script running on a Raspberry Pi. But even if that doesn't work, having a Windows only visualisation would be more than satisfactory.

    Best regards,
    Nikola

     
  • Stefan Zieker

    Stefan Zieker - 2019-12-17

    Hi Nikola,

    you can find two scripts in exampleScripts\WorkerScripts\CyclicSendReceive. Here you have a simple GUI, a timer (for cyclic execution) and sending/receiving of data with the main interface (you can create separate interfaces in a script too).
    To test them you must execute both scripts in two separate instances of ScriptCommunicator and connect them (e.g. via UDP).

    PS: ScriptCommunicator has a command line mode where you only see the script GUI.

    Regards
    Stefan

     

    Last edit: Stefan Zieker 2019-12-17
  • Anonymous

    Anonymous - 2019-12-24

    Hello Stefan,
    I wanted to report a first success, we are now able to communicate with the controller through ScriptCommunicator. The examples you suggested were spot on, everything needed was there, thanks a lot!

    I have a few questions:
    1. Is it possible to left align the plot legend? Some Qt examples I found online do it over axisRect: yourPlot->axisRect()->insetLayout()->setInsetAlignment(0, Qt::AlignLeft|Qt::AlignTop); But I could not find a way to get the Plot object exposed in such a way to access the axisRect function.
    2. Could axis values be custom text instead of numbers? For our example, it would be most convenient to have x-axis display date and time.

    Best regards with best Christmas wishes,
    Nikola`

     
  • Anonymous

    Anonymous - 2019-12-26

    One more question:
    3. What is the most efficient way to create and send a HTTP POST request (asynchronously) from a worker script? I am currently misusing UI_webView with a handcrafted HTML page with a form submit struct... Neither clean nor optimal.

     
  • Stefan Zieker

    Stefan Zieker - 2020-01-01

    Hi Nikola,

    sorry for my late response, I was not at home and had no access to a PC the last days.

    1. No
    2. you can use the function showDateTimeAtXAxis for that
    3. I would create a socket and created the needed data by myself

    Regards,
    Stefan

     

    Last edit: Stefan Zieker 2020-01-01

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.