New Commands: SH2, CS2, CH2

This Forum is about the Opentherm gateway (OTG) from Schelte

Moderator: hvxl

New Commands: SH2, CS2, CH2

Postby rpav » Tue Jan 30, 2018 9:31 am

Hi,
I believe there are a lot of boilers with two (relatively independent) heating circuits. Unfortunately, current version of OTmonitor can't control the second circuit behaviour, however it can show the sate of it properly.
We, the users of dual circuit boilers, will very appreciate if OTmonitor has three new commands:

SH2=temperature
Setpoint for Second Heating Circuit - Set the maximum heating setpoint for 2 circuit. This command is only available with boilers that support this function.
Examples: SH2=72.5, SH2=+20

CS2=temperature
Control Setpoint for Second Heating Circuit - Manipulate the control setpoint of 2 circuit being sent to the boiler. Set to 0 to pass along the value specified by the thermostat.
Example: CS2=45.8, CS2=0

CH2=state
Second Central Heating - Control the second CH enable status bit when overriding the control setpoint. By default the CH2 enable bit is set after a CS2 command with a value other than 0. With the CH2=0 and CH2=1 commands, the bit can be manipulated.
Example: CH2=0, CH2=1

I believe it couldn't be so difficult because all of them are variant of existing commands, that are already in the code.
Unfortunately, I have absolutely no experience of TCL. :( I'm sure I will spend a tons of hours to find the right pieces of code and to modify it to implement commands described.
Schelte, please, will you have time to make a patch that implements it? Please...

Thank you,
Roman
rpav
Starting Member
Starting Member
 
Posts: 26
Joined: November 2015

Re: New Commands: SH2, CS2, CH2

Postby rpav » Tue Jan 30, 2018 10:41 am

Unfortunately, implementing new commands means to modify OTGW, firmware for PIC :oops:

Now I know it is not as easy as I thought. :(

But implementing it, will be still very appreciated :)

Revision of new command proposal:
S2=temperature
Setpoint for Second Heating Circuit - Set the maximum heating setpoint for 2 circuit. This command is only available with boilers that support this function.
Examples: S2=72.5, S2=+20

C2=temperature
Control Setpoint for Second Heating Circuit - Manipulate the control setpoint of 2 circuit being sent to the boiler. Set to 0 to pass along the value specified by the thermostat.
Example: C2=45.8, C2=0

H2=state
Second Central Heating - Control the second CH enable status bit when overriding the control setpoint. By default the H2 enable bit is set after a C2 command with a value other than 0. With the H2=0 and H2=1 commands, the bit can be manipulated.
Example: H2=0, H2=1
rpav
Starting Member
Starting Member
 
Posts: 26
Joined: November 2015

Re: New Commands: SH2, CS2, CH2

Postby rpav » Sat Sep 22, 2018 3:02 pm

Schelte,
is there any chance you will think about implementing these new commands?
Since the code is in assembler, there is not many people which are able to do it quickly.
Thank you for your answer,

Roman
rpav
Starting Member
Starting Member
 
Posts: 26
Joined: November 2015

Re: New Commands: SH2, CS2, CH2

Postby hvxl » Sat Sep 22, 2018 8:33 pm

Oh I thought about it when you brought it up in January. But there's no way it'll fit in the PIC without removing some other features. So, whoever wants to have this will have to decide which existing functionality they can live without, rip that out and add this in its place. I can't do that, because there will always be people using those features.
Schelte
hvxl
Senior Member
Senior Member
 
Posts: 1333
Joined: June 2010

Re: New Commands: SH2, CS2, CH2

Postby rpav » Sun Sep 23, 2018 9:33 am

Thank you very much for the answer.

How big the problem with memory availability is?
Is it possible to implement at least C2(control setpoint) and H2 (enable status)?

If not, what about GB=5. GB=6 and SB (GPIO funtions HOME, AWAY and SetBack temp) commands? Should those be the candidates for substitution? What is the typical user story that use it?

Thank you,
Roman
rpav
Starting Member
Starting Member
 
Posts: 26
Joined: November 2015

Re: New Commands: SH2, CS2, CH2

Postby foobar » Sun Jan 19, 2020 8:35 pm

Hello everyone, Schelte!

I'm in the same situation as Roman. A boiler + thermostat with two circuits, one for the floor heating, one for the radiators.
I would also appreciate having this functionality available.
Could you please explain which parts of the code need to be changed / added? Then I would try to change it myself. Since I am not a professional in assembler, this would be a huge challenge for me without a guide.

Thanks in advance,
Frank
foobar
Starting Member
Starting Member
 
Posts: 2
Joined: January 2020

Re: New Commands: SH2, CS2, CH2

Postby hvxl » Wed Jan 22, 2020 9:21 pm

The trick I used to save space for the command parsing is to make a jump table (SerialCmdTable) based on the XOR of the ASCII code of the two letters of the command. This calculation produces a value between 0 and 31. Once that first selection has been made, only one of the two characters still needs to be checked to know which command was given.

For example, a new 'FB' command would lead to an offset of 4 (70 ^ 66) in the jump table. So this new command would need to be handled by the code at SerialCmd04. There, checks are already in place for commands starting with 'V' (which can only be 'VR') and 'S' ('SW'). Again, XOR instructions are used to save a memory word compared to straight-forward comparisons. So you would add an "xorlw 'S' ^ 'F'" instruction just before the "retlw CommandNG" to check for the 'FB' command.

Hopefully you understand from this explanation that the command can only consist of two letters, otherwise this method will not work. Commands like C2 and H2 are therefor not possible with this scheme.

The OpenTherm messages are handled via the jump table "messagetable". For CH2 you would have to change the "goto FakeResponse" instruction at offset 8 in the table to "goto MessageID8", and provide the appropriate code labeled with MessageID8. Beware that this code will be called for both the request and the response.

To add the CH2 enable bit to the status message, you have to make some modifications to the code at the MessageID0 label.

For more information, read chapter 16 of the PIC16F88 data sheet to understand what each assembly instruction does and study the gateway source code. I have attempted to explain in the comments how things are supposed to work.
Schelte
hvxl
Senior Member
Senior Member
 
Posts: 1333
Joined: June 2010

Re: New Commands: SH2, CS2, CH2

Postby foobar » Tue Jan 28, 2020 12:15 am

Thanks a lot for all the guidance! Will see what I can do. I already understood some parts of it.
Just one basic question: How do I know if the fw with modifications fits to the space of the PIC? You said some functionality which is now existing has to be removed to make it fit. Is it just the size of the image in bytes?
The current gateway.hex is ~23kb. What is the maximum size?

Thanks again!

Best,
Frank
foobar
Starting Member
Starting Member
 
Posts: 2
Joined: January 2020

Re: New Commands: SH2, CS2, CH2

Postby hvxl » Tue Jan 28, 2020 9:12 pm

When building the project, the linker will tell you if it can't fit the code in the selected PIC.

It's not the size of the hex file that is important. The critical measurement is the number of code words. Currently 3916 of the available 4096 words have been used. So there are only 180 left. Also 361 of the available 368 bytes of RAM have already been claimed.
Schelte
hvxl
Senior Member
Senior Member
 
Posts: 1333
Joined: June 2010


Return to Opentherm Gateway Forum

Who is online

Users browsing this forum: No registered users and 1 guest