beginners question on DEBUGIN
lfreeze
Posts: 174
I am a beginner, I have gotten through the basis instructions in the manual, and thought I would try and
expand my knowledge..
I am trying to create a simple object which will mimic "debugin" via a hyperterminal session. I am using a propstick
(serial connector) to my desktop. For purposes of simplicity, I want the object to pause and wait for an input via
keyboard. The input will be a variable, either 1 or 2. If the input is 1, the object goes to the lightledtone· object.
If the input is 2, the object goes to the lightledtwo object.· If any other number, or nothing is input, the object stays
in a loop and·keeps looking for a 1 or 2.
I have tried countless variations of Martin Hebels BS2 functions (debugin) and also many variations of the full duplex
serial object.· I have searched the posting for any examples and can't find any. Below is some of the code (not working)
which I am using. Can anyone offer an example or some guidance on how to accomplish this.
Thank you in advance
Larry
CON
··· _clkmode = xtal1 + pll16x
··· _xinfreq = 5_000_000····················
VAR
··· byte value
·················································
OBJ
'··· BS2· : "BS2_Functions"·
···· SER· : "FullDuplexSerial"
·········
PUB start
REPEAT
·· ser.start(31, 30, 0, 9600)
· if value ==1
··· lightledone
· if value ==2
···· lightledtwo···
······
PUB lightledone
··· dira[noparse][[/noparse]9] ~~············ 'makes pins 9 an· output
··· outa[noparse][[/noparse]9] :=%1·········· 'set the value of pin· 9· as high +5
··· waitcnt (5_000_000 + cnt)
··· outa[noparse][[/noparse]9] :=%0·········· 'sets the value of pin 9· as low· 0
···· waitcnt (10_000_000 + cnt)·
PUB lightledtwo
··· dira[noparse][[/noparse]8] ~~············· 'makes pin an 8 output
··· outa[noparse][[/noparse]8] :=%1··········· 'set the value of pin 8· as high +5
··· waitcnt (5_000_000 + cnt)
··· outa[noparse][[/noparse]8] :=%0··········· 'sets the value of pin 8· as low· 0
···· waitcnt (10_000_000 + cnt)·
expand my knowledge..
I am trying to create a simple object which will mimic "debugin" via a hyperterminal session. I am using a propstick
(serial connector) to my desktop. For purposes of simplicity, I want the object to pause and wait for an input via
keyboard. The input will be a variable, either 1 or 2. If the input is 1, the object goes to the lightledtone· object.
If the input is 2, the object goes to the lightledtwo object.· If any other number, or nothing is input, the object stays
in a loop and·keeps looking for a 1 or 2.
I have tried countless variations of Martin Hebels BS2 functions (debugin) and also many variations of the full duplex
serial object.· I have searched the posting for any examples and can't find any. Below is some of the code (not working)
which I am using. Can anyone offer an example or some guidance on how to accomplish this.
Thank you in advance
Larry
CON
··· _clkmode = xtal1 + pll16x
··· _xinfreq = 5_000_000····················
VAR
··· byte value
·················································
OBJ
'··· BS2· : "BS2_Functions"·
···· SER· : "FullDuplexSerial"
·········
PUB start
REPEAT
·· ser.start(31, 30, 0, 9600)
· if value ==1
··· lightledone
· if value ==2
···· lightledtwo···
······
PUB lightledone
··· dira[noparse][[/noparse]9] ~~············ 'makes pins 9 an· output
··· outa[noparse][[/noparse]9] :=%1·········· 'set the value of pin· 9· as high +5
··· waitcnt (5_000_000 + cnt)
··· outa[noparse][[/noparse]9] :=%0·········· 'sets the value of pin 9· as low· 0
···· waitcnt (10_000_000 + cnt)·
PUB lightledtwo
··· dira[noparse][[/noparse]8] ~~············· 'makes pin an 8 output
··· outa[noparse][[/noparse]8] :=%1··········· 'set the value of pin 8· as high +5
··· waitcnt (5_000_000 + cnt)
··· outa[noparse][[/noparse]8] :=%0··········· 'sets the value of pin 8· as low· 0
···· waitcnt (10_000_000 + cnt)·
Comments
One of the features is it uses hyperterminal to control the program. The program looks for I,J,K,M and does something if one of those is hit. Your program is basically the same idea.
How about something like this description
The above is not 'real' code, it is just thinking out loud with something that looks like code (but is really close).
Check out the color-code.spin to see how I did it with both RS232 and IR-TV-remote
Look in this thread
http://forums.parallax.com/showthread.php?p=651296
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nothing is impossible, there are only different degrees of difficulty.
Sapieha
I will try both solutions, Saphiea is there an English version of the web site? ·I used the·link you suggested
and then downloaded the files, I·need some directions in how to use them. The help button sends me to a German language site. Meinen Deutsch is nicht gut
Larry
It is both on some sides
But Spin codes is in English.
Study it (I recommend Virtual_S_L.spin)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nothing is impossible, there are only different degrees of difficulty.
Sapieha
Thanks again for·your example. I·used it to build on, ·then I extracted the case statements from color-code spin. The
object I built loads, but I get no result when· keyboard 1 or 2 is pressed.· I suspected My hyperterminal setup is incorrect
so I ran a known good object and I can receive via hyperterminal okay.···Any suggestions would be appreciated.
Here is the code I have created so far...
CON
··· _clkmode = xtal1 + pll16x
··· _xinfreq = 5_000_000····················
VAR
··· byte value
OBJ
··· SER· : "FullDuplexSerial"
PUB start
ser.start(31, 30, 0, 9600)
REPEAT
· value:=ser.rxcheck·
· CASE value
···· 49: 'ascii· "1" was pressed
······· light_led_one
···· 50:· 'ascii· "2" was pressed
······· light_led_two
······
PUB light_led_one
··· dira[noparse][[/noparse]9] ~~············ 'makes pins 9 an· output
··· outa[noparse][[/noparse]9] :=%1·········· 'set the value of pin· 9· as high +5
··· waitcnt (5_000_000 + cnt)
··· outa[noparse][[/noparse]9] :=%0·········· 'sets the value of pin 9· as low· 0
···· waitcnt (10_000_000 + cnt)·
PUB light_led_two
··· dira[noparse][[/noparse]8] ~~············· 'makes pin an 8 output
··· outa[noparse][[/noparse]8] :=%1··········· 'set the value of pin 8· as high +5
··· waitcnt (5_000_000 + cnt)
··· outa[noparse][[/noparse]8] :=%0··········· 'sets the value of pin 8· as low· 0
···· waitcnt (10_000_000 + cnt)
·
There will most likely be a parity bit, but EITHER 49 OR 50 should work
Take into account that a flash of 5/80 = 0.06 s is hardly noticeable
Post Edited (deSilva) : 9/25/2007 9:33:03 PM GMT
Thus is HyperTerminal setup.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nothing is impossible, there are only different degrees of difficulty.
Sapieha
beginners mistake. I had set up hyperterminal incorrectly. Saphiehas message prompted me to create a new
hyperterminal connection using the settings he provided And suddenly magic !!! it worked.··
Larry
··· bits per second··· = 9600
··· data bits············· = 8
··· parity················· =· none
··· stop bits············ =· 1
·· flow control········ =· none
I checked the program (attached) several times and noticed one problem. If you key in "1" rapidly the program will stop reacting to
it after about three times. If you rapidly alternate between keying "1" then ·"2", it works fine. I am not sure what is causing this. I will spend some time with it and see if I can solve it.
Larry
I suspect you're dropping characters because of the 3/16 second delay for each action.· If you type too many characters ahead, the FullDuplexSerial buffer will fill up before your program can get them and the extras will be dropped.· The buffer is normally 16 bytes.
Post Edited (Mike Green) : 9/26/2007 12:06:11 AM GMT
You cant use this to check values.
value:=ser.rxcheck
Study "FullDuplex" it is only check for incomming char flag
else check in you routin for "case -1" - not char in
Ps. Sorry my bad English
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nothing is impossible, there are only different degrees of difficulty.
Sapieha
Post Edited (Sapieha) : 9/26/2007 12:17:08 AM GMT
Thanks for the tip on the quote marks. I don't think it's the 3/16 second delay. If I key in a 1, wait approx one second then do it again, it will fail after the third· or fourth try. If I key in· 1, and then rapidly (as fast as I can) ·key in any other key the program reacts perfectly. I am really puzzled (not unusual) about this problem. I will pursue if further, but I· am not sure
which direction to take. (hyperterminal, fullduplexserial or my program)
Thanks
Larry
Thank you for your response. I am confused about not being able to use value:=ser.rxcheck. It seems to be working
as it is reading whether a 1 or 2 is keyed in. i suspect a buffer problem in fullduplexserial.· I will work on this in
the morning as see if I can fix it.··.
guten nacht
Larry
Yes it reading but.
You mast test for incominh char first and if one, read it and test.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nothing is impossible, there are only different degrees of difficulty.
Sapieha
emulation. My program works fine if hyperterminal emulation is changed from auto detect to minitel. Of course nothing
is easy, if you disconnect the hyperterminal connection while using minitel emulation, you can not restart it.
You must create a new connection. Does anyone have any ideas about how to solve this.
"rxcheck" is the approved way to read characters.
"rx " does nothing but
it is not necessary to check for -1 when you check for other specific values
Sorry my miss. I still thing standard serial port.
Rxcheck = Receive buffer full flag
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nothing is impossible, there are only different degrees of difficulty.
Sapieha