Panel użytkownika
Nazwa użytkownika:
Hasło:
Nie masz jeszcze konta?

[Arduino] Łączenie bibliotek z błędem

Ostatnio zmodyfikowano 2014-04-11 10:23
Autor Wiadomość
p0ldek
Temat założony przez niniejszego użytkownika
[Arduino] Łączenie bibliotek z błędem
» 2014-04-09 18:03:40
Witam
Zadanie pewnie trywialne choć sprawia mi to wiele problemów, staram się połączyć dwie biblioteki, mianowicie: DMXSerial i ShiftPWM. Poniżej mój kod i błąd jaki generuje. Działam na Arduino 1.0.5. Staram się stworzyć 16 kanałowy kontroler led z 595. Sterowany przez DMX.

C/C++
const int ShiftPWM_latchPin = 8;
const bool ShiftPWM_invertOutputs = false;
const bool ShiftPWM_balanceLoad = true;
#include <DMXSerial.h>
#include <ShiftPWM.h> // include ShiftPWM.h after setting the pins!

unsigned char maxBrightness = 255;
unsigned char pwmFrequency = 75;
unsigned int numRegisters = 2;
unsigned int numOutputs = numRegisters * 8;
unsigned int numRGBLeds = numRegisters * 8 / 3;


#define  DefaultLevel 100


void setup() {
    DMXSerial.init( DMXReceiver );
    DMXSerial.write( 1, 100 );
    DMXSerial.write( 2, 100 );
    DMXSerial.write( 3, 100 );
   
    // Sets the number of 8-bit registers that are used.
    ShiftPWM.SetAmountOfRegisters( numRegisters );
    ShiftPWM.Start( pwmFrequency, maxBrightness );
   
    ShiftPWM.SetAll( 0 );
}

void loop() {
    // Calculate how long no data backet was received
    unsigned long lastPacket = DMXSerial.noDataSince();
   
    if( lastPacket < 5000 ) {
        // read recent DMX values and set pwm levels
        ShiftPWM.SetOne( 1, DMXSerial.read( 0 ) );
        ShiftPWM.SetOne( 2, DMXSerial.read( 1 ) );
        ShiftPWM.SetOne( 3, DMXSerial.read( 2 ) );
        ShiftPWM.SetOne( 4, DMXSerial.read( 3 ) );
        ShiftPWM.SetOne( 5, DMXSerial.read( 4 ) );
        ShiftPWM.SetOne( 6, DMXSerial.read( 5 ) );
        ShiftPWM.SetOne( 7, DMXSerial.read( 6 ) );
        ShiftPWM.SetOne( 8, DMXSerial.read( 7 ) );
        ShiftPWM.SetOne( 9, DMXSerial.read( 8 ) );
        ShiftPWM.SetOne( 10, DMXSerial.read( 9 ) );
        ShiftPWM.SetOne( 11, DMXSerial.read( 10 ) );
        ShiftPWM.SetOne( 12, DMXSerial.read( 11 ) );
        ShiftPWM.SetOne( 13, DMXSerial.read( 12 ) );
        ShiftPWM.SetOne( 14, DMXSerial.read( 13 ) );
        ShiftPWM.SetOne( 15, DMXSerial.read( 14 ) );
        ShiftPWM.SetOne( 16, DMXSerial.read( 15 ) );
       
    }
    else {
        ShiftPWM.SetOne( 1, DefaultLevel );
        ShiftPWM.SetOne( 2, DefaultLevel );
        ShiftPWM.SetOne( 3, DefaultLevel );
        ShiftPWM.SetOne( 4, DefaultLevel );
        ShiftPWM.SetOne( 5, DefaultLevel );
        ShiftPWM.SetOne( 6, DefaultLevel );
        ShiftPWM.SetOne( 7, DefaultLevel );
        ShiftPWM.SetOne( 8, DefaultLevel );
        ShiftPWM.SetOne( 9, DefaultLevel );
        ShiftPWM.SetOne( 10, DefaultLevel );
        ShiftPWM.SetOne( 11, DefaultLevel );
        ShiftPWM.SetOne( 12, DefaultLevel );
        ShiftPWM.SetOne( 13, DefaultLevel );
        ShiftPWM.SetOne( 14, DefaultLevel );
        ShiftPWM.SetOne( 15, DefaultLevel );
        ShiftPWM.SetOne( 16, DefaultLevel );
       
    }
   
   
}


