Absolute Noob - Interrupt Vector Conflicts (SoftwareSerial/EnableInterrupt)

Hello all, as noted in the title, I’m a newbee at both software and the Arduino. I have a little experience in simple software development as it applies to the Arduino, and none in libraries development - reading things like .h and .cpp files is almost impossible since I don’t have any experience with this level of programming.

I am designing a programmable RC servo sequencer that controls 6 servo’s via VarSpeedServo.h, a motor via an L298 Bridge, a couple of optical sensor inputs and three switch inputs for positional information. I use one of the external interrupts to monitor the position of the RC transmitter switch to control the state of the sequencer. In general, this piece of the code is working fine.

The sequencer is also fully programmable with several options, speeds at which servos traverse, end-point adjustment for the servos and whether the servo direction is normal or reversed.

setup() controls the programming function and the loop() manages the sequencer. Programming is initiated by plugging in a programming board to the sequencer unit and pressing a button at powerup to enter the programming mode. The programming board has 4 switches (Prog/Sel, Inc, dec, and toggle), one buzzer and two LED’s. Once programming is complete, the programming board is removed and some of the pins that were assigned to the programming mode are reassigned for the sequencer.

I’m also using a serial 7 Segment display from SparkFun as a programming mode display device and want to use SoftwareSerial.h to do that - at least this is what I believe.

I am currently using EnableInterrupt.h for the four switches and I believe I need SoftwareSerial for the display during programming.

That’s the general overview. Note that seqee.h IS a library but it is simply the fixed data related to EEPROM locations and arrays used during programming. It has one ifndef, define and endif statement only - very simple.

The issue I am having is the conflict between these two libraries. I have researched over the web and believe I understand the cause of the compiler error I’m getting, that of the “land grab” for interrupts. What I have NOT been able to find is a solution to this. Remember, I am a newbee so much of the dialog I have read simply goes over my head.

The board I’m using is an UNO and I will port to a nano for implementation. Just about every I/O pin is in use in this application and I’m also using the Analog pins as digital inputs for switches and sensors. The only pins I’m currently not using are the Una Rx/Tx and A6/A7.

As most of you know, the compiler punches out __vector3, 4 and 5 errors when I include the SoftwareSerial library. I haven’t assigned anything yet using SoftwareSerial. The snippit of code shows the basic assignments.

Someone in the forum did mention HardwareSerial but I cannot locate information on how to use this library and since reading the .h and .cpp files is not something I have learned yet, they are of little use to me on usage.

Are there other libraries or methods I can use to get the simple serial reset and write capabilities to the Serial7Segment SparkFun display?

#include <SoftwareSerial.h>
#include <EnableInterrupt.h>
#include <seqee.h>
#include <elapsedMillis.h>
#include <VarSpeedServo.h>
#include <avr/eeprom.h>
#include <EEPROM.h>


#define TXSWPin 2
#define PROGSELPin 4
#define INCPin A1
#define DECPin A2
#define TOGPin A3

VarSpeedServo servo1;
VarSpeedServo servo2;
VarSpeedServo servo3;
VarSpeedServo servo4;
VarSpeedServo servo5;
VarSpeedServo servo6;
elapsedMillis timeElapsed;

Please post the error messages that you are getting and the full program.

The only pins I'm currently not using are the Una Rx/Tx and A6/A7.

Not part of the problem but does the Uno actually have pins A6 and A7 ?

I use one of the external interrupts to monitor the position of the RC transmitter switch to control the state of the sequencer.

Do you really need to use an interrupt to monitor the position of a switch ? Could you not just poll an input ?

Post the error message, and link to the library you're using.

UKHeliBob:
Please post the error messages that you are getting and the full program.
Not part of the problem but does the Uno actually have pins A6 and A7 ?
Do you really need to use an interrupt to monitor the position of a switch ? Could you not just poll an input ?

Probably not.

Here's the error message.

Arduino: 1.6.7 (Windows 7), Board: "Arduino/Genuino Uno"

libraries\SoftwareSerial\SoftwareSerial.cpp.o: In function `__vector_3':

C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial/SoftwareSerial.cpp:229: multiple definition of `__vector_3'

sketch\sls-Sequencer-v1.10-working-version.ino.cpp.o:C:\Program Files (x86)\Arduino\libraries\EnableInterrupt/EnableInterrupt.h:1574: first defined here

libraries\SoftwareSerial\SoftwareSerial.cpp.o: In function `SoftwareSerial::read()':

C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial/SoftwareSerial.cpp:394: multiple definition of `__vector_4'

sketch\sls-Sequencer-v1.10-working-version.ino.cpp.o:C:\Users\Tony\Documents\Arduino\sls-Sequencer-v1.10-working-version/sls-Sequencer-v1.10-working-version.ino:808: first defined here

libraries\SoftwareSerial\SoftwareSerial.cpp.o: In function `SoftwareSerial::read()':

C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial/SoftwareSerial.cpp:394: multiple definition of `__vector_5'

sketch\sls-Sequencer-v1.10-working-version.ino.cpp.o:C:\Users\Tony\Documents\Arduino\sls-Sequencer-v1.10-working-version/sls-Sequencer-v1.10-working-version.ino:808: first defined here

collect2.exe: error: ld returned 1 exit status

Multiple libraries were found for "EnableInterrupt.h"
 Used: C:\Program Files (x86)\Arduino\libraries\EnableInterrupt
 Not used: C:\Users\Tony\Documents\Arduino\libraries\EnableInterrupt-master
exit status 1
Error compiling.

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.

This is where I got the library;

Regarding polling the switches - I guess that is an alternate way to do this but I've written everything to run with interrupts. Your point however, is taken and I will review exactly what this would mean for the work I've done so far.

I'd like to continue on the path I am but if it turns out to be impossible, maybe polling switches is the only workaround.

Are there alternate workarounds to maintain support of pin change interrupts?

I'd like to continue on the path I am

Why make things more complicated than they need to be ?

If possible follow the KISS principle.

Conflicts between Arduino libraries are common - partly because there is no guidance for authors, partly because authors are only concerned with their little world and partly because an Arduino has limited resources.

It is also my experience, not just with Arduino, that it is easy to spend more time trying to figure out or fix a library than the time it would take to achieve the same result without a library. Unfortunately documentation for OpenSource software is absent or very sparse.

I reckon many library authors could have made a better contribution by writing a tutorial to teach people how to do something rather than trying to remove the need to do it. Probably take them less time also.

I very much subscribe to the KISS principle.

…R

Take a look at Paul Stoffregen's AltSoftSerial library.

Instead of pin-change interrupts, AltSoftSerial uses a system of timer interrupts to clock the serial data in and out. AltSoftSerial only works with certain pins(9 and 8 on the UNO and other Atmega 328s).

That one has a similar error during compile except __vector_11.

Arduino: 1.6.7 (Windows 7), Board: "Arduino/Genuino Uno"

libraries\VarSpeedServo\VarSpeedServo.cpp.o: In function `__vector_11':

C:\Program Files (x86)\Arduino\libraries\VarSpeedServo/VarSpeedServo.cpp:138: multiple definition of `__vector_11'

libraries\AltSoftSerial-master\AltSoftSerial.cpp.o:C:\Users\Tony\Documents\Arduino\libraries\AltSoftSerial-master/AltSoftSerial.cpp:131: first defined here

collect2.exe: error: ld returned 1 exit status

Multiple libraries were found for "EnableInterrupt.h"
 Used: C:\Program Files (x86)\Arduino\libraries\EnableInterrupt
 Not used: C:\Users\Tony\Documents\Arduino\libraries\EnableInterrupt-master
exit status 1
Error compiling.

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.

As I noted, I'm very new at this so I am still looking at software debouncing and polling the switches. I've never done this and to be honest, using interrupts in this day and age SHOULD be simple but I get the fact that this is open source and as such.........

So, on the collective advise, I went with polling switches using the Bounce2 library. Now it all seems to work together! Thanks for the pointers!!!

About a year ago, I had a conflict with PCINT1_vect in the software serial.cpp and my A0 and A1 PCINT1_vect interrupt service routine. I found the SoftwareSerial.cpp file in the Arduino IDE package and Commented out PCINT1_vect line 311-316 in SoftwareSerial.cpp in Application Arduino 1.05
package Contents to allow Uno or pro mini A0 & A1 Pin change Int for buttons. (I wasn't using the analog pins for serial).
Now that I have moved to Arduino 1.6.7, I can't find the SoftwareSerial.cpp file in the package contents to make the same change to disable the SoftwareSerial PCINT1_vect.

I Just found the library and Commented out PCINT1_vect line 311-316 in SoftwareSerial.cpp in Application Arduino package Contents to allow Uno or pro mini A0 & A1 Pin change Int for buttons.
I don't use the analog pins for serial.