hi im working on a dmxtester device.
i want to use a single potentiometer to set both channel and dmxvalue .a button to change between set channel mode and dmxvalue mode.
to display the channel and dmx output value I want to use the nootropicdesign digitshield wich is a four digit 7 segemt display shield.
i have now start writing the code but when im compiling the sketch i get a strange error message:
DigitShield/DigitShield.cpp.o: In function __vector_9': /Users/GET/Documents/Arduino/libraries/DigitShield/DigitShield.cpp:286: multiple definition of __vector_9'
DmxSimple/DmxSimple.cpp.o:/Users/GET/Documents/Arduino/libraries/DmxSimple/DmxSimple.cpp:141: first defined here
it seems like the error has to do with the libraries im using. could it be a timer issue?
any ideas how to solve it?
the code :
#include <DmxSimple.h>
#include <DigitShield.h>
int sensorPin = A0; // select the input pin for the potentiometer
int DmxValue = 0; // variable to store the value coming from the sensor
int buttonState = 0; // variable for reading the pushbutton status
int ChannelValue=0;
int RawValue1=0;
int RawValue2=0;
const int buttonPin = 7;
void setup() {
DmxSimple.usePin(6);
DigitShield.begin();
pinMode(buttonPin, INPUT);
}
void loop() {
if (buttonState == HIGH) {
// set Dmx channel
RawValue1 = analogRead(sensorPin);
ChannelValue = map(RawValue1, 0, 1023, 1, 512);
DigitShield.setValue(ChannelValue);
}
else {
// Set DMX value
RawValue2 = analogRead(sensorPin);
DmxValue = map(RawValue2, 0, 1023, 0, 255);
DigitShield.setValue(DmxValue);
}
DmxSimple.write(ChannelValue, DmxValue);
}
Do you have sourcecode for the libraries? Look for ISR routines for the same interrupt vector - if they both define an interrupt routine for the same interrupt that would clash.
with help from Michael at nootropic design who made the digitshield and its library i solve the timer issue. the segment shield is now using timer1 instead of timer2.
here is the code that needs to be change in the digitshield library:
// TIMER1
// Disable the timer overflow interrupt
TIMSK1 &= ~(1 << TOIE1);
// Set timer1 to normal mode
TCCR1A &= ~((1 << WGM11) | (1 << WGM10));
TCCR1B &= ~((1 << WGM13) | (1 << WGM12));
// Disable compare match interrupt
TIMSK1 &= ~(1 << OCIE1A);
TIMSK1 &= ~(1 << OCIE1B);
// Prescalar is clock divided by 128
TCCR1B &= ~(1 << CS12);
TCCR1B &= ~(1 << CS11);
TCCR1B |= (1 << CS10);
// Start the counting at 0
TCNT1 = 0;
// Enable the timer2 overflow interrupt
TIMSK1 |= (1 << TOIE1);
the DmxTester uses a button,slider potentiometer, Nootropic design digitshield , and a sn75176 for the rs232 ttl to rs485 conversion.
and here is the code:
/*
This code was made by Gustaf Gagge with help to change to timer 1
in the digitshield library from Michael at Nootropic design who also wrote the digitshield library.
modify the digitshield libary with this in the initialization part
file to modify: DigitShield.cpp
// TIMER1
// Disable the timer overflow interrupt
TIMSK1 &= ~(1 << TOIE1);
// Set timer1 to normal mode
TCCR1A &= ~((1 << WGM11) | (1 << WGM10));
TCCR1B &= ~((1 << WGM13) | (1 << WGM12));
// Disable compare match interrupt
TIMSK1 &= ~(1 << OCIE1A);
TIMSK1 &= ~(1 << OCIE1B);
// Prescalar is clock divided by 128
TCCR1B &= ~(1 << CS12);
TCCR1B &= ~(1 << CS11);
TCCR1B |= (1 << CS10);
// Start the counting at 0
TCNT1 = 0;
// Enable the timer2 overflow interrupt
TIMSK1 |= (1 << TOIE1);
the overflow ISR need to be change to this:
ISR(TIMER1_OVF_vect) {
TCNT1 = 0;
for(int i=0;i<nDigitShields;i++) {
digitShields[i]->isr();
}
}
*/
#include <DigitShield.h>
#include <DmxSimple.h>
int sensorPin = A0; // select the input pin for the potentiometer
int DmxValue = 0; // variable to store the value coming from the sensor
int ChannelValue=0;
int RawValue1=0;
int RawValue2=0;
const int buttonPin = 7;
void setup() {
DmxSimple.usePin(6);// as standard the DmxSimple uses D3 but for this we need D7
DigitShield.begin();
pinMode(buttonPin, INPUT);
digitalWrite(buttonPin, HIGH);
}
void loop() {
int val = digitalRead(buttonPin);
if (val == LOW) {
// set Dmx channel
RawValue1 = analogRead(sensorPin);
ChannelValue = map(RawValue1, 0, 1023, 1, 512);
DigitShield.setValue(ChannelValue);
}
else {
// Set DMX value
RawValue2 = analogRead(sensorPin);
DmxValue = map(RawValue2, 0, 1023, 0, 255);
DigitShield.setValue(DmxValue);
}
DmxSimple.write(ChannelValue, DmxValue);
}