SEROUT command (single byte value not string)


Closed Thread
Results 1 to 16 of 16
  1. #1
    Join Date
    Dec 2008
    Posts
    23

    Default SEROUT command (single byte value not string)

    All

    I am using the SPEAKJET with the TTS256 to get it to talk from commands i send it in PBASIC using the SEROUT command from my PIC16F84A.

    It works, but I need to send it data message (see below)to tell it to stop repeating, how can I send data(not as a string) in PICBASIC

    i have tried the following and none work

    SEROUT 7, T9600,(15)
    SEROUT 7, T9600, (0x0D)
    SEROUT 7, T9600, ("0X0D")
    SEROUT 7, T9600, ('0X0D') 'does not compile

    I need to send the control code 0x0d as a single byte value not a string.
    If I try to put the 0x0d in quotes, the speech chip tries to say it. Any ideas anyone please.

  2. #2
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Are you using PicBasic, or PicBasic Pro?

    Here is the example from the PBP manual:

    SEROUT
    0,N2400,[#B0,10] ‘ Send the ASCII value of B0 followed by a linefeed out Pin0 serially


    So, from that, you could try:


    SEROUT 7, T9600,[15]

    or if using PicBasic, your
    SEROUT 7, T9600,(15)
    should work
    Last edited by ScaleRobotics; - 7th June 2010 at 18:25.

  3. #3
    Join Date
    Dec 2008
    Posts
    23


    Did you find this post helpful? Yes | No

    Default Serout

    Thank you but that gives an error in PICBASIC, any other ideas-ill try them -

  4. #4
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    What is the error?

  5. #5
    Join Date
    Dec 2008
    Posts
    23


    Did you find this post helpful? Yes | No

    Default SEROUT erros

    ERROR Line 20: Illegal Character '[' (Speech test.pbc)
    ERROR Line 20: '(' Expected (Token '15') (Speech test.pbc)
    ERROR Line 20: Illegal Character ']' (Speech test.pbc)

  6. #6
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Ok, sounds like you are using PicBasic, and not picbasic pro. What errors do you get when you use:

    Code:
    include "Modedefs.bas"
    serout 7,T9600,(15)
    Last edited by ScaleRobotics; - 7th June 2010 at 19:04.

  7. #7
    Join Date
    Dec 2008
    Posts
    23


    Did you find this post helpful? Yes | No

    Default Serout

    Yes, I am using Picbasic, here are the errors when i added what you said

    ERROR Line 12: ':' or '=' Expected (Token 'Modedefs') (Speech test.pbc)
    ERROR Line 12: Illegal Character '.' (Speech test.pbc)

  8. #8
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Thanks MrRoboto,

    Sorry, my bad, can you do:

    include "modedefs.bas"

    Can you share your code? Interested in line 12, but the rest would help too.
    Last edited by ScaleRobotics; - 7th June 2010 at 19:04.

  9. #9
    Join Date
    Dec 2008
    Posts
    23


    Did you find this post helpful? Yes | No

    Default Serout code

    Here it is, minus text at the top that does not apply to code since it is commented out


    include Modedefs.bas ' I added this when u told me


    Main:

    serout 7, T9600, ("at your command")
    serout 7, T9600,(15)

    End


    '----

    The code above does not say anything, unless i can send it this data somehow 0x0d or 15 ?

  10. #10
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    I was in error, can you put quotes around "modedefs.bas" and see what happens when you compile?

  11. #11
    Join Date
    Dec 2008
    Posts
    23


    Did you find this post helpful? Yes | No

    Default Serout

    Here is the error i get when i do this
    include "modedefs.bas"



    ERROR Line 12: ':' or '=' Expected (Token 'modedefs.bas') (Speech test.pbc)


    Any ideas?

  12. #12
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    You do not need "modedefs.bas" in Pic Basic. It is part of it, sorta.

    You also said the chip tries to talk so that is a good sign, IT IS ALIVE

    Any way.
    From the data sheet.
    http://www.speechchips.com/downloads...eet_prelim.pdf
    For example, the pistol shot sound is 253. Create a string with text and include the
    value 253 somewhere in it. The text will be read back and the gunshot sound will
    play. In a string constant in C, the value can be either octal or hexadecimal and is
    preceded by an escape character.
    Octal Value Encoded in String “This is a gunshot\375”
    Decimal Value Encoded in String “This is a gunshot \xFD”

    The two byte commands (volume, pitch, etc.) will only pass through correctly if the
    second byte is a non-text character. Otherwise the TTS256 will process the second
    byte as text and incorrect data will be sent to the SpeakJet. Two byte commands
    can be sent without this restriction by placing the TTS256 in pass through mode.
    So.
    Code:
    serout 7, T9600, ("at your command\15")
    or try the example
    Code:
    serout 7, T9600, ( “This is a gunshot \xFD”)
    Dave
    Always wear safety glasses while programming.

  13. #13
    Join Date
    Dec 2008
    Posts
    23


    Did you find this post helpful? Yes | No

    Default Serout

    I tried both, if i put in inside the quotes, it will actually attempt to say backslash 15

    and another thing, if I do this, it doesnt say anything

    Main:

    serout 7, T9600, ("at your command\15")

    End


    -----

    But if I do this this(below), it works, but repeats itself over and over again with the backslash 15 ,--that is why I think it is with the buffer, i just need to know how to send a data byte in PICBASIC and not a string.

    Main:

    serout 7, T9600, ("at your command\15")


    goto Main


    ---

    Any help????

  14. #14
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    The data sheet for this part could tell more, it is not much help...
    Have you tried this? From the data sheet:
    P
    ass Through Mode
    In cases where the host processor needs to communicate directly with the SpeakJet,
    the TTS256 offers a pass though mode that will send any received codes from the
    host directly to the SpeakJet without translation of any kind.
    This is accomplished by sending the text "passthruon" and an end-of-line character.
    All characters sent to the TTS256 will be sent directly to the SpeakJet without
    translation. An "X" ($58) will terminate the pass through mode. Note that this
    character cannot be used as the second byte of a two-byte command as it will
    terminate the pass through mode. An "X" is also used to terminate the SCP mode for
    communication directly with the SpeakJet internal registers. An alternate \A may be
    used to terminate SCP mode and not pass through.
    Dave
    Always wear safety glasses while programming.

  15. #15
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default

    For starters, Decimal 15 does not equal 0x0D
    Hexidecimal 0x0F equals Decimal 15,
    but this isn't C. For Picbasic (Pro at least) the Hex is represented $0F.

    From reading the PBP manual (that's PicBasic Pro),
    It appears to me that serout cannot send raw data.

    The example you were given before:
    "SEROUT 0,N2400,[#B0,10] ‘ Send the ASCII value of B0 followed by a linefeed out Pin0 serially"
    is only sending a string because a linefeed is the ASCII control code associated with the decimal value 10,
    and the command line is going to send the ASCII representation of variable B0 before that (still a string).

    That being said I'm suprised even the plain vanilla PicBasic can't send proper serial data.
    I can't be sure since I don't have the manual for it.
    I am sure that PBP can send raw serial data... I do it all the time.
    Art.

  16. #16
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default

    Why do you think a decimal 15 value will make the Speakjet stop repeating itself?
    There is nothing in the datasheet to suggest that. It say that value will make the voice
    sound relaxed.

    You say this makes the Speakjet repeat the string over and over
    Code:
    Main:
    
    serout 7, T9600, ("at your command\15")
    
    goto Main
    but if you leave out the goto cammand it will never say anything?

    Might I suggest that the Microchip pic has powered up and sent the serial command
    before the Speakjet has become ready to receive it?

    Try this:

    Code:
    Main:
    
    PAUSE 5000
    
    serout 7, T9600, ("at your command\15")
    
    End
    and if that works, see how low you can adjust the pause value.
    Art.

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts