Baby steps, trying to get roborealm to interface with propeller to sense a butt
So I have been slowly working through the propeller labs. Taking a small step, I am trying to get roborealm to recognize a button being pushed. Using the following spin code I can watch the button being pushed in the terminal emulator it correctly produces a carriage return, a 0, or a 1, and a tab:
{{
DisplayPushbuttons2.spin
Display pushbutton states with roborealm}}
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
OBJ
Debug: "FullDuplexSerialPlus"
PUB TerminalPushbuttonDisplay
Debug.start(31, 30, 0, 57600) ' initiates serial connection
waitcnt(clkfreq*7 + cnt) ' waits 7 seconds
repeat
If ina[noparse][[/noparse]10] == 1 ' if the button on pin 10 is pushed
Debug.str(String(13,"1",9)) 'output <cr>1<tab>
else
Debug.str(String(13,"0",9)) 'output <cr>0<tab>
waitcnt(clkfreq/100 + cnt) 'wait 1/100 second before repeat
The fact that I see the correct output in hyperterm leads me to believe it is an issue with the way I am using roborealm and not the prop. I don't know how many of you are running roborealm, but I figured I would ask anyway.
On the roborealm side, I have loaded serial control and Watch_Variables. I can connect to the com port at 57600 and the only thing I have is
<cr>[noparse][[/noparse]Button]<tab>
under receive sequence.
I open Watch_Variables and it sticks at "0" no matter the state of the button.
Do I need an initialization sequence? If I do, it is unclear to me if I need an initialization sequence at every connect to update the state of [noparse][[/noparse]Button] or just once at the beginning.
This is my initial attempt at a "HELLO WORLD" type of program to get information from the propeller to Roborealm. I feel I am missing something obvious.
Here is a link to roborealm's serial plugin: www.roborealm.com/help/Serial.php
thanks,
grindel
{{
DisplayPushbuttons2.spin
Display pushbutton states with roborealm}}
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
OBJ
Debug: "FullDuplexSerialPlus"
PUB TerminalPushbuttonDisplay
Debug.start(31, 30, 0, 57600) ' initiates serial connection
waitcnt(clkfreq*7 + cnt) ' waits 7 seconds
repeat
If ina[noparse][[/noparse]10] == 1 ' if the button on pin 10 is pushed
Debug.str(String(13,"1",9)) 'output <cr>1<tab>
else
Debug.str(String(13,"0",9)) 'output <cr>0<tab>
waitcnt(clkfreq/100 + cnt) 'wait 1/100 second before repeat
The fact that I see the correct output in hyperterm leads me to believe it is an issue with the way I am using roborealm and not the prop. I don't know how many of you are running roborealm, but I figured I would ask anyway.
On the roborealm side, I have loaded serial control and Watch_Variables. I can connect to the com port at 57600 and the only thing I have is
<cr>[noparse][[/noparse]Button]<tab>
under receive sequence.
I open Watch_Variables and it sticks at "0" no matter the state of the button.
Do I need an initialization sequence? If I do, it is unclear to me if I need an initialization sequence at every connect to update the state of [noparse][[/noparse]Button] or just once at the beginning.
This is my initial attempt at a "HELLO WORLD" type of program to get information from the propeller to Roborealm. I feel I am missing something obvious.
Here is a link to roborealm's serial plugin: www.roborealm.com/help/Serial.php
thanks,
grindel
Comments
Start a new project and·add a Serial object and a Watch_Variables object
In the Serial object make the send sequence <lf> and the recieve sequence ![noparse][[/noparse]Input]<lf>·· (no spaces)
The exclamation is a "wait" character, the [noparse][[/noparse]Input] is the data string and <lf> end of data
Adjust this BS2 code to suit a prop
string(0)="!"
string(0)="4"
SERIN 16,16468,[noparse][[/noparse]WAIT (10)]
SEROUT 16,16468,[noparse][[/noparse]"wait",STR string\2,10]
string(0) is to satisfy the "wait" and string(1) is the data string followed by 10 (line feed)
The watch_variables object should, when connected, contain a variable named Input with a value of 4
Jeff T
EDIT:· I took another look and by adding a SERIN at the processor end (waiting for <lf>) the data was captured in a more reliable way
Post Edited (Unsoundcode) : 7/1/2007 6:58:51 PM GMT
I haven't programmed a BS2, but looking at your code:
string(0)="!"
string(0)="4"
' this should be string(1)="4" right?
SERIN 16,16468,[noparse][[/noparse]WAIT (10)]
' here you are waiting for a line feed sent from roborealm
' 16468 is the baud rate right? How did you set roborealm to this baud?
SEROUT 16,16468,[noparse][[/noparse]"wait",STR string\2,10]
' I'm really not sure what your doing here with "wait" I think it is just some junk to send before you send the actual code? instead of STR string\2, you could have written
' "!","4" right?
string(0) is to satisfy the "wait" <- Please explain more.
Can someone help me out with the spin equivalent if I have the wrong idea?
I see the computer sending LED working on the propclip, but not the computer receiving LED. Also, I just noticed the formatting of my code was screwed up...be assured that I have indented properly
I have messed with Baud rate and the waitcnt to see if there is a timing issue
new code
Note, I wasn't sure how to set <lf> as a variable so I wrote a VBScript as follows:
SetVariable "output", 10
and then used [noparse][[/noparse]output] as my send sequence
again I tried in hyperterminal and was able to type in 10 and get !1 or !2 as a response
thanks for any comments.
Yes the second element should be string(1).
The "wait" in the SEROUT should not be there , I copy and pasted something I was·playing with while I was checking things out.
16468 equates to 9600 baud.
The reason I put a line feed in the Roborealm send sequence was because the only way I could get·things to work was to send data first. I am thinking you can send any data as long as the prop waits for a match
The Roborealm recieve string ( ![noparse][[/noparse]Input}<lf> ) , the exclamation is for synchronization, Roborealm waits for the "!"· ( or any ascii string you want ) , when it sees a match to the string it assumes the data is to follow and places it in the variable in the square brackets.
So the sequence of events in my example is Roborealm sends <lf>, Stamp waits for the line feed sees it at the SERIN , the Stamp transmits "!" , Roborealm sees the exclamation then waits for the data string, Stamp sends data , Roborealm assigns data to Input variable, Stamp sends <lf> signalling end of data.
Going back to the "wait" I posted by mistake in the previous post, at one point I used the string wait in the Roborealm recieve sequence, wait[noparse][[/noparse]input]<lf>, it works just as well as sending the "!"·Roborealm is·just looking for a matching string.
I hope this is a little clearer, sorry I can't help with the prop but looking at your debug statements it looks along the right lines.
Jeff T.
In my case I had to send data before RR would goto the recieve sequence. It didn't matter what the string was. I had to place a serial input line in the BS2 code to wait and match the string before I transmitted my data to RR or the data displayed in RR would bounce around erratically. So a RR send sequence is a must.
Sending data to RR can be one continuous string, for example if the recieve sequence in RR is.... mydata[noparse][[/noparse]Input]<cr>.......and you want to send the data value 123 you would send the string "mydata123",CR ( I changed from line feed to carriage return·both work ). Input would then contain the value 123, this value can be operated on directly in VB script.
If you succeed in this first part and need a pointer on how to access the new variable with VB script I think I can help with that..
hope this helps
Jeff T.
http://forums.parallax.com/forums/default.aspx?f=25&m=200247&p=1
Jeff T.
Do you have that code for me? Ive been struggeling for a weeks now!
I just want to receive the values that rbr spits out. And just for debugging i need the propeller to send it back.
Please help me out!!!!