Syntax help
Can anyone help me to understand what is happening in the following lines by adding some detailed comments. Any help would be appreciated
rcv_data VAR Byte(9) ' Array
SERIN 16, 84, 20, xmitFailed, [noparse][[/noparse]STR rcv_data\9]
IF rcv_data(8)<>CR THEN xmitFailed
left_motor = rcv_data(0)|(rcv_data(1)<<8)
right_motor = rcv_data(4)|(rcv_data(5)<<8)
Thanks
Tom aka grumpy
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Robot vision is the the future, and Vision will take us there.
rcv_data VAR Byte(9) ' Array
SERIN 16, 84, 20, xmitFailed, [noparse][[/noparse]STR rcv_data\9]
IF rcv_data(8)<>CR THEN xmitFailed
left_motor = rcv_data(0)|(rcv_data(1)<<8)
right_motor = rcv_data(4)|(rcv_data(5)<<8)
Thanks
Tom aka grumpy
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Robot vision is the the future, and Vision will take us there.
Comments
rcv_data VAR Byte(9) ' Array ............Defines rcv_data as an array with 9 byte sized elements (0-8)
·SERIN 16, 84, 20, xmitFailed, [noparse][[/noparse]STR rcv_data\9] ..........Serial input at 9600 baud, 20 milisecond timeout, goes to xmitFailed if no data with the 20 miliseconds
IF rcv_data(8)<>CR THEN xmitFailed .............If the last character of the array is not a carriage return then goto xmitFailed
left_motor = rcv_data(0)|(rcv_data(1)<<8)
right_motor = rcv_data(4)|(rcv_data(5)<<8) .............these two lines really dont make sense, bit shifting left by 8 will always give zero and a bitwise OR will always give the result of data(0) and data(4) respectively so·the second part of the equation is pointless.
what is it you are trying to do Tom
Jeff T
Thanks for the info I do appreciate it alot. The piece of code is part of·a larger bs2 code for running Boe Bot bluetooth and roborealm. STeven and the team over at roborealm.com·are helping me realize my dream of Boe Bot vision. They are also working on a module for the Boe Boe. I am sure they can explain this code but I did not want to ask too much as I am sure they are busy with more important things then explaining code to newbies like me. I really do appreciate this forum and all that has been shared by the more experienced. I am learning quite abit from this forum and hope to be able contribute·something back·as I learn. Here is the complete code from Roborealm. This code runs on the BoeBot. If you download roborealm and would like the robo file written by the team at roborealm that runs in roborealm for the BoeBot with eb500 let me know.
Tom
' {$STAMP BS2}
' {$PBASIC 2.5}
'
[noparse][[/noparse]I/O Definitions]
LMotor CON 15
RMotor CON 14
'
[noparse][[/noparse]Constants]
'
[noparse][[/noparse]Variables]
rcv_data VAR Byte(9) ' Array
left_motor VAR Word
right_motor VAR Word
delim VAR Byte
'
[noparse][[/noparse]Initialization]
Initialize:
'Wait for the eb500 radio to be ready
'PAUSE 1000
'Set the initial state to hold
left_motor = 750
right_motor = 750
GOTO main
'
[noparse][[/noparse]Main Code]
Main:
'Wait for a command
SERIN 16, 84, 20, xmitFailed, [noparse][[/noparse]STR rcv_data\9]
IF rcv_data(8)<>CR THEN xmitFailed
left_motor = rcv_data(0)|(rcv_data(1)<<8)
right_motor = rcv_data(4)|(rcv_data(5)<<8)
xmitFailed:
PULSOUT LMotor, left_motor+10
PULSOUT RMotor, right_motor+10
GOTO Main
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Robot vision is the the future, and Vision will take us there.
I did DL Roborealm, I had it working pretty good but when I load a script and open the serial port it will run for 2 or 3 minutes then the frame rate will drop to like 3 FPS and I will lose comms. I have to stop the serial and it will be ok for another 2 minutes. Did you see anything like that?
I think its possibly my PC isn't up to it.
What I did in the script was modify the pan/tilt servo variables to a value I could transmit and feed straight into the pulsout, if it didn't mess up your set up too much maybe you could try it on your pan/tilt.
Jeff T
I could not get it to work at all. He is the robo file. http://www.roborealm.com/forum/program.php?id=751
Let me know how you make out. Be sure to change serial port to match yours.
Tom
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Robot vision is the the future, and Vision will take us there.
Here is the code for 1 servo connected to the Stamp, adjust the Pin assignment and baud to what you have.
x VAR Word
main:
SERIN 16,16468,[noparse][[/noparse]DEC x]
PULSOUT 0,x
PAUSE 15
GOTO main
Load the VB script
In the Roborealm serial interface set baud and com port and where it says send sequence insert this [noparse][[/noparse]PAN_SERVO]<lf>
open the connection and press OK
Attached is the VB script that just deals with the PAN variable
Jeff T.
I did have the frame rate die off when I was trying to make it work. Like you I restarted and it was fine for awhile. I did notice that I could kill the frame rate by bringing object very close to cam in an atempt to get some reaction from my Boe Bot. That has not happened since I downloaded the latest version of roborealm. Although my eb500 lights up when I start roborealm indicating a connection, my Boe Bot just turns slowly in place (as it does before I start roborealm) without reguard to changing variables in roborealm. I am begining to think that I have a compatability issue with my bluetooth dongle. I am using a kensington bluetooth usb adapter 2.0 What are you using?
Tom
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Robot vision is the the future, and Vision will take us there.
I am in early stages of prototyping Tom, and I am checking everything out via a hardwired serial cable. I wanted you to try the code in the last post, I figure if we can get one motor to react as we want then we can add more later. I noticed the cog would measure in fractions to half a pixel, which is not what we want to transmit to the Stamp , so I formatted it as an integer in the script.
One thought, my camera is wireless and set on a continuous rotation servo for the pan axis, so I am able to follow an object through 360 degrees. For the VB script to work for your set up you will need to delete the last IF THEN statement in the script or the servo will repeatedly keep targeting the cog then moving back to center·.
Jeff T.
I've been trying to follow along with your progress with RoboRealm since you asked if I had ever tried to use RR. I have an eb500 that I have not been able to get working. The BlueTooth software on my PC (Win XP SP2) seems to be working (I'm using a Belkin USB, Broadcom drivers that works just fine with several other Bluetooth devices). It sees the eb500, pairs with it OK and I can connect (I think) with HyperTerm on the BlueTooth Serial port· PC to eb500 (COMM 6 in my case, Comm 5 is the eb500 to PC port). Bluetooth and HT indicate that the eb500 is connected. However, I never get the connection LED on the eb500 to light and trying to communicate from my BOE/BS2 to the PC does nothing.·The BOE is bare except for the eb500 connected to the AppMod header. I put the eb500 back in the drawer and maybe I'll try it another day. Other things to do in any case. Good luck and I hope you colaberation with the folks a RR works out.
Steve
I have an update for ya. The code in my earlier post uses pin 16 which is for direct serial cable. Change to pin 0 for eb500 bluetooth or use direct serial cable. This code has only been tested sucessfully with serial cable.
Tom
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Robot vision is the the future, and Vision will take us there.