nlamprian / EMIC2

Arduino library for interfacing with the Emic 2 Text-to-Speech module
MIT License
15 stars 6 forks source link

Not working with Arduino Mega 2560 (?) #1

Open kd8bxp opened 8 years ago

kd8bxp commented 8 years ago

The library appears to not work with the Meg 2560 and hardware serial ports.
I tried to just put the RX/TX pins the hardward uses and it didn't work. I think there is a way to check what type of Arduino you are using at time of compile, but I'm not clear on how to use it, or what needs to change here to make something like that work. http://electronics.stackexchange.com/questions/58386/how-can-i-detect-which-arduino-board-or-which-controller-in-software Thanks

nlamprian commented 8 years ago

Thanks for the feedback. First chance I get, I'll fix it. Though, I need you to confirm that you'll be able to test the library, since I don't have the EMIC2 module anymore.

kd8bxp commented 8 years ago

I'd be happy to test it out. I am using the eMic 2 in my Hero Jr Robot which I've updated the hardware to a Arduino Mega 2560 etc. I've noticed that the method I'm using to have the eMic speak sometimes it misses words or entire sentences. I asked someone else about that and they suggested your library which is how I found you, so it would be great if between us we could get it working with the mega! I did fork the project and was going to try myself, I am not sure that I have the needed skill to fix or it just make it worse :-)

-Thank you - LeRoy

mjs513 commented 8 years ago

Know I am late at joining this conversation but I am using a Mega 2560 and getting ready to use the emic 2 in my project. So if you would like I can test it out as well.

v/R Mike

mjs513 commented 8 years ago

Here is code I use periodically to identify different boards. This was modified from something I found on the forum. I may help:

//
// This sketch will print some of interesting predefined constants to Serial.
//  
// For more information, look at 
// http://electronics4dogs.blogspot.com/2011/01/arduino-predefined-constants.html

// helper macro
#define LINE(name,val) Serial.print(name); Serial.print("\t"); Serial.println(val);

void setup()
{
  Serial.begin(9600);

  Serial.println("OK in Setup");
  // Compile file path (internal file of compilation proccess)
  LINE("__FILE__", __FILE__);

  // Current line (but in __FILE__)
  LINE("__LINE__", __LINE__);

  // Name of current function   
  LINE("__func__", __func__);

  // Date of compliation
  LINE("__DATE__", __DATE__);

  // Time of compilation
  LINE("__TIME__", __TIME__);

  // Version of comilator (avr-gcc) 
  LINE("__VERSION__", __VERSION__);

  // Counter
  LINE("__COUNTER__",__COUNTER__); // 0 
  LINE("__COUNTER__",__COUNTER__); // 1
  LINE("__COUNTER__",__COUNTER__); // 2

  Serial.println("\nCPU:");

  #if defined(__AVR__)
    // Arduino Duemilanove and Uno
    LINE("__AVR__", __AVR__);
  #endif

  #if defined(__AVR_ATmega168__)
    // Arduino Diecimila and older
    LINE("__AVR_ATmega168__", __AVR_ATmega168__);
  #endif

  #if defined(__AVR_ATmega328P__)
    // Arduino Duemilanove and Uno
    LINE("__AVR_ATmega328P__", __AVR_ATmega328P__);
  #endif

  #if defined(__AVR_ATmega2560__)
    // Arduino Mega 2560
    LINE("__AVR_ATmega2560__", __AVR_ATmega2560__);
  #endif

  #if defined(__AVR_ATmega1280__)
    // Arduino Mega
    LINE("__AVR_ATmega1280__", __AVR_ATmega1280__);
  #endif

  #if defined(__AVR_ATmega32U4__)
    // Arduino Leonardo
    LINE("__AVR_ATmega32U4__", __AVR_ATmega32U4__);
  #endif

  #if defined(__SAM3X8E__)
    // Arduino Due
    LINE("__SAM3X8E__", __SAM3X8E__);
  #endif

  // Determine board type
  #if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__)
    Serial.println("Regular Arduino");
  #elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__)
    Serial.println("Arduino Mega"); 
  #elif defined(__AVR_ATmega32U4__)
    Serial.println("Arduino Leonardo");
  #elif defined(__SAM3X8E__)
    Serial.println("Arduino Due");
  #elif defined(__AVR__)
    Serial.println("AVR");
  #elif defined(__MK20DX256__)
    Serial.println("Teensy 3.1");
  #else
    Serial.println("Unknown");
  #endif

  Serial.println("\nArduino:");

  // Arduino SW version
  LINE("ARDUINO", ARDUINO);

  // Oscillator frequency
  LINE("F_CPU", F_CPU);

}

void loop(){

  Serial.println("OK in Setup");
  // Compile file path (internal file of compilation proccess)
  LINE("__FILE__", __FILE__);

  // Current line (but in __FILE__)
  LINE("__LINE__", __LINE__);

  // Name of current function   
  LINE("__func__", __func__);

  // Date of compliation
  LINE("__DATE__", __DATE__);

  // Time of compilation
  LINE("__TIME__", __TIME__);

  // Version of comilator (avr-gcc) 
  LINE("__VERSION__", __VERSION__);

  // Counter
  LINE("__COUNTER__",__COUNTER__); // 0 
  LINE("__COUNTER__",__COUNTER__); // 1
  LINE("__COUNTER__",__COUNTER__); // 2

  Serial.println("\nCPU:");

  #if defined(__AVR__)
    // Arduino Duemilanove and Uno
    LINE("__AVR__", __AVR__);
  #endif

  #if defined(__AVR_ATmega168__)
    // Arduino Diecimila and older
    LINE("__AVR_ATmega168__", __AVR_ATmega168__);
  #endif

  #if defined(__AVR_ATmega328P__)
    // Arduino Duemilanove and Uno
    LINE("__AVR_ATmega328P__", __AVR_ATmega328P__);
  #endif

  #if defined(__AVR_ATmega2560__)
    // Arduino Mega 2560
    LINE("__AVR_ATmega2560__", __AVR_ATmega2560__);
  #endif

  #if defined(__AVR_ATmega1280__)
    // Arduino Mega
    LINE("__AVR_ATmega1280__", __AVR_ATmega1280__);
  #endif

  #if defined(__AVR_ATmega32U4__)
    // Arduino Leonardo
    LINE("__AVR_ATmega32U4__", __AVR_ATmega32U4__);
  #endif

  #if defined(__SAM3X8E__)
    // Arduino Due
    LINE("__SAM3X8E__", __SAM3X8E__);
  #endif

  // Determine board type
  #if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__)
    Serial.println("Regular Arduino");
  #elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__)
    Serial.println("Arduino Mega"); 
  #elif defined(__AVR_ATmega32U4__)
    Serial.println("Arduino Leonardo");
  #elif defined(__SAM3X8E__)
    Serial.println("Arduino Due");
  #elif defined(__AVR__)
    Serial.println("AVR");
  #elif defined(__MK20DX256__)
    Serial.println("Teensy 3.1");
  #else
    Serial.println("Unknown");
  #endif

  Serial.println("\nArduino:");

  // Arduino SW version
  LINE("ARDUINO", ARDUINO);

  // Oscillator frequency
  LINE("F_CPU", F_CPU);

 while(!Serial.available());
 while(Serial.available())
 {
 Serial.read();
 }
}
nlamprian commented 8 years ago

Sorry for the delay.

I just looked at the Arduino Serial page and I see that the Serial API for Mega doesn't change. I believe you should be able to use the EMIC2 module with the library as it is. The limitation is that you must connect the module to pins 0/1 (RX0/TX0).

Have you tried that? If you have a problem, what exactly is it?

kd8bxp commented 8 years ago

The limitation as I recall is that your library didn't work with any of the hardware serial ports, it only wanted to be used by softwareserial. I don't think it gave me any specific error thou. The MEGA has four hardware serial ports, of which I am now using all four. I ended up putting the EMIC on a Arduino NANO, which softwareserial works on. - I am using my MEGA to tell the NANO what to say, and the NANO is saying it.

I like the library, but I think it can be improved on to support more/support better hardward. I forked the project, and if I get some time after my current project is done I'd like to take a crack at having it support the MEGAs hardware serial ports.

nlamprian commented 8 years ago

Sorry, scratch that. The library uses SoftwareSerial. It's not supposed to work with the hardware serial ports. If you had problems with SoftwareSerial on Mega, that's probably because SoftwareSerial has limitations on Mega.

Please use one of the supported pins on Mega for RX, and tell me how it goes.

If you want to configure the library to use a hardware serial port, it shouldn't be that hard. You just have to change all _emic2_io-> to Serial. and do a few other minor modifications related to the _emic2_io object.

In order to parameterize the library to use either SoftwareSerial or one the hardware serial ports requires more effort. I might consider this for a future update.

arpeggio1234 commented 5 years ago

Just changed the tx/rx pin to 9 and 10 due to the limitation of the MEGA , see above, and works fine now. Thanks for all the messages. Dian