SERIN command with Hyperterminal
cjkogan111
Posts: 20
Hello, I am having trouble using the SERIN command to read what I type in hyperterminal on the basic stamp (using the debugger to read the variable typed.)
The code is as follows:
get_ground_command:
SERIN SER_IN, 188, 10000, timeout, [noparse][[/noparse]WAIT(01,02),STR command\2]
DEBUG "MADE IT", CR
timeout:
DEBUG "CONTINUE", CR
DEBUG DEC5, command
RETURN
Iam using the MAX232 chip as a serial driver to interface between the computer and the stamp.
I have been able to successfully use the SEROUT command with the same baud rate to write an output to the computer. Also, I have shorted together pins 11 and 12 on the MAX232 and been able to perform a successful loopback with my computer (meaning what I type in hyperterminal immediately appears.) When I type in the terminal, I will type a command like 1256A, where the 1 and 2 (that is what the wait 01,02 is - I think) should initialize the transfer, and the A ends it.
I think that the problem is with my SERIN code, or what I am typing in hyperterminal. I was wondering if you can see a problem with either what I am typing or my SERIN command.
Sorry if I didn't write this very clearly, I will be able to answer questions whenever.
Thanks!
- cjkogan111
The code is as follows:
get_ground_command:
SERIN SER_IN, 188, 10000, timeout, [noparse][[/noparse]WAIT(01,02),STR command\2]
DEBUG "MADE IT", CR
timeout:
DEBUG "CONTINUE", CR
DEBUG DEC5, command
RETURN
Iam using the MAX232 chip as a serial driver to interface between the computer and the stamp.
I have been able to successfully use the SEROUT command with the same baud rate to write an output to the computer. Also, I have shorted together pins 11 and 12 on the MAX232 and been able to perform a successful loopback with my computer (meaning what I type in hyperterminal immediately appears.) When I type in the terminal, I will type a command like 1256A, where the 1 and 2 (that is what the wait 01,02 is - I think) should initialize the transfer, and the A ends it.
I think that the problem is with my SERIN code, or what I am typing in hyperterminal. I was wondering if you can see a problem with either what I am typing or my SERIN command.
Sorry if I didn't write this very clearly, I will be able to answer questions whenever.
Thanks!
- cjkogan111
Comments
One problem I see is that you’re waiting for a value of 1 then 2, but you’re typing 1 and 2, which is actually sending ASCII $31 and $32 which are different values. I hope this helps. Take care.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
SERIN SER_IN, 188, 10000, timeout, [noparse][[/noparse]WAIT("12"),STR command/2]
INPUT = RESULT
12a3e = "a3"
12a3 = "a3"
12a 1 = "a "
1x = Here the function will wait till the time out and continue to the time out function
12 = Here the function will continue to wait till 2 more bytes are recieved and will not go to the time out function.
command VAR Word
get_ground_command:
SERIN SER_IN, 188, 10000, timeout, [noparse][[/noparse]STR command\2]
DEBUG "MADE IT", CR
timeout:
DEBUG "CONTINUE", CR
DEBUG DEC5, command
RETURN
Still, however, every time that command is written out, its value is 00000.
Is command not taking on a value of the input, or am I writing it out incorrectly? Any ideas?
Thanks!
- cjkogan111
You’re entering the data into an array of one element (Word) of which serial can only input one byte at a time. Try this:
For more digits, change the 2 to a 3, 4 or 5.· I hope this helps.· Take care.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
Also serin(STR) stores your key press's in an array (command), each key press is stored in a different element of the array, to view each key press you need to debug each element. In your code you are using two elements (STR command\2) the index starts at 0 through 1.
Example
DEBUG DEC command(0)
DEBUG DEC command(1)
Alternatively you can send the array back to hyperteminal using SEROUT SER_OUT,188,[noparse][[/noparse]STR command] and hyperterminal should display it as you typed it.
Jeff T.
command VAR Byte
Now I am able to press the keys and see there values on the debug from the stamp.
get_ground_command:
SERIN SER_IN, 188, 10000, timeout, [noparse][[/noparse]WAIT(49,50),STR command\2]
DEBUG "MADE IT", CR
timeout:
DEBUG "CONTINUE", CR
DEBUG DEC command(0)
DEBUG DEC command(1)
RETURN
One more question, the transmission that the stamp should receive will be something like: 12AA3DA, where the 12 initiates the transfer, and the 3DA ends the transfer.
I can use WAIT(49,50) to begin the transfer, but is there any similar way to end the transfer?
Thanks!
-cjkogan111
-cjkogan111
hope im not hijacking this post by asking
Be careful with the timeout function combined with WAIT, as·stray data (or electrical noise on the line) will hold the program there.
I mean,·it will hang there until either...
1- It receives the data specified in the·WAIT command, or
2- It times out with no data coming in.
Hope this helps,
Cheers, Chris, West Oz.