Interruption Vector
-
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
-
@flylowgofast Post your sketch so we can have a look.
-
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; } -
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. -
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 ? -
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 ?Hi!
Use attachInterrupt instead.
http://gammon.com.au/interruptsAnd don't use delay inside the ISR. Variables should be volatile.
-
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 D10Have I to add volatile in this case too ?
Thanks
-
"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.
-
thanks to all your contributions, it becomes clear for me.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login