lucadentella / BoosterBoard

9 stars 2 forks source link

Shortcircuit is to fast #2

Closed Knitterpitti closed 1 year ago

Knitterpitti commented 1 year ago

Hello Luca, at first i will thank you for this great Project.

I have build the Boosterboard it runs fine with a DCC++ Arduino Central and Rocrail. But i use two sweeping loop´s with DR 5013 Modules. https://www.manualslib.com/manual/1512127/Digikeijs-Dr5013-Digireverse.html#manual Now my Problem: The Shortcircuit detection from the booster is faster then the Modules can switch the Polarisation.

Can you insert a delay witch stop the Booster after a half Second after the short circuit! Not directly after detection!

My Central Station DR5000 is going to shortcircuit after 100 miliseconds this runs great with the sweeping loop´s.

Thank you for your Time,

Greatings Sebastian Kuhnert (Knitterpitti)

lucadentella commented 1 year ago

Hi Sebastian

I'm not going to change the normal behavior of the booster because it's important to detect a short circuit as soon as it happens.

Anyway I'm aware that some loop modules do require some ms to activate. You can alter the code that detects short circuits, starting from line:

https://github.com/lucadentella/BoosterBoard/blob/06c8bd1694cb7f5fff553e723a42c103eaa35553/firmware/BoosterBoard-10.ino#L124

at the moment I get only one sample and if it's greater than 1000, activate the short circuit protection. You can add here a delay and check again: only if after 100-200ms the read value is still high, trigger the protection.

Let me know if it works, I won't include it in the "main" source code because I think that most of the users will prefer a fast protection if they don't use any loop modules.

Knitterpitti commented 1 year ago

Hello Luca, okay so i will try it. i create a new line after 124 and wrote / delay(300) no function...

than i test this if(sample > 1000) delay(300); { than i become directly a short cut warning

lucadentella commented 1 year ago

you should check after 200-300ms the value:

int sample = analogRead(BOOSTER_CURRENT_PIN); if(sample > 1000) { delay(200); sample = analogRead(BOOSTER_CURRENT_PIN); if(sample > 1000) { currentWorkingMode = W_ALERT_SHORT; boosterOff(); Serial.println("Booster OFF due to a short circuit"); return; }