I'm using a ESP32C6 to capture the data sent by my em150 Votol controller but i'm having some issues:
- its not super stable and since the CRC is very basic i sometime have bad data with a correct CRC
- the data specified in the vendor documentation does not seem to be correct (drawings certainly are not).
I took some capture with a logic analyzer and the bit value is 0 for a duty cycle lower than 50% and 1 for a duty cycle greater than 50%. The start symbol has a duty cycle lower than 1%. I have modified the code to be the following which works for me.
C:
int8_t bitIndex = -1;
bool wait_reset = true;
void IRAM_ATTR sifChange() {
int val = digitalRead(SIF_PIN);
unsigned long now = micros();
unsigned long duration = now - lastTime;
lastTime = now;
if (val == LOW) {
if (lastDuration > 0) {
bool bitComplete = false;
float duty_cycle = float(duration) / (float(duration + lastDuration));
if (duty_cycle < 0.1) {
bitIndex = 0; //Reset condition
wait_reset = false;
} else if (duty_cycle < 0.45 && !wait_reset) {
// bit value 0
bitClear(data[bitIndex / 8], 7 - (bitIndex % 8));
bitComplete = true;
} else if (duty_cycle > 0.55 && !wait_reset) {
// bit value 1
bitSet(data[bitIndex / 8], 7 - (bitIndex % 8));
bitComplete = true;
}
if (bitComplete) {
bitIndex++;
if (bitIndex >= 96) {
decode_frame(&votol_state);
bitIndex = 0;
wait_reset = true;
}
}
}
}
lastDuration = duration;
}
I'm still trying to figure out which bit indicates reverse since the documentation does not seem to be correct.