Code:
' =========================================================================
'
' File...... RN-SPEAK_1_0.bs2
' Version... 1.0
' Purpose... Serial Control of RN-Speak with BS2e on Board of Education or
' Milford develloping board using switched joystick input data
' Author.... Rolf Black
' based on . SpeakJet_Demo.BS2, (c) 2004 Parallax, INC. -- All Rights Reserved
' PhonicStick_3_0_1, (c) 2006 Rolf Black -- All Rights Reserved
' E-mail.... rolfblack @ computing.dundee.ac.uk, support@parallax.com
' Started... 06 SEP 2006 (3.0)
' Updated... 25 OCT 2006 (RN-Speak 1.0)
' {$STAMP BS2E}
' {$PBASIC 2.5}
'
' =========================================================================
' -----[ Program Description ]---------------------------------------------
'
' Example program for RS232 control of RN-Speak via BASIC Stamp controller
' Direct connection, BASIC Stamp outputs 5V - enough to work...
' Connections: BS2 RN-Speak RS232
'
' P15 (Tx) ----> Pin 1 (RX) DB9.2
' P14 (Rx) <---- Pin 3 (TX) DB9.8 not used
' Vss ----- Pin 2 (GND) DB9.5
' -----[ Revision History ]------------------------------------------------
' -----[ I/O Definitions ]-------------------------------------------------
Tx PIN 15 ' serial out to RN-Speak
Rx PIN 14 ' serial in from RN-Speak
' -----[ Constants ]-------------------------------------------------------
#SELECT $stamp
#CASE BS2, BS2E, BS2PE
T2400 CON 396
T4800 CON 188
T9600 CON 84
T19K2 CON 32
#CASE BS2SX, BS2P
T2400 CON 1021
T4800 CON 500
T9600 CON 240
T19K2 CON 110
#ENDSELECT
SevenBit CON $2000
Inverted CON $4000
Open CON $8000
Baud CON T9600 + Inverted
Sync CON $55
' -----[ Variables ]-------------------------------------------------------
phonicIndex VAR Byte ' index where phonic is found in RN-Speak
bufferByte VAR Byte ' speak buffer of RN-Speak
' -----[ In/Out Pins ]--------------------------------------------------
DIRS = %1000000000000000 ' sets I/O Pins
' -----[ Program Code ]----------------------------------------------------
phonicIndex = 1
Main:
' DEBUG "Main", CR
SEROUT Tx, Baud, ["rnm", phonicIndex]
' DEBUG "Element ", DEC phonicIndex, " sent to RN-Speak", CR
' DO ' possibly to wait for next phonic input until last phonic spoken
' SERIN Rx, Baud, [bufferByte] ' not tested
' IF (bufferByte = 0) THEN exit
' LOOP
' DEBUG "Finished speaking", CR
' DEBUG CR
End_of_program:
END
Lesezeichen