Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unstable operations #6

Open
avbdr opened this issue Aug 4, 2022 · 6 comments
Open

unstable operations #6

avbdr opened this issue Aug 4, 2022 · 6 comments

Comments

@avbdr
Copy link

avbdr commented Aug 4, 2022

Thank you very much for your efforts with this project. I have built an esphome wrapper around your library and so far everything is working great as long as you are controlling single blind.
I have 5 blinds which i have to control at the same time so to do that im sending commands to them one after another. From the most it is working fine but im getting bunch of missed commands by the 2nd or a 3rd (pretty much always the second one) blind.
currently your sendAOKCommand and setndTribit() functions are unchanged
I have added a 600ms delay after each command execution which significantly improved missed commands rate.
Do you have any suggestions what I can change to get more reliable operation?

Blinds are operating with 6 different remotes with different serials without channels usage, there is no way to control all of the with a single command unfortunately. But if there will be no other option -- seems I would need to reprogram the shades to use same serial and different channels

Thank you

@avbdr
Copy link
Author

avbdr commented Aug 4, 2022

btw, initially i were blaming my cheap transmitter, but yesterday I have tried with STX882 transmitter and ended up with the same issue.

@akirjavainen
Copy link
Owner

akirjavainen commented Aug 4, 2022

Thank you for your comments! My best guess is that the transmitter is falling behind and cannot maintain steady timing with so many commands being sent.

You could try reducing the amount of repetitions per command (REPEAT_COMMAND) but if you ask me, I would program an additional remote to control all of the blinds at once - with a single command. This way the blinds would also operate at the same time (looking much more impressive when showing them off ;) ).

Typically this is done by first pressing the "program" button from the blinds and then "up" from the new remote. Blinds can have several remotes paired with them.

@avbdr
Copy link
Author

avbdr commented Aug 4, 2022

@akirjavainen in reverse, increasing repeats to 10 seems making things much better. At least I have tested 10 cycles and its working 100% of times now. Thanks for the hint :) Its funny but there is even a comment saying that for a single remote control its better to use 10 repetitions. Intrestingly, that I have tested removing a 600ms delay between the calls -- and things started to work very bad. So the best combination for me now 10 repetitions + 600ms delay between sending commands.

Re single remote control, I see a java code to generate commands here from serial number, maybe you are aware of this code
written on C? Im not very good with bit operations, it will take me a while to rewrite it :)

Ill update you tomorrow of how the change will work. Thank you for your help

@akirjavainen
Copy link
Owner

akirjavainen commented Aug 4, 2022

Ironically, that may in fact happen for the very same reason: some commands fail (inaccurate timing at the transmitter, for whatever reason), so more repetitions "fixes" it because some of them have the correct timing. :)

There is a caveat that one should be aware of, regarding transmitting multiple commands quickly like this, especially if you add more than 10 repetitions and/or try to make the radio silence between them shorter. In some cases, the motors could interpret a command as another. The commands do contain a kind of checksum, but long presses on some of the remote buttons (like "stop") have another function on the motor. I did have a motor rotation direction inverted once and there was a possibility of actual physical damage to the blinds, as limits were no longer respected and the script was running scheduled (often unattended).

This happened after I ran that daily script for over a year and it transmitted 3 command sequences (up or down to 3 blinds) in a quick sequence. This is another reason why I recommend adding an extra remote (virtual or physical) to all of the motors, to control them with a single command. It's less "radio noise" on the 433MHz frequency.

I haven't seen the Java code you mentioned but I'll definitely take a look when I have the chance!

@avbdr
Copy link
Author

avbdr commented Aug 4, 2022

i got you. Im working on the virtual remote development now. the only thing which is missing is a crc calculation.
The java code i been mentioning is from #1 by @vonnieda to generate sequences
for the sonoff. Im reusing it to build the commands sequences. Ill post later on the full code.

#include <stdio.h>
#include <string.h>

#define COMMAND_DOWN                        "01000011"                // Remote button DOWN
#define COMMAND_UP                          "00001011"                // Remote button UP
#define COMMAND_STOP                        "00100011"                // Remote button STOP
#define COMMAND_PAIR                        "01010011"                // Remote button C
#define COMMAND_CHANGE_ROTATION_DIRECTION   "01010000"                // Remote buttons STOP + L
#define DEFAULT_HEADER                      "10100011"
#define DEFAULT_CRC                         "00000000"
#define AOK_COMMAND_BIT_ARRAY_SIZE       65    // Command bit count

// 10100011 000000001000101110001101 00000100000000000 1000011 010111111

void errorLog (char* msg) {
  printf ("%s", msg);
}

const char* calcAokCrc(char* remote_id, char * remote_channel, char* command) {
  char crc[8]
  int i = 7;
  /*
          (10100011) 00000000 10001011 10001101 00000100 00000000 01000011 01011111 (1)
                       0         139      141     4         0       67     351 = (1)01011111
  */
  crc[]
}

const char* genAokCommand(char* remote_id, char * remote_channel, char* command) {

  if (strlen(remote_id) != 24) {
    errorLog("sendShortMarkisolCommand(): Correct remote ID length is 16 bits. Cannot continue.");
    return NULL;
  }
  if (strlen(command) != 8) {
    errorLog("sendShortMarkisolCommand(): Correct command length is 4 bits. Cannot continue.");
    return NULL;
  }

  // Let's form and transmit the full command:
  char full_command[AOK_COMMAND_BIT_ARRAY_SIZE];

  full_command[0] = '\0';
  strcat(full_command, DEFAULT_HEADER);
  strcat(full_command, remote_id);
  strcat(full_command, remote_channel);
  strcat(full_command, command);
  strcat(full_command, DEFAULT_CRC);
  strcat(full_command, "1");

  return strdup(full_command);
}


int main(void) {
    printf("%s", genAokCommand ("000000001000101110001101", "0000010000000000", COMMAND_DOWN));
    return 0;
}

@avbdr
Copy link
Author

avbdr commented Aug 5, 2022

closing issue as done. I will open later on a pull request with a command generator. I finally managed to do that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants