The new Raspberry Pi B Model B+ is here - Pick one up in the store and check our detailed guide!

Emic 2 + Arduino Mega 2560: Problems Getting Started No Sound

by insultcomicdog on Tue Mar 19, 2013 10:23 pm

I just picked up the Emic 2 Text-to-Speech Module, and I've run into issues running the example Arduino sketch:

http://www.parallax.com/Portals/0/Do...c2-Arduino.zip


Here are some pics of my setup:

Image

Image

I stripped down my Mega so it's down to it's bare bones, and I'm not getting any audio output from the module. I put some traces in and the sketch dies after sending a carriage return to the module. The loop function doesn't get called at all. Is there something simple I'm missing or is there something up with my module?

Here's my code:

Code: Select all | TOGGLE FULL SIZE
/*
 
  Emic 2 Text-to-Speech Module: Basic Demonstration       
                                                         
  Author: Joe Grand [www.grandideastudio.com]             
  Contact: support@parallax.com                           
 
  Program Description:
 
  This program provides a simple demonstration of the Emic 2 Text-to-Speech
  Module. Please refer to the product manual for full details of system
  functionality and capabilities.

  Revisions:
 
  1.0 (February 13, 2012): Initial release
 
*/

// include the SoftwareSerial library so we can use it to talk to the Emic 2 module
#include <SoftwareSerial.h>

#define rxPin 2    // Serial input (connects to Emic 2 SOUT)
#define txPin 3    // Serial output (connects to Emic 2 SIN)
#define ledPin 13  // Most Arduino boards have an on-board LED on this pin

// set up a new serial port
SoftwareSerial emicSerial =  SoftwareSerial(rxPin, txPin);


void setup()  // Set up code called once on start-up
{
  Serial.begin(9600);           // start serial for output
 
  Serial.println("setting up pins");


  // define pin modes
  pinMode(ledPin, OUTPUT);
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
 
  // set the data rate for the SoftwareSerial port
  emicSerial.begin(9600);

  digitalWrite(ledPin, LOW);  // turn LED off
 
  /*
    When the Emic 2 powers on, it takes about 3 seconds for it to successfully
    intialize. It then sends a ":" character to indicate it's ready to accept
    commands. If the Emic 2 is already initialized, a CR will also cause it
    to send a ":"
  */
  Serial.println("sending CR");
  emicSerial.print('\n');             // Send a CR in case the system is already up
  while (emicSerial.read() != ':');   // When the Emic 2 has initialized and is ready, it will send a single ':' character, so wait here until we receive it
  Serial.println("waiting for :");
  delay(10);                          // Short delay
  emicSerial.flush();                 // Flush the receive buffer
}

void loop()  // Main code, to run repeatedly
{
  // Speak some text
  Serial.println("loop");
  emicSerial.print('S');
  emicSerial.print("Hello. My name is the Emic 2 Text-to-Speech module. I would like to sing you a song.");  // Send the desired string to convert to speech
  emicSerial.print('\n');
  digitalWrite(ledPin, HIGH);         // Turn on LED while Emic is outputting audio
  while (emicSerial.read() != ':');   // Wait here until the Emic 2 responds with a ":" indicating it's ready to accept the next command
  digitalWrite(ledPin, LOW);
   
  delay(500);    // 1/2 second delay
   
  // Sing a song
  emicSerial.print("D1\n");
  digitalWrite(ledPin, HIGH);         // Turn on LED while Emic is outputting audio
  while (emicSerial.read() != ':');   // Wait here until the Emic 2 responds with a ":" indicating it's ready to accept the next command
  digitalWrite(ledPin, LOW);

  while(1)      // Demonstration complete!
  {
    Serial.println("demo complete");

    delay(500);
    digitalWrite(ledPin, HIGH);
    delay(500);             
    digitalWrite(ledPin, LOW);
  }
}
insultcomicdog
 
Posts: 19
Joined: Mon Apr 02, 2012 12:04 am

Re: Emic 2 + Arduino Mega 2560: Problems Getting Started No Sound

by insultcomicdog on Tue Mar 19, 2013 10:51 pm

Just a follow up...

I've tested the following RX/TX pins..

Serial: 0 (RX) and 1 (TX); Serial 1: 19 (RX) and 18 (TX); Serial 2: 17 (RX) and 16 (TX); Serial 3: 15 (RX) and 14 (TX).

I was actually able to get audio through pins 0, 1 but NOT through any of the other Serial pins pairs.

I have this in my setup function :

Serial.begin(9600);
Serial1.begin(9600);
Serial2.begin(9600);
Serial3.begin(9600);

I'm would like to use to use Serial3 b/c I'm already using Serial2 for another device. Any ideas why the other serial pins wouldn't work?
insultcomicdog
 
Posts: 19
Joined: Mon Apr 02, 2012 12:04 am

Re: Emic 2 + Arduino Mega 2560: Problems Getting Started No Sound

by insultcomicdog on Tue Mar 19, 2013 11:09 pm

Ok...I got it working...by bypassing the SoftwareSerial library altogether and talking to Serial3 directly.
insultcomicdog
 
Posts: 19
Joined: Mon Apr 02, 2012 12:04 am

Re: Emic 2 + Arduino Mega 2560: Problems Getting Started No Sound

by adafruit_support_bill on Wed Mar 20, 2013 4:51 am

I've tested the following RX/TX pins..

Serial: 0 (RX) and 1 (TX); Serial 1: 19 (RX) and 18 (TX); Serial 2: 17 (RX) and 16 (TX); Serial 3: 15 (RX) and 14 (TX).

You came pretty close there. But you didn't land on any of the lucky numbers :wink: .
Unlike the Uno, the Mega does not support software-serial on all pins. It uses pin-change interrupts to monitor the Rx pin.
http://arduino.cc/en/Reference/SoftwareSerial
Not all pins on the Mega and Mega 2560 support change interrupts, so only the following can be used for RX: 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69
User avatar
adafruit_support_bill
 
Posts: 27951
Joined: Sat Feb 07, 2009 9:11 am