CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

EMIC text-to-speech & UART

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
moryoav



Joined: 23 Feb 2014
Posts: 35

View user's profile Send private message

EMIC text-to-speech & UART
PostPosted: Mon May 05, 2014 7:56 am     Reply with quote

hey, im using pic18F2553 ubw [https://www.sparkfun.com/products/762] and im trying to interface with the EMIC module via UART.
EMIC datasheet (couldn't find online one): http://goo.gl/27Vdrx

i connected a speaker to the EMIC and ran a basic "say hello" code and it didn't work, so i suspect either my UART settings are wrong or the code, and i can't find the problem.
speaker datasheet (same as EMIC): http://goo.gl/aA65Bm

Code:
//set to 1 to use a PIC's internal USB Peripheral
//set to 0 to use a National USBN960x peripheral
#define __USB_PIC_PERIF__ 1

#if !defined(__PCH__)
 #error USB CDC Library requires PIC18
#endif

#if __USB_PIC_PERIF__
  #include <18F2553.h>

  //configure a 20MHz crystal to operate at 48MHz
  #fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL6,CPUDIV1,VREGEN
  //#fuses   USBDIV, PLL1, CPUDIV1, PROTECT, NOCPD, noBROWNOUT,HSPLL,NOWDT,nolvp, VREGEN
  #use delay(clock=48000000)
#else //use the National USBN960x peripheral
  #include <18F452.h>
  #fuses HS,NOWDT,NOPROTECT,NOLVP     
  #use delay(clock=20000000)     
  #use rs232 (baud=2400, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
#endif   //endif check to see which peripheral to use

/////////////////////////////////////////////////////////////////////////////
//
// If you are using a USB connection sense pin, define it here.  If you are
// not using connection sense, comment out this line.  Without connection
// sense you will not know if the device gets disconnected.
//       (connection sense should look like this:
//                             100k
//            VBUS-----+----/\/\/\/\/\----- (I/O PIN ON PIC)
//                     |
//                     +----/\/\/\/\/\-----GND
//                             100k
//        (where VBUS is pin1 of the USB connector)
//
/////////////////////////////////////////////////////////////////////////////
///only the 18F4550 development kit has this pin
//#if __USB_PIC_PERIF__ && defined(__PCH__)
// #define USB_CON_SENSE_PIN PIN_B2
//#endif
//
// Includes all USB code and interrupts, as well as the CDC API
#include <usb_cdc.h>

#define DefPeriod   20     
#define DefDuty     4   

//#rom int 0xf00000={1,2,3,4}
int TimerCount =0,
    priod =DefPeriod,
    duty =DefDuty;

   
char InChar=0;

#INT_TIMER1 // interrupt for timer1
void clock_isr1()
{                 
       set_timer1(62523);
 //      output_toggle(PIN_A5);
     
     
     
      // duty handler
     
      if  (TimerCount >0 && TimerCount <= duty)
      {
           output_high(PIN_C0);
          output_high(PIN_A5);
         
      }   
      else
      {
          output_low(PIN_C0);
          output_low(PIN_A5);
      }   
       
      if (TimerCount > priod-1) TimerCount=0; // period cicel - working ariel
       TimerCount ++;
   
 
   
}

void main()
{
   while(1)
   {
      printf("say=hello;");     
      delay_ms(1000);                     
   }
}   
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Mon May 05, 2014 8:49 am     Reply with quote

Hi,

I haven't used the EMIC module in a while, but I remember that it was quite straight-forward. I just looked at my code, and I send the module a number of 'setup' commands at start-up (pitch, speed, etc.), but nothing that should prevent the module from speaking.

A couple of suggestions:

1. The EMIC has a 'TTL' serial interface, so the PIC 'Tx' output can connect directly to the EMIC 'Rx' input. The EMIC is a +5V device, so this assumes that everything is powered at +5V.

2. The EMIC needs a few seconds to boot, so I'd add a small delay at the top of Main() to allow the EMIC to get started.

3. You should make sure your PIC is actually running, and running at the proper speed by attaching an LED to an unused I/O pin and blinking it at start-up. If you turn the LED On for 1 second, and then Off for 1 second and then repeat several times, you'll know the PIC is working correctly.

4. My version of the EMIC flashes an LED when serial data is being received. Do you see that?

5. Simplify you code with just the EMIC stuff until you get this working! Get rid of the USB and timer stuff until this works!

Good Luck!

John
moryoav



Joined: 23 Feb 2014
Posts: 35

View user's profile Send private message

PostPosted: Mon May 05, 2014 8:57 am     Reply with quote

ezflyr wrote:
Hi,

I haven't used the EMIC module in a while, but I remember that it was quite straight-forward. I just looked at my code, and I send the module a number of 'setup' commands at start-up (pitch, speed, etc.), but nothing that should prevent the module from speaking.

A couple of suggestions:

1. The EMIC has a 'TTL' serial interface, so the PIC 'Tx' output can connect directly to the EMIC 'Rx' input. The EMIC is a +5V device, so this assumes that everything is powered at +5V.

2. The EMIC needs a few seconds to boot, so I'd add a small delay at the top of Main() to allow the EMIC to get started.

3. You should make sure your PIC is actually running, and running at the proper speed by attaching an LED to an unused I/O pin and blinking it at start-up. If you turn the LED On for 1 second, and then Off for 1 second and then repeat several times, you'll know the PIC is working correctly.

4. My version of the EMIC flashes an LED when serial data is being received. Do you see that?

5. Simplify you code with just the EMIC stuff until you get this working! Get rid of the USB and timer stuff until this works!

Good Luck!

John


thanks for the answer. i did connect the Tx and Rx as sugested and i am aware of the EMIC LED. the usb stuff is for me and is not important regarding to the main(), but still a must, so basically it can be ignored here.
is my way of interfacing with the EMIC correct? (printf("command"))?
that's as straight forward as i can think of.
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Mon May 05, 2014 9:15 am     Reply with quote

Hi,

Yes, it looks OK. Here is one code snippet of what works for me:

Code:

printf("say=Repeater Voltage;");


I'd follow my suggestion to verify that the PIC is running at the correct speed. This simple oversight trips up a lot of programmers new to the PIC. I'd also add a healthy delay at the top of Main().....

John
moryoav



Joined: 23 Feb 2014
Posts: 35

View user's profile Send private message

PostPosted: Mon May 05, 2014 9:29 am     Reply with quote

ezflyr wrote:
Hi,

Yes, it looks OK. Here is one code snippet of what works for me:

Code:

printf("say=Repeater Voltage;");


I'd follow my suggestion to verify that the PIC is running at the correct speed. This simple oversight trips up a lot of programmers new to the PIC. I'd also add a healthy delay at the top of Main().....

John

aight it works! a few more questions as for now if you'll allow:
i added a 3 seconds delay, seems enough?
also what is the minimal delay i can put between commands? (speed pitch etc), and how do i change pitch or speed mid-sentence?
Quote:
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Mon May 05, 2014 10:23 am     Reply with quote

Hi,

I delay about 2 seconds before sending any data to the EMIC, and that seems to work fine. I use a fixed delay of 500ms between the configuration commands I send to the EMIC. I don't know if anything faster would work, but I do know that the module will respond with 'OK' upon receipt of the command, so you could just wait for that?

If you want to change the speed/pitch in mid-sentence, then you'll have to break up the sentence to do this. It wasn't a requirement for me, so I didn't play with this too much. I imagine you'd need to figure out the optimal delivery rate of data to the EMIC to avoid any objectionable pauses in the speech.

John
moryoav



Joined: 23 Feb 2014
Posts: 35

View user's profile Send private message

PostPosted: Mon May 05, 2014 10:38 am     Reply with quote

ezflyr wrote:
Hi,

I delay about 2 seconds before sending any data to the EMIC, and that seems to work fine. I use a fixed delay of 500ms between the configuration commands I send to the EMIC. I don't know if anything faster would work, but I do know that the module will respond with 'OK' upon receipt of the command, so you could just wait for that?

If you want to change the speed/pitch in mid-sentence, then you'll have to break up the sentence to do this. It wasn't a requirement for me, so I didn't play with this too much. I imagine you'd need to figure out the optimal delivery rate of data to the EMIC to avoid any objectionable pauses in the speech.

John


1. the EMIC sending 'OK' means the BUSY pin is back to LOW i assume. how can i use the BUSY output in a the code? doing something like "(while BUSY=0){ <change settings>*}?

2. I read about Phonetic Alphabet in the datasheet. it gives a word stress and stuff, but when i use it the EMIC just reads the letters one by one and not as a whole word with a stress in it. did you use that option? do you know why it doesn't work for me?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group