core.a(HardwareSerial.cpp.o): In function `__vector_18':
C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/HardwareSerial.cpp:115: multiple definition of `__vector_18'
DMXSerial\DMXSerial.cpp.o:C:\Program Files (x86)\Arduino\libraries\DMXSerial/DMXSerial.cpp:353: first defined here
core.a(HardwareSerial.cpp.o): In function `__vector_19':
C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/HardwareSerial.cpp:218: multiple definition of `__vector_19'
DMXSerial\DMXSerial.cpp.o:C:\Program Files (x86)\Arduino\libraries\DMXSerial/DMXSerial.cpp:440: first defined here
P-107959
MrPoxipol
» 2014-04-09 21:52:38
Może coś pomoże: http://forum.arduino.cc​/index.php/topic,112251.0.html, ew napisz na forum Arduino.

/edit: http://www.alrightythen.de​/blog/2012/10​/developing-for-arduino-on-ecli​pse​/
Frazy, które należy wpisać w wyszukiwarkę google:
P-107982
p0ldek
Temat założony przez niniejszego użytkownika
» 2014-04-10 19:08:53
Witam starałem się wykonać instrukcje zawarte w linkach, lecz z miernym efektem. Za to wpadłem na pomysł skorzystania z innej biblioteki, mianowicie Shifter . Poniżej zamieszczam kod, nie wywala mi już żadnego błędu lecz kod po prostu nie działa po wrzuceniu na arduino. Jedyne co to na 595 na pinie Q7 dioda świeci się ciągle reszta bez większego efektu.


// - - - - -
// DmxSerial - A hardware supported interface to DMX.
// DmxSerialRecv.ino: Sample DMX application for retrieving 3 DMX values:
// address 1 (red) -> PWM Port 9
// address 2 (green) -> PWM Port 6
// address 3 (blue) -> PWM Port 5
//
//
// Documentation and samples are available at
// 25.07.2011 creation of the DmxSerial library.
// 10.09.2011 fully control the serial hardware register
//            without using the Arduino Serial (HardwareSerial) class to avoid ISR implementation conflicts.
// 01.12.2011 include file and extension changed to work with the Arduino 1.0 environment
// 28.12.2011 changed to channels 1..3 (RGB) for compatibility with the DmxSerialSend sample.
// 10.05.2012 added some lines to loop to show how to fall back to a default color when no data was received since some time.
// - - - - -
#include <Shifter.h>
#include <DMXSerial.h>

// Constants for demo program

///const int RedPin =    9;  // PWM output pin for Red Light.
///const int GreenPin =  6;  // PWM output pin for Green Light.
///const int BluePin =   5;  // PWM output pin for Blue Light.

#define RedDefaultLevel   100
#define GreenDefaultLevel 200
#define BlueDefaultLevel  255
#define SER_Pin 11 //SER_IN
#define RCLK_Pin 8 //L_CLOCK
#define SRCLK_Pin 13 //CLOCK

#define NUM_REGISTERS 1 //how many registers are in the chain

Shifter shifter(SER_Pin, RCLK_Pin, SRCLK_Pin, NUM_REGISTERS);
void setup () {
  DMXSerial.init(DMXReceiver);
 
  // set some default values
  DMXSerial.write(1, 80);
  DMXSerial.write(2, 100);
  DMXSerial.write(3, 100);
 
  // enable pwm outputs
  //pinMode(RedPin,   OUTPUT); // sets the digital pin as output
  //pinMode(GreenPin, OUTPUT);
  //pinMode(BluePin,  OUTPUT);
}


void loop() {
 
    shifter.clear(); //set all pins on the shift register chain to LOW
    shifter.write(); //send changes to the chain and display them
 
  // Calculate how long no data backet was received
  unsigned long lastPacket = DMXSerial.noDataSince();
 
  if (lastPacket < 5000) {
    // read recent DMX values and set pwm levels
    shifter.setPin(1,   DMXSerial.read(1));
    shifter.setPin(2,   DMXSerial.read(2));
    shifter.setPin(3,   DMXSerial.read(3));

  } else {
    // Show pure red color, when no data was received since 5 seconds or more.
    shifter.setPin(1,   RedDefaultLevel);
    shifter.setPin(2, GreenDefaultLevel);
    shifter.setPin(3,  BlueDefaultLevel);
  } // if
}

// End.
P-108002
OSA_PL
» 2014-04-11 10:23:50
Shifter.h służy tylko do ustawiania stanu wysokiego/niskiego na danym pinie, a ShiftPWM.h do ustawiania wypełnienia PWM danego pinu, wiec raczej nie będzie działać tak jak oczekujesz.
P-108037
« 1 »
  Strona 1 z 1