VoiceKey
The VoiceKey instruction recognizes the return of a number 1 through 9, the asterisk (*), or the pound key (#). VoiceKey is often used to add a delay, which provides time for the message to be spoken, in a VoiceBegin/EndVoice sequence.
Syntax
VoiceKey ( Timeout )
In the following program, the code enclosed in the VoiceBeg/EndVoice instructions will be performed when a ring is detected from a voice modem. The datalogger will report the temperature and prompt the user to press the asterisk to end the call. The two messages will be repeated until the datalogger receives the asterisk, a Counter is incremented to 60, or the timeout period expires (2 minutes).
'Declare Variables
Public PTemp, TCTemp, Counter
VoiceBeg
Counter=0
Do
Counter=Counter + 1
VoiceSpeak ("THE TEMPERATURE IS" + TCTemp + "DEGREES", 2)
VoiceSpeak ("PRESS STAR TO DISCONNECT", 2)
'42 is the ASCII code for *
Loop Until VoiceKey(12000)=42 or Counter=60
EndVoice
BeginProg
Scan (1,Sec,3,0)
PanelTemp (PTemp,15000)
TCDiff (TCTemp,1,mv200C,U1,TypeT,PTemp,True ,0,15000,1.0,0)
NextScan
EndProg
Remarks
If the timeout period is exceeded, the VoiceKey instruction returns a -1. If the key is received within the time out period, the key itself is returned. If a carrier is detected a -2 is returned. If a voice modem is not detected, a -3 will be returned. If the connection is terminated on the other end or the voice modem times out speaking, a -4 will be returned.
NOTE: When creating code for voice modems, the VoiceKey instruction should be used to add a delay before the EndVoice instruction is executed. Otherwise, the datalogger will end the VoiceSpeak command before the spoken message is completed.
Parameter
VoiceTimeOut
Defines a time, in 0.01 seconds, when the instruction should time out and proceed to the next instruction if the defined key is not returned. The TimeOut timer begins once the spoken announcements have finished.
Type: Constant