View Full Version : SEROUT command (single byte value not string)
MrRoboto
- 7th June 2010, 17:54
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.
ScaleRobotics
- 7th June 2010, 18:18
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
MrRoboto
- 7th June 2010, 18:22
Thank you but that gives an error in PICBASIC, any other ideas-ill try them -
ScaleRobotics
- 7th June 2010, 18:28
What is the error?
MrRoboto
- 7th June 2010, 18:34
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)
ScaleRobotics
- 7th June 2010, 18:40
Ok, sounds like you are using PicBasic, and not picbasic pro. What errors do you get when you use:
include "Modedefs.bas"
serout 7,T9600,(15)
MrRoboto
- 7th June 2010, 18:44
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)
ScaleRobotics
- 7th June 2010, 19:01
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.
MrRoboto
- 7th June 2010, 19:07
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 ?
ScaleRobotics
- 7th June 2010, 19:17
I was in error, can you put quotes around "modedefs.bas" and see what happens when you compile?
MrRoboto
- 7th June 2010, 20:06
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?
mackrackit
- 7th June 2010, 23:54
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 :eek:
Any way.
From the data sheet.
http://www.speechchips.com/downloads/TTS256_Datasheet_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.
serout 7, T9600, ("at your command\15")
or try the example
serout 7, T9600, ( “This is a gunshot \xFD”)
MrRoboto
- 8th June 2010, 02:30
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????
mackrackit
- 8th June 2010, 15:05
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.
Art
- 12th June 2010, 03:19
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.
Art
- 12th June 2010, 03:34
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
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:
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.
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.