Thanks Andries,
I appreciate you inserting the changes in my code, which is a known constant in my head, and that makes it easier for me to understand.
Let's put our thinking caps on and analyze what is happening here.
I added timers in the code to measure the time spent in a RX serial REPEAT/UNTIL loop.
Here is the code with the timers inserted, it is what you modified:
Code: Select all
'talk test
PINMODE 36, OUT ' set pin 36 as output for serial TX
PINMODE 37, IN ' set pin 37 as input for serial RX
SERINIT 1,9600,8,1,0 ' port 1, 9600 bps, 8 data bits, 1 stop bit, no parity
CR$ = CHR$(13) ' for CR
'timer to measure loop time
looptime = GETTICK
REPEAT
x$=SERINP$(1,-1,-1,1) ' Clear the receive buffer
x=SEROUT(1, CHR$(13)) ' Send a CR to Emic and
WAIT(20) ' Delay 20ms
x$= SERINP$(1, 1,ASCII(":"),5000000) ' check if a ":" is returned
' to show Emic is ready to receive
UNTIL x$ = ":"
x$=SERINP$(1,-1,-1,1) ' Clear the receive buffer of the previous ":"
'print loop time
? (GETTICK - looptime)/10 , " ms"
? "Booted... Input Command or [ENTER] to continue:"
INPUT setup$ ' get input from terminal
x=SEROUT(1,setup$+CR$)
'timer to measure loop time
looptime = GETTICK
REPEAT
WAIT(20) ' Delay 20ms to see if the EMIC responded with ":" to SEROUT
x$= SERINP$(1, 1,ASCII(":"),5000000) ' check if a ":" is returned
' to show Emic is ready to receive
UNTIL x$ = ":"
x$=SERINP$(1,-1,-1,1) ' Clear the receive buffer of the previous ":"
'print loop time
? (GETTICK - looptime)/10 , " ms"
TXtalk$ = "hello. i am the emic 2 text 2 speech module being tested on the EzSBC1."
? "Speaking greeting..."
'timer to measure loop time
looptime = GETTICK
SOUT$ = "s" + TXtalk$ + CR$ ' combine "s" for speak, text & CR
x = SEROUT (1, SOUT$) ' Sends SOUT$ to serial port 1 (pin 36)
REPEAT
WAIT(20) ' Delay 20ms to see if the EMIC responded with ":" to SEROUT
x$= SERINP$(1, 1,ASCII(":"),5000000) ' check if a ":" is returned
' to show Emic is ready to receive
UNTIL x$ = ":"
x$=SERINP$(1,-1,-1,1) ' Clear the receive buffer of the previous ":"
'start=GETTICK ' 1 tick = 0.0001 seconds
'REPEAT ' timer for speech to finish...
'UNTIL GETTICK > (start+5000000) ' 13 seconds
'print loop time
? (GETTICK - looptime)/10 , " ms"
? "Speaking number..."
'timer to measure loop time
looptime = GETTICK
RNDpass$=STR$(INT(RND(9000)+1000)) ' random number between 1000 & 9999
x=SEROUT(1,"s"+RNDpass$+". that's, "+RNDpass$+CR$)
REPEAT
WAIT(20) ' Delay 20ms to see if the EMIC responded with a ":" to SEROUT
x$= SERINP$(1, 1,ASCII(":"),5000000) ' check if a ":" is returned
' to show Emic is ready to receive
UNTIL x$ = ":"
'start=GETTICK
'REPEAT ' timer for speech to finish...
'UNTIL GETTICK > (start+50000) ' 5 seconds
'print loop time
? (GETTICK - looptime)/10 , " ms"
?RNDpass$ + " random number" ' print passcode to the terminal...
END
Here is the result of the program run:
Control BASIC v0.73
R-Run S-Step L-List E-Edit C-Configure B-Bank D-Download K-Reset T-Time & Date
Start program
42.2 ms
Booted... Input Command or [ENTER] to continue:
41.3 ms
Speaking greeting...
115.8 ms
Speaking number...
6247.4 ms
9201 random number
Program Ended.
Now let me describe what is happening in
RED:
===
Start program
42.2 ms
Booted... Input Command or [ENTER] to continue:
--{ I hit {ENTER} and a CR is sent to the Emic 2 ]--
41.3 ms
Speaking greeting...
115.8 ms
Speaking number...
--[ speech starts and goes to here after 157.1 ms and waits for the greeting text to be spoken, passing over speaking the random number speech. ]--
6247.4 ms
--[ greeting speech has finished and only prints the random number ]--
9201 random number
Program Ended.
===
The second time i run this program it immediately says ",(random number 1 digit, something "what" like garbage)" and then displays the timer value in ms. it took to speak the garbage and it's ready receive an input from the terminal.
When you hit {ENTER} it proceeds the same as above, the 3rd and 4th time running and so on.
Progress has been made since it did wait for the speech to finish before printing the random number but it's still not right.
There should be enough data here to diagnose the problem if you study the code and it's responses.
If not, then a better code to test the problem should be written.
Thanks for your help,
Enjoy!
Robert
.