Activity Forums Questions & Troubleshooting Questions about interruptions on Controllino mini before buying it

  • Questions about interruptions on Controllino mini before buying it

     Lukas updated 1 year ago 3 Members · 4 Posts
  • Math

    Member
    June 7, 2021 at 9:39 am

    Hi, I’m working on a little project in order to manage the switch between 2 battery systems on a boat. I have to take the controllino mini but I wanted to know if it can manage 2 interruptions ( even if 2 pins are made for that ).

    Could someone simulate this code with the Controllino before I buy the card because I’m note sure of myself.

    Thanks a lot in advance.

    #include <Controllino.h>

    void ICACHE_RAM_ATTR Perte_Tension();
    void ICACHE_RAM_ATTR Retrouve_Tension();
    void ICACHE_RAM_ATTR Detection_Alarme();
    void ICACHE_RAM_ATTR Coupure_Alarme();

    // code pour l'alternance entre batteries système et batterie de secours
    boolean ERS=false; // false si on est sur le système général, true sur le secours
    int ORS = CONTROLLINO_D0; // Output Relais Shield
    int FSPB = CONTROLLINO_IN0; // Tension Sortie batterie système
    int A_relais= CONTROLLINO_IN1; // Détection signal d'alarme

    void setup() {
    // put your setup code here, to run once:
    Serial.begin(9600);
    pinMode(ORS, OUTPUT);
    pinMode(FSPB, INPUT);
    pinMode(A_relais, INPUT);
    Serial.println("Setup"); //initialisation
    attachInterrupt(FSPB, Perte_Tension, FALLING); //Front descendant détecté sur tension batterie
    attachInterrupt(FSPB,Retrouve_Tension , RISING); //Front montant détecté sur tension batterie
    attachInterrupt(A_relais,Detection_Alarme , RISING); //Front montant détecté sur alarme
    attachInterrupt(A_relais,Coupure_Alarme , FALLING); //Front descenadant détecté sur alarme
    }
    void loop() {
    // put your main code here, to run repeatedly:
    }
    void Perte_Tension() {
    Serial.println("Perte tension"); // perte tension sans signal alarme
    if (ERS == false) // on est sur le général
    {
    digitalWrite(ORS, HIGH); // passage sur le secours
    digitalRead(ORS);
    ERS = true;
    Serial.println("Cas 0, perte batterie sans alarme");
    }
    }
    void Retrouve_Tension(){
    Serial.println("Tension retrouvée");
    if (ERS == true) //sur le secours
    {
    digitalWrite(ORS, LOW); // passage sur le général
    digitalRead(ORS);
    ERS = false;
    Serial.println("Cas 1, tension retrouvée");
    }
    }
    void Detection_Alarme() {
    Serial.println("Alarme ON");
    if (ERS== false){//on est sur le général
    digitalWrite(ORS, HIGH);// passage sur le secours
    digitalRead(ORS);
    ERS = true;
    Serial.println("Cas 2,allumage de l'alarme");
    }
    }
    // l'alarme se coupe au bout d'un certain temps même sans retrouver la tension du système
    void Coupure_Alarme() {
    Serial.println("Alarme OFF");
    if (analogRead(CONTROLLINO_A0)>500 && ERS== true)// coupure alarme car la tension système est retrouvée
    {
    digitalWrite(ORS, LOW); // passage sur le système général
    digitalRead(ORS);
    ERS = false;
    Serial.println("Cas 3,coupure alarme extinction batterie secours");
    }
    else if (ERS== false)
    {
    digitalWrite(ORS, HIGH);
    digitalRead(ORS);
    ERS= true;
    Serial.println("Cas 3,coupure alarme toujours sur batterie secours");
    }
    }
  • pbro

    Member
    June 8, 2021 at 10:51 pm

    M. Math, the Mini can handle two external interrupts with no problem. I am not sure what the maximum frequency is, but we have interrupts at about 200Hz on Int0, and 50Hz on Int1.

    What may cause problems is noise. Noisey input is common, although if you are testing battery voltage, that might not have noise. If you can, look at the input on an oscilloscope. Good luck…

    • Math

      Member
      June 9, 2021 at 8:47 am

      Thanks a lot for your answer, I’ll test it with the oscilloscope.

      Finally, we have chosen the Maxi. Do you know if the maximum frequencies are the same ?

      • Lukas

        Member
        June 15, 2021 at 10:21 am

        Hi Math,

        I assume that the frequency will be limited by the ESD protection at the inputs. MINI and MAXI are the same from this point of view. It should be fast enough for your purpose.

        Let us know about the results!

        Thanks,

        Lukas

Viewing 1 - 2 of 2 replies

Log in to reply.

Original Post
0 of 0 posts June 2018
Now