Shop OBEX P1 Docs P2 Docs Learn Events
C code in EMIC TEXT TO SPEECH — Parallax Forums

C code in EMIC TEXT TO SPEECH

psutpsut Posts: 7
edited 2007-05-05 23:19 in General Discussion
hello:

am using emic text to speech module takibg the results from 16f877 pic
am using c lang, the problem is when it says the results it stops without completing the sentence
my statement to be clear: printf("say=temperature is %s degrees",x);
the word "degrees" will not appear·EMIC stops before·saying it..
i tried to separate printf but also same
·printf("say=temperature is %s",x);
printf("say=degrees");
also ot work..
wut should i do???

Comments

  • Harrison.Harrison. Posts: 484
    edited 2007-05-05 02:12
    Is your x variable actually a pointer to a real string? Or is it just an int / byte variable? If so you should be using %d for int/byte or %f for floats. If this is not the problem then hook your PIC up to your computer and see what it is actually sending to the EMIC.

    Harrison
  • psutpsut Posts: 7
    edited 2007-05-05 09:56
    x is an array of characte x
    i used sprintf(x,s);
    which s is the value i wana display so %S is correct...
  • FranklinFranklin Posts: 4,747
    edited 2007-05-05 19:38
    [noparse][[/noparse]quote]my statement to be clear: printf("say=temperature is %s degrees",x);
    the word "degrees" will not appear EMIC stops before saying it..
    i tried to separate printf but also same
    printf("say=temperature is %s",x);
    printf("say=degrees");
    And then...
    [noparse][[/noparse]quote]i used sprintf(x,s);
    which s is the value i wana display so %S is correct...
    It will help us help you if you give us correct information to start with.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • psutpsut Posts: 7
    edited 2007-05-05 19:46
    my code in brief is:

    void main() {

    char sv1[noparse][[/noparse]8];
    unsigned int8 v1;

    setup_port_a( ALL_ANALOG );
    setup_adc( ADC_CLOCK_INTERNAL );
    set_adc_channel( 0 );



    v1=(Read_ADC()/255)*100;

    sprintf(sv1,"%03U\r\n",v1);


    printf("say=temperature is %S degrees celsuis",sv1);
    }

    the module stops after saying the value!!!
  • danieldaniel Posts: 231
    edited 2007-05-05 21:33
    The EMIC data sheet at http://www.parallax.com/dl/docs/prod/audiovis/EmicModules.pdf states "The Emic Platform will process the buffer when it receives the termination character. In ASCII mode, the termination character is a ";" (semicolon) or 0x0D byte (carriage return)."

    Likely the \r\n characters in your sprintf statement are causing the behavior you describe.

    Divide the problem in half: try the statement

    printf("say=temperature is 100 degrees celsuis");

    If that works, then the difficulty is with the sv1 variable, not the printf statement.

    As advised, acually examining the serial string sent to the EMIC would be useful. Hyperterm is on every Windows PC. I prefer a product you can find on the web called Bray's Terminal for these things.

    Daniel
  • psutpsut Posts: 7
    edited 2007-05-05 21:46
    do u mean by making
    sprintf(sv1,"%03U\r\n",v1);
    sprintf(sv1,"%03U",v1);
    it will say
    printf("say=temperature is %S degrees celsuis",sv1);
    ????
  • danieldaniel Posts: 231
    edited 2007-05-05 23:19
    All I'm saying is that

    sprintf(sv1,"%03U\r\n",v1);

    is, among other things, appending a CR and a LF to the formatted value.

    Perhaps you should review your C compiler's documentation of the escape sequences for character constants.


    Have you tried the experiment of:

    printf("say=temperature is 100 degrees celsuis");

    If not, give it a chance; at least it will tell you if the problem lies with a longish string being sent to the emic, or if there is a problem somewhere before the printf() function.


    Capture the output from your device and make sure it is what you, and especially the EMIC, expect.

    Daniel
Sign In or Register to comment.