Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Development
  3. Interruption Vector

Interruption Vector

Scheduled Pinned Locked Moved Development
9 Posts 4 Posters 2.0k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • flylowgofastF Offline
    flylowgofastF Offline
    flylowgofast
    wrote on last edited by
    #1

    Hello all,

    few days ago I sent a post to know if I can adapt my hardware to MySensors. SomeOne explained me that is possible, because there isn't constraint with pin to use. That's right, I already have two nodes which work with temperature and door switch.

    But now I have an issue with a node which runs two triacs. I need AC power synchronization to drive my triacs and I use ISR (INT0_vect) { }, but when I compile the sketche I have : multiple definition of `__vector_1'

    I think it occurs because MySensors use this interruption too ?

    Could you help me ?

    regards

    1 Reply Last reply
    0
    • sundberg84S Offline
      sundberg84S Offline
      sundberg84
      Hardware Contributor
      wrote on last edited by
      #2

      @flylowgofast Post your sketch so we can have a look.

      Controller: Proxmox VM - Home Assistant
      MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
      MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
      RFLink GW - Arduino Mega + RFLink Shield, 433mhz

      1 Reply Last reply
      0
      • flylowgofastF Offline
        flylowgofastF Offline
        flylowgofast
        wrote on last edited by
        #3

        ok, but it's a little bit long, this is the part : ISR(INT0_vect) {

        #include <MySensor.h>  
        #include <SPI.h>
        #include <DallasTemperature.h>
        #include <OneWire.h>
        #include "config.h"           //Définition des constantes pour le projet DomoFab
        
        #define COMPARE_TEMP 1 // Send temperature only if changed? 1 = Yes 0 = No
        
        #define MAX_ATTACHED_DS18B20 1
        unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
        OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
        DallasTemperature sensors(&oneWire); // Pass the oneWire reference to Dallas Temperature.
        MyTransportNRF24 transport(CE, CSN, RF24_PA_LEVEL_GW);
        MySensor gw(transport);// signerRADIO_RX_LED_PIN, RADIO_TX_LED_PIN, RADIO_ERROR_LED_PIN);
        float lastTemperature[MAX_ATTACHED_DS18B20];
        int numSensors=0;
        boolean receivedConfig = false;
        boolean metric = true; 
        // Initialize temperature message
        MyMessage msgTemp(0,V_TEMP);
        MyMessage msgDoor(1,V_STATUS);
        
        uint32_t triacTempo;
        volatile uint8_t triac1 = false;
        volatile uint8_t triac2 = false;
        uint16_t analogUp;
        uint16_t analogDown;
        uint8_t doorOpenState;
        uint8_t doorOpenChange = 99; //pour passer la première fois
        
        unsigned long myTime = 15000; // Pour faire une lecture des valeurs tout de suite
        
        // ???????????????????????????  Who am I ?????????????????????????????????????????????????????????????????????????????????????????????????????????????
         byte role = API2; // première carte avec pro mini capteur de température et capteur de porte
        // ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
        
        // the setup routine runs once when you press reset:
        void setup() {
        
          printf("DomoFab rRF24 API n°: %u start\n\n\r", role);
        
          // initialize the digital pin as an output.
          pinMode(HALL, INPUT);
          pinMode(TRIAC1, OUTPUT); // output pin for OC2B
          pinMode(TRIAC2, OUTPUT); // output pin for OC1B
          pinMode(ZEROCROSS, INPUT); //passage par zéro du réseau INT0
          digitalWrite(UP, HIGH);    //Set pull up resistor
          digitalWrite(DOWN, HIGH);  //Set pull up resistor
        
          EIMSK = (1 << INT0);       //INT 0 enable
          EICRA = (1 << ISC00);      //autoriser n'importe quel changement sur INT0 (D2) à générer une interruption;
        
          printf ("\nConfiguration : API2\n\r");
        
          // Startup up the OneWire library
          sensors.begin();
          // requestTemperatures() will not block current thread
          sensors.setWaitForConversion(false);
        
          // Startup and initialize MySensors library. Set callback for incoming messages. 
          gw.begin();
        
          // Send the sketch version information to the gateway and Controller
          gw.sendSketchInfo("Temperature Sensor", "1.1");
        
          // Fetch the number of attached temperature sensors  
          numSensors = sensors.getDeviceCount();
          Serial.print("nombre de capteur : ");
          Serial.println(numSensors);
        
          // Present all sensors to controller
          gw.present(0, S_TEMP);
          gw.present(1, S_DOOR);
        }
        
        /*ISR(TIMER2_COMPB_vect)        // interrupt service routine
        {
        }
        
        ISR(TIMER1_COMPB_vect)        // interrupt service routine
        {
        }
        */
        ISR(INT0_vect) {
          if (triac1) {
            digitalWrite(TRIAC1, HIGH);
            digitalWrite(TRIAC1, LOW);
            delayMicroseconds(100);
            digitalWrite(TRIAC1, HIGH);
            digitalWrite(TRIAC1, LOW);
            digitalWrite(TRIAC1, HIGH);
            digitalWrite(TRIAC1, LOW);
            digitalWrite(TRIAC1, HIGH);
            digitalWrite(TRIAC1, LOW);
          } else {
            if (triac2) {
              digitalWrite(TRIAC2, HIGH);
              digitalWrite(TRIAC2, LOW);
              delayMicroseconds(100);
              digitalWrite(TRIAC2, HIGH);
              digitalWrite(TRIAC2, LOW);
              digitalWrite(TRIAC2, HIGH);
              digitalWrite(TRIAC2, LOW);
              digitalWrite(TRIAC2, HIGH);
              digitalWrite(TRIAC2, LOW);
            }
          }
        }
        
        // the loop routine runs over and over again forever:
        void loop() {
          // Process incoming messages (like config from server)
          gw.process(); 
        
          //---------------Lecture des valeurs------------------
          if ((millis() - myTime) > 10000) { // toutes les dix secondes
            myTime = millis();
            // Attention à la fréquence 16 ou 8 Mhz pro mini Chinois ou pas !!!
            // Sinon ca ne marche pas et je cherche pendant 3 heures !!!
            // Fetch temperatures from Dallas sensors
            sensors.requestTemperatures();
          }
          // Fetch and round temperature to one decimal
          float temperature = static_cast<float>(static_cast<int>((gw.getConfig().isMetric?sensors.getTempCByIndex(0):sensors.getTempFByIndex(0)) * 10.)) / 10.;
         
          // Only send data if temperature has changed and no error
          #if COMPARE_TEMP == 1
          if (lastTemperature[0] != temperature && temperature != -127.00 && temperature != 85.00) {
          #else
          if (temperature != -127.00 && temperature != 85.00) {
          #endif
            // Send in the new temperature
            gw.send(msgTemp.setSensor(0).set(temperature,1));
            // Save new temperatures for next compare
            lastTemperature[0]=temperature;
          }
          doorOpenState = digitalRead(HALL); // lecture à chaque cycle (urgence)
          if (doorOpenState != doorOpenChange){
             
            gw.send(msgDoor.setSensor(1).set(doorOpenState));
            doorOpenChange = doorOpenState;
          }
        
        1 Reply Last reply
        0
        • sundberg84S Offline
          sundberg84S Offline
          sundberg84
          Hardware Contributor
          wrote on last edited by
          #4

          Hi.
          Cant se any definition of the vector_1 in your code - maybe in any of the libraries?
          There are some info in the arduino forum: http://forum.arduino.cc/index.php?topic=47992.0 have a look and see if that helps you out.

          Controller: Proxmox VM - Home Assistant
          MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
          MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
          RFLink GW - Arduino Mega + RFLink Shield, 433mhz

          1 Reply Last reply
          0
          • flylowgofastF Offline
            flylowgofastF Offline
            flylowgofast
            wrote on last edited by
            #5

            Yes you're right,
            before MySensors my code was ok, but now MySensors use a librairy in ~/arduino-1.6.7/harware/arduino/avr/cores/arduino/WInterrupts.c
            So this use of interrupt is already declare in this library !
            I don't now how to avoid the issue ?

            martinhjelmareM 1 Reply Last reply
            0
            • flylowgofastF flylowgofast

              Yes you're right,
              before MySensors my code was ok, but now MySensors use a librairy in ~/arduino-1.6.7/harware/arduino/avr/cores/arduino/WInterrupts.c
              So this use of interrupt is already declare in this library !
              I don't now how to avoid the issue ?

              martinhjelmareM Offline
              martinhjelmareM Offline
              martinhjelmare
              Plugin Developer
              wrote on last edited by martinhjelmare
              #6

              @flylowgofast

              Hi!

              Use attachInterrupt instead.
              http://gammon.com.au/interrupts

              And don't use delay inside the ISR. Variables should be volatile.

              1 Reply Last reply
              1
              • flylowgofastF Offline
                flylowgofastF Offline
                flylowgofast
                wrote on last edited by
                #7

                @martinhjelmare

                Hi, thank you for your reply, the link is very usefull.
                You said variables should be Volatile, this is the case for my variable triac1 & 2, but I use two other "const" :

                static const uint8_t TRIAC1= 3;    //Triac 1 associé au timer 2 OC2B pour la sortie D3
                static const uint8_t TRIAC2= 10;   //Triac 2 associé au timer 1 OC1B pour la sortie D10 
                

                Have I to add volatile in this case too ?

                Thanks

                1 Reply Last reply
                0
                • mfalkviddM Offline
                  mfalkviddM Offline
                  mfalkvidd
                  Mod
                  wrote on last edited by
                  #8

                  "C's volatile keyword is a qualifier that is applied to a variable when it is declared. It tells the compiler that the value of the variable may change at any time--without any action being taken by the code the compiler finds nearby" (source: http://www.barrgroup.com/Embedded-Systems/How-To/C-Volatile-Keyword )

                  So volatile only affects changes to variables. Your const variables will not change, so there is no need to declare them volatile.

                  1 Reply Last reply
                  0
                  • flylowgofastF Offline
                    flylowgofastF Offline
                    flylowgofast
                    wrote on last edited by
                    #9

                    thanks to all your contributions, it becomes clear for me.

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    25

                    Online

                    11.7k

                    Users

                    11.2k

                    Topics

                    113.1k

                    Posts


                    Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • MySensors
                    • OpenHardware.io
                    • Categories
                    • Recent
                    • Tags
                    • Popular