loading
 
Boe Bot Serial Communication
Anonymous
17 year
Hi Guys,
I am running this bs2 code on my Boe Bot and vb script in roborealm. And I am not sure how to use the serial command window on roborealm. I can connect to my eb500 bluetooth with roborealm, but I am not sure how to set up the serial part of roborealm. The variables are being sent but Boe Bot just jerks around in circles. can anyone help?
Thanks
Tom

'-----[I/O Definitions]--------------------------------------
LMotor CON 15
RMotor CON 14
'-----[Constants]--------------------------------------------
'-----[Variables]--------------------------------------------
left_motor VAR Byte
right_motor VAR Byte
'-----[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
'-----[Main Code]--------------------------------------------
Main:
'Wait for a command
SERIN 0,84, [DEC left_motor,right_motor]
PULSOUT LMotor,left_motor
PULSOUT RMotor,right_motor
GOTO Main



vb

' initialize our start motor values to neutral
  left_base = 750
  right_base = 750

  ' get the size (width or height) of the current
  ' bounding box
  size = GetVariable("COG_BOX_SIZE")

  ' if it is equal to "" then no object was detected
  if size <> "" then

    ' get the horizontal center of gravity found by the COG
    ' module
    cogX = GetVariable("COG_X")
    ' if it is less than 75 the blob is on the left side
    ' of the screen so move that way
    if cogX < 75 then
      left_base = 750-(80-cogX)/2
      right_base = 750
    ' otherwise move to the right if above 85 pixels (and no
    ' movement if 75 < cogX < 85 )
    elseif cogX > 85 then
      left_base = 750
      right_base = 750-(cogX-80)/2
    end if

    ' if the ball is too close then we have to move backwards
    if (size>40) then
      left_motor = left_base+((size-40)*2)
      right_motor = right_base+((size-40)*2)
    ' otherwise move forward
    else
      left_motor = left_base-((40-size)*2)
      right_motor = right_base-((40-size)*2)
    end if

    ' set the final motor values to be picked up by
    ' the SSC module
    SetVariable "LEFT_MOTOR", left_motor
    SetVariable "RIGHT_MOTOR", right_motor

    ' now lets work on the tilt ... grab the current
    ' tilt value
    tilt = GetVariable("TILT")
    ' if it was not set then default to 220 (in our case
    ' this is horizontal to the floor)
    if tilt = "" then
        tilt = 220
    end if

    ' if the blob is below 55 then tilt down up a bit more
    ' otherwise tilt up a little more
    cogY = GetVariable("COG_Y")
    if cogY < 55 then
        tilt = tilt - (60-cogY)/5
    elseif cogY > 65 then
        tilt = tilt + (cogY-60)/5
    end if

    ' we don't want to look up more than horizontal to the
    ' floor as we don't expect the
    ' ball to be on the ceiling
    if tilt > 220 then
      tilt = 220
    end if

    ' and set that value for the SSC module too
    SetVariable "TILT", tilt

  end if


I am only sending the motor variables
Anonymous 17 year
Tom,

Try what the Parallax forums have mentioned (making the motor values 16 bits) and see if that makes a difference. Note that I assume you are using something like

(single backslash)[left_motor](single backslash)[right_motor]

correct? When you switch your PBasic program to accept 16 bits you will need to change the above to double backslashes since a single backslash will only transmit 8 bits over serial whereas a double will do 16. Or you can keep that the same but do the cast of 8 to 16 bits in the stamp before sending them to the PULSOUT motor coordinates.

STeven.
Anonymous 17 year
When I add the slashes it does not work at all. sorry about the other posts related to this one. I press wrong button to reply.
Boe Bot Serial Communication
Anonymous
17 year
Tom,

Are you using the most current version of RoboRealm? The double slash technique was added about two weeks ago or so. Let us know if you still have an issue and we will investigate further.

STeven.
Anonymous 17 year
Hi STeven,
I am using roborealm I downloaded yesterday. I am still having problem. When I add the slashes Boe Bot will not respond at all. Without slashes Boe bot will sporadically turn left only and it will not back up at all. I do not know about the cast thing you mentioned earlier, can you give me alittle more info on that.
Thanks
Tom
P.S. Is the Boe Bot plug in almost ready? I am going nuts here.....lol
Anonymous 17 year
STeven,
Can you tell me exactly what the form of data is when it goes through serial port from roborealm? I am sending 2 variables and I also need to know how they start and end if I am to have any hope of making this work correctly. Forgive my ignorance on this subject, but I am trying to learn as I go.
Thanks
Tom
Anonymous 17 year
Hi Again Steven,
I have discovered a problem with my eb500 bluetooth device. I am sure that is why I have not been able to use the serial setup in Roborealm. I  will get a new one and let you know what happens.
Tom
Anonymous 17 year
Tom,

We tries the code you supplied with the Boe-Bot and found that there are some modifications that need to be made. Below is the robo-file that you can use to test the connection (try using the serial cord connection instead of the bluetooth for now). Note that the serial module has a cr at the end of the left and right motor variables. This cr is used to check in the boe-bot that everything was transmitted correcting. Using the robo-file and the following boe-bot program we were able to get the boe bot to turn based on the position of a red object. Give it a try and see if it improves what you currently have.

Let us know how it goes. We are working on a boe-bot module that will be ready in a week or two but you should be able to use the serial module to get started.


' {$STAMP BS2}
' {$PBASIC 2.5}

'-----[I/O Definitions]--------------------------------------
LMotor CON 15
RMotor CON 14
'-----[Constants]--------------------------------------------
'-----[Variables]--------------------------------------------
rcv_data VAR Byte(9) ' Array
left_motor VAR Word
right_motor VAR Word
delim VAR Byte
'-----[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
'-----[Main Code]--------------------------------------------
Main:
'Wait for a command
SERIN 16, 84, 20, xmitFailed, [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
program.robo
Anonymous 17 year
Hi STeven,
Thanks so much for taking the time to do this. When I tried to load the Bs2 code my basic stamp editor would not let me load the second backslash in the following line :
SERIN 16, 84, 20, xmitFailed, [STR rcv_data\\9]
The error stated     expected a constant, variable, unary operator, or '('  with the second backslash highlighted.
I am using Basic Stamp Editor 2.2 with pbasic 2.5

Thanks
Tom
Anonymous 17 year
I do not know why the last post got 4 slashes there should only be 2.
slashslash9
Anonymous 17 year
Tom,

there is a problem with the forum posting code ... it doubles up the backslash on any posted code. Just translate each double one to a single backslash. We'll see about fixing that problem.

STeven.
Anonymous 17 year
Hi STeven,
Thank You for the work you have done so far. I have not been able to get the code to work yet. My eb500 connects ok when robo program starts, but the servos do not respond to movement of red object. I can see the variables changing but it has no effect on Boe Bot. A similar thing happened with MSRS. When I switched from MSRS version 1.0 to version 1.5 and tried the tutorials that had worked with 1.0 my eb500 would connect but servos would not respond. When I switched back to version 1.0 everything worked fine. I dont know if this helps at all, but I figured I would mention it since the behavior is very similar.
Thanks Again
Tom
Anonymous 17 year
Tom,

Check your motor pins. The code we posted was using pin 15 and 14 which are not the ones the BoeBot manual says to use.

If the pins check out but a freqout after the serial command to hear if the serial command is completing correctly. If not, check that the serial module has the <cr> at the end.

Also note that the \9 at the end of the read serial command was in fact just one backslash as apposed to the doubling error that the forum caused (which is now hopefully fixed).

If all that does not work then hard code some values that increment to even see if you can move the servo's at all.

STeven.
Anonymous 17 year
Hi Steven,
I have double checked servo connections. I can tell you that when I turn the Boe Bot on it slowly turns in place. When I start roborealm the green light on the eb500 lights up. Roborealm opens and I can wave a red object in front of cam and roborealm responds the way it should, but the Boe Bot continues to slowly turn around in place as it does before I start roborealm. I suspect that maybe my dongle may be incompatible. I am using a kensington bluetooth usb adapter 2.0 What kind are you using?
Tom
Anonymous 17 year
Tom,

quick thought .. your script was using pin 0 for serin ... we were using pin 16 which is used when you have a direct serial cable connected to the BOE. Either try with a serial cable or switch the serin number to 0 like you had it.

We only tried with the serial cable and did not try this with BT just yet.

STeven.
Anonymous 17 year
Thanks STeven, I will give that a try today.
Tom
Anonymous 17 year
Hi Steven,
I am still unable to get any predictable results. One thing that I am noticeing is that something seems to be loading up. I have tried with and without the serial cable and I have had similar behaviors for both. I get no response to variable changes unless I bring object very close to cam, when I do the servos will speed up and stay in the same state even after I take the object away. The only way to change the state of the servos after this happens is to reset the boe bot. This happens with the eb500 removed from BOE as well. So I'm thinking it may be related to the memory use on the bs2. I am not experienced enough to remedy this problem, but I hope this information helps in the debugging.
Thanks
Tom
Anonymous 17 year
Tom,

Can you try the other programs that come with the BoeBot to see if they still function as expected? At this point you may just want to verify that your BoeBot is functioning normally. Are you able to run the servos at different speeds even when you code those values directly into a PBasic program? I.e. use a for loop that slowly increases and decreases the motor values.

STeven.
Anonymous 17 year
Hi Steven,
My boe bot works fine with other code. As a matter of fact this code works to test eb500 and 1 servo. I am using the program.robo that you posted and this short bs2 code works with it to test communication and servo function. This code also works with direct serial connection when you change serin pin to 16

x VAR Word
main:
SERIN 0,84,[DEC x]
PULSOUT 15,x
PAUSE 5
GOTO main

Thanks
Tom
Anonymous 17 year

Note that this code will not work with the robo-file that we posted. The issue is with the use of "DEC" in the serin. That looks for an ascii string that represents a number. The posted robo-file transmits a 4 byte number ... not an ascii string. You will have to change the serial module to output

[cog_x]<cr>

i.e. remove the double \\ in front of the variable. You also need the <cr> since the "DEC" in pbasic looks for the first non-digit ascii code in order to know that the number is complete.

Try that change with the above code that you posted and see if you have better success.

STeven.
Anonymous 17 year
Hi Steven,
Now I'm getting confused...lol  There is no double slash in the robo file you posted. The Boe Bot is running with the following code loaded on it and the robo code attached.
' {$STAMP BS2}
' {$PBASIC 2.5}

x VAR Word
y VAR Word
main:
SERIN 0,84,[DEC x,y]
PULSOUT 15,x
PULSOUT 14,y
PAUSE 5
GOTO main

The only thing that is not working is that Boe Bot will not back up, but it will follow.

Tom

Anonymous 17 year
Heres the robo file
program.robo
Anonymous 17 year
Hi Steven,
The boe bot is not following to well. But is responding to moving a red object.
Tom
Anonymous 17 year
Great! That's good news.

When you say not following too well can you be more specific? Does it require you to move the ball slowly? Does it not move fast enough? Is it's movement jerky?

Thanks,
STeven.
Tom Amara  [13 posts] 17 year
Hi STeven
I will make a video and post it on you tube so you can see whats going on. I will try to get it done today.
Tom
Anonymous 17 year
STeven,
We have finaly got the Boe Bot with eb500 bluetooth working perfectly.It works perfectly with the color tracking tutorial. With your help and that of Jeff who has some posts here related to the same project, it is working. We made some changes to the vb script as well as the Bs2 code and the send sequence. The changes are as follows:

Bs2 code

' {$STAMP BS2}
' {$PBASIC 2.5}
x VAR Word
y VAR Word
main:
SERIN 0,84,[WAIT ("!"),DEC4 x,DEC4 y]
PULSOUT  14, x
PULSOUT  15, y
PAUSE 5
GOTO main


VB script

  ' initialize our start motor values to neutral
  left_base = 750
  right_base = 750

  ' get current image size
  width = GetVariable("IMAGE_WIDTH")
  center = width / 2

  ' get the size (width or height) of the current
  ' bounding box
  size = GetVariable("COG_BOX_SIZE")

  ' if it is equal to "" then no object was detected
  if size <> "" then

    ' get the horizontal center of gravity found by the COG
    ' module
    cogX = GetVariable("COG_X")
    ' if it is less than 75 the blob is on the left side
    ' of the screen so move that way
    if cogX < center-5 then
      left_base = 750-(center-cogX)/2
      right_base = 750
    ' otherwise move to the right if above 85 pixels (and no
    ' movement if 75 < cogX < 85 )
    elseif cogX > center+5 then
      left_base = 750
      right_base = 750-(cogX-center)/2
    end if

    ' if the ball is too close then we have to move backwards
    if (size>90) then
left_motor = left_base-((40-size)*2)
      right_motor = right_base+((40-size)*2)
' otherwise move forward
    else
      left_motor = left_base-((size-40)*2)
      right_motor = right_base+((size-40)*2)
  
    
    end if

    ' set the final motor values to be picked up by
    ' the SSC module
    SetVariable "LEFT_MOTOR", CInt(left_motor)
    SetVariable "RIGHT_MOTOR", CInt(right_motor)

    
end if

send sequence

! [Left_motor] <lf> [Right_motor] <lf>


If you see ways of improving this code we would appreciate anything you can contribute.

Thanks for all your help
Tom
Anonymous 17 year
Tom,

That's fantastic! When do we get to see a video??

The code looks good and we don't have any suggestions at this time. If we think of something we'll post it here!

STeven.
Anonymous 17 year
Hi STeven,
I am working on the video. Of all things to happen I need to get some batteries.....lol I should have some by this evening.
Tom
Anonymous 17 year
Hi STeven,
Here is the address of the video. I did some more fine tuning of software.
http://www.youtube.com/watch?v=mngim02Cqec
Tom
Anonymous 17 year
Hi Guys,
I am working on getting the Boe Bot to stay still when no object is detected. Any thoughts?
Tom
Anonymous 17 year
Yes, you can check the COG_BOX_SIZE and if that is > 20 then you probably have an object in view. To see that working check out the robo-file in another forum post at http://www.roborealm.com/forum/index.php?forum_id=806

I'm assuming that you are using the COG?

STeven.
Anonymous 17 year
Tom,

Thanks for posting the video above!! It shows some nice control of the BoeBot using video. Is that a kitty-cat toy that you are using for the red ball? I'm enjoying the comparison of play with your robot like playing with your cat :-)

Its interesting in that using the size of the red ball one can do a simplistic depth perception in that the robot will move forwards and backwards based on the size of the ball. Perhaps you can now turn the BoeBot into a soccer playing robot?

Also which camera did you use on the BoeBot?

Great stuff!
STeven.
Anonymous 17 year
Hi STeven,
Thanks for the advise, I think I will have to set motors to 750 near end of code. The ball is styrofoam painted red on a shish kabob skewer. The camera is one of those cheap spy cams from ebay ( about $30.00 ) with receiver. I'm not sure if you can get those cams with different frequencies, but the Soccer Boe Bot sounds like fun project.
Tom
Anonymous 17 year
Here is an update to vb script program for color tracking Boe Bot. Some bugs have been worked out.

Tom

  ' initialize our start motor values to neutral
left_base = 750
right_base = 750
  

  ' get current image size
  width = GetVariable("IMAGE_WIDTH")
  center = width / 2

  ' get the size (width or height) of the current
  ' bounding box
  size = GetVariable("COG_BOX_SIZE")

  ' if it is equal to "" then no object was detected
  if size <> "" then

    ' get the horizontal center of gravity found by the COG
    ' module
    cogX = GetVariable("COG_X")
    ' if it is less than 75 the blob is on the left side
    ' of the screen so move that way
    if cogX < center-5 then
      left_base = 750-(center-cogX)/2
      right_base = 750
    ' otherwise move to the right if above 85 pixels (and no
    ' movement if 75 < cogX < 85 )
    elseif cogX > center+5 then
      left_base = 750
      right_base = 750+(cogX-center)/2
    end if
    ' if the ball is too close then we have to move backwards
    if (size>90) then
left_motor = left_base+((40-size)*2)
      right_motor = right_base-((40-size)*2)
' otherwise move forward
    else
left_motor = left_base-((size-40)*2)
      right_motor = right_base+((size-40)*2)
    end if
    ' set the final motor values to be picked up by
    ' the SSC module
end if
if (size<20) then
left_motor=750
right_motor=750
end if
SetVariable "LEFT_MOTOR", CInt(left_motor)
SetVariable "RIGHT_MOTOR", CInt(right_motor)

Anonymous 17 year
Hi Guys,
Heres a new video of Bluetooth Boe Bot with Pan and Tilt accessory running with Roborealm.

http://www.youtube.com/watch?v=gbf0zaxWjvI

Tom
Anonymous 17 year

Very cool!! Can you explain or do you have a link that describes the pan/tilt system more? Perhaps a quick parts list of how you've accomplished this would help others achieve the same thing!

Nice!

STeven.
Anonymous 17 year
Hi STeven,
The parts for the pan and tilt are cnc machined from expanded pvc. The unit uses 2 mini servos and a spycam I purchased on ebay. The bumper uses 4 small springs and 4-40 screws. The super bright leds were purchased from ebay as well. The whole assembly minus the cam ( cam availible seperatly on ebay ) is availible on ebay, but for those who wish to make their own see the attached pics and email me if you have any questions.

Tom
harms1@optonline.net



Anyone try this yet
Tom Amara  [13 posts]
17 year
I was wondering if anyone has tried this setup and what they think of it.
Tom
[test]\n in the boe bot .robo file
grindel  [5 posts]
16 year
I am still trying to wrap my head around serial communications.  I don't see where the "[test]\n" in the receive sequence of  the serial command is doing anything in this boe bot communication.  Why would the \n be in there in the first place?  In the serial communications section, it mentions it in examples, but I find them hard to understand.  I'll quote them here:
"
[binary_input_1]:\[binary_input_2]

which would read binary numbers delimited by ':' and ended with \r into the two variables (\1024:\667\n) but

[ascii_input_1]:[ascii_input_2]

would read in two ascii numbers into the two variables (1024:667\n). "

I have tried transmitting the \n to roborealm, but maybe I am not doing it right.

Also, when I run the boe bot .robo file "test" doesn't show up as one of the variables.  What is the preferred method of initializing this variable?  Would it show up if I ever got it to write?

As mentioned in an earlier thread, I am trying to write a value to a variable from a propeller microcontroller, I can see the correct inputs in hyperterminal, but I am doing something wrong in roborealm because it never correctly sets the variable.  

I hope this is not too much of a threadjack, but I wanted to respond in the same thread as the .robo files in question.
Anonymous 16 year
grindel,

The difference between the two is that the // mean that a binary number (4byte number) will be transmitted as apposed to a variable amount depending on the size of the number being transmitted in text.

The \\n is the escape sequence for a newline that indicates the end of a text message that should be read into [test].

Thus the line

[test]\\n

will read in anything sent from the BoeBot until a newline is seen. Then it will start reading again and again for as many messages come from the BoeBot overwriting the value within the variable "test".

Keep in mind that the \\n is actually just a single byte.

Note that the "test" variable will only be created when something was read.

Does that make any better sense?

STeven.
Anonymous 16 year
Ok, steven... Hmmm so this [test]\n should be in the large box under receive sequence, in the roborealm serial module? For some reason, it is saying that it is connected to my BS2 board, and I am sending from the BS2 board, but the variable -test- is not being created, and I have tried this about a thousand different ways.... in my BS2 code, I am sending the dec number 65, over and over, and never seeing the -test- variable created... I'm not sure that I understand how the receive section of the serial module actually works, or how to correctly use the insert field, if the module is going to create the variable when it receives the information... Does any of this make any sense?
Anonymous 16 year
Correct, it only creates the variable when it receives the data. One thing to note is that based on [test]\n RoboRealm will wait for a newline to signal the end of the value for 'test'. Thus you will need to send 65 and then 10 in order to signal the end of the variable. OR you could specify \[test] without the \n and with a single '\' in front of it. This tells RoboRealm that the variable test should be created using a single byte that is received from the serial stream. If you want to use 4 bytes (a word) use a double '\\' instead.

Does this help?

STeven.
Anonymous 16 year
I dunno, I am still having problems, and it must be something simple.... I cannot get the variable to create, and thus no data.... I will attach my simple test code here:

STAMP CODE:

'   {$STAMP BS2}
'   {$PBASIC 2.5}

st:
SEROUT 16,16468, [DEC 65, 10]
GOTO st



The way that I am understanding the 16468, should be the 8 data bits, with no parity, the 16 should be the correct pin, although I have tried others...

and the simple robofile is also attached here:

It must be something really simple that I am doing wrong, but for the life of me, I have not been able to figure what I am continually doing wrong.

I really appreciate your help!




program.robo
Steve Joblin from United States  [18 posts] 16 year
It is a rather long thread, so appologies in advance if I am way off base, but isn't the idea for the Stamp to "read" the serial string from RoboRealm?  That is, shouldn't you be using SERIN, not SEROUT?
Anonymous 16 year
I'm sorry Steve, I should have clarified a little better in the post, I just jumped in on this thread at the end, and am not the original person that posted.  my issue is getting information from the stamp. I am working on having the stamp read information from sensors, and then input that data into RR. In my little example, I am trying to send the number 65, and have it read by RR, and stored as a variable. If you could look at my examples, and tell me why I am not getting a variable generated that holds the value, sent from the stamp, I would be extremely grateful. Sorry again, that I didn't clkarify a little better, but the thread seemed to be dealing with similar issues, and I was trying to avoid starting another thread.... Ooops!
Anonymous 16 year
This is the VB script running on roborealm in the above video.

  ' initialize our start motor values to neutral
left_base = 750
right_base = 750
tilt = 700  

  ' get current image size
  width = GetVariable("IMAGE_WIDTH")
  center = width / 2

  ' get the size (width or height) of the current
  ' bounding box
  size = GetVariable("COG_BOX_SIZE")

  ' if it is equal to "" then no object was detected
  if size <> "" then

    ' get the horizontal center of gravity found by the COG
    ' module
    cogX = GetVariable("COG_X")
    ' if it is less than 75 the blob is on the left side
    ' of the screen so move that way
    if cogX < center-5 then
  left_base = 750
      right_base = 750-(cogX-center)/2  
    ' otherwise move to the right if above 85 pixels (and no
    ' movement if 75 < cogX < 85 )
    elseif cogX > center+5 then
left_base = 750+(center-cogX)/2
      right_base = 750
      
    end if
    ' if the ball is too close then we have to move backwards
size = GetVariable("COG_BOX_SIZE")
  if  (size > 60)  then
left_motor = left_base+((60-size)*2)
right_motor = right_base-((60-size)*2)
    else
left_motor = left_base-((size-60)*3)
     right_motor = right_base+((size-60)*3)
   end if
    ' set the final motor values to be picked up by
    ' the SSC module
end if
if (size<10) then
left_motor=750
right_motor=750
end if
SetVariable "LEFT_MOTOR", CInt(left_motor)
SetVariable "RIGHT_MOTOR", CInt(right_motor)
' now lets work on the tilt ... grab the current
    ' tilt value
    tilt = GetVariable("TILT")
    ' if it was not set then default to 700 (in our case
    ' this is horizontal to the floor)
    if tilt = "" then
        tilt = 700
    end if

    ' if the blob is below 55 then tilt down up a bit more
    ' otherwise tilt up a little more
    cogY = GetVariable("COG_Y")
    if cogY < 55 then
        tilt = tilt - (60-cogY)/5
    elseif cogY > 65 then
        tilt = tilt + (cogY-60)/5
    end if
    ' we don't want to look up more than horizontal to the
    ' floor as we don't expect the
    ' ball to be on the ceiling
   if (cogY<5)or(cogY>105) then
tilt =700
end if

    ' and set that value for the bs2
    SetVariable "TILT", CInt(tilt)

Anonymous 16 year
If I remember correctly , This was the send sequence I used.

! [Left_motor] <lf> [Right_motor] <lf> [Tilt] <lf>

I am sorry I have not posted this sooner. I have been away taking care of my mom who was battling cancer. She is doing fine now.
Tom A
Anonymous 16 year
I'm trying to do the same and I'm having some trouble. I used the exact code above and roborealm shows that it recognizes the ball I'm using and my BOE even flashes continuously. But nothing happens.
   One reason that nothing is happening is probably because I'm not using the eb500 properly. I know that the eb500 allows for the pc to communicate to the board wirelessly, but I just want to have the boebot connected via serial. How would the code be different?
Steve Joblin from United States  [18 posts] 16 year
I think the code should be the same... double check your settings in the "Serial" section to make sure you are actually communicating with all the correct settings (speed, port, etc.).
Anonymous 16 year
thanks for the reply! I got it working!
However, when I tried using the eb500 instead it didn't work. When I ran the .robo roborealm comes with the error that roborealm needs to close. I know that the eb500 is connected to the pc and I ran the exact vb code and .robo that you had.
   Do you know why it freezes?

Thanks for the help!
Anonymous 16 year
the .robo file you posted a few post prior also freezes up on roborealm. I'm sure it ran fine on your pc. What could be the problem?
Anonymous 16 year
I've managed to fix the freezing up problem. Seems to have been caused by problems with my bluetooth adapter. The Boebot can move, but it only move forward and not back. Any help?
Anonymous 16 year
Can you post the code you are using. I started this thread and have a robot set up that I can test your code on.
Tom
Anonymous 16 year
I basically built my boebot off of yours. And because nothing is fully functional yet, I have not added anything. I only altered the camera size.
  On another thread I talked about another issue that I had. The frame rate greatly decreases with this code. Can you run it and see if that happens for you? Thanks!

Le
program.robo
Anonymous 16 year
btw, that bot of yours looks awesome!
I tried troubleshooting a bit more. And it seems like after I finally resolved my bluetooth issues, the fps is now always low(instead of before where only if the ball goes off the camera then roborealm starts lagging). Because of the constant lag, the boebot no longer moves at all. If this code works for you, would that mean that I have a camera issue?
    Again, thanks for your help
Anonymous 16 year
more updates...
  If I decrease the baudrate to 2400 instead of 9600, it seems like(at least for now) that the lag has stopped. Even the serial modules shows that the positions are being transmitted. However, the boebot does nothing!

' {$STAMP BS2}
' {$PBASIC 2.5}
PAUSE 1000
x VAR Word
y VAR Word

main:
'Connect to the remote device

SERIN 0,396,[WAIT ("!"),DEC4 x,DEC4 y]

PULSOUT  14, x
PULSOUT  15, y

GOTO main
Steve Joblin from United States  [18 posts] 16 year
are you sending a "!" as part of your SEROUT?  Are you sure that 396 is the correct value for receiving a 2400 baud signal?
Anonymous 16 year
i have a table which translates that  for 8 data bits, no parity through line driver, the val is 396 for 2400 baud.
  I am sending
! [Left_motor] <lf> [Right_motor] <lf>
like Tom did.
And this used to work. But now even though the console shows that it is being sent and even the eb500's light is on, the bot still doesnt move.
Anonymous 16 year
I notice that different things happen if I change the COM port. Just want to check that the outgoing port is the correct one to use for serial
Anonymous 16 year
ok, after further hacking I finally got it back to the way is was b4. Now it still has problem in going other directions. Here is the .robo with moving forward and backward commented out(it only has the turn towards red ball function).
Anonymous 16 year
here it is...
program.robo
Anonymous 16 year
Ah, it finally works now! I guess I relied too much upon the original algorithm. So I changed the algorithm to fit what I needed: Boe Bot soccer goalie.
program.robo
Anonymous 16 year
Glad it working.
Tom
Edward from Spain  [10 posts] 15 year
Hello, I followed the "Color Object Tracking"  tutorial and I also reviewed this post. After that I have created the roborealm project and the boebot doesn't work,doesn't move anything. I don't understand why it's happens. I use the serial comunications without eb500.
I have upload my project. can anybody look my project and say me if all is good?


Thank you
program.robo
Anonymous 15 year
Edward,

Yes, two current issues. One, you need to specify 9600 buad in the serial module .. it seems that you did not have anything set when we loaded in your robofile.

Second, the SERIN command needs a 16 instead of a 0 as the first parameter since you are using COM1 or the physical connection. 0 works with the bluetooth but you need 16 if you are to run it over the debugging COM1.

We will continue to investigate your script further as even when it does communicate with the boebot it does not appear to be sending out the right motor values.

STeven.
Edward from Spain  [10 posts] 15 year
Steven Gentner,thanks for the reply!

I have changed the buad to 9600 and I have used the parameter SERIN 16 in Bs2,but the boebot doesn't stop to move in circles. After I have read this post,now the boebot is working well.

I want to do the wireless connection , and I want to add a wireless cam, too.
I know I have to buy the bluetooth adapter eb500, a bluetooth adabter for pc, a wireless cam but how does it connect to PC?
Can you tell me the components that I need, please?

Finally, I change the Serin to 0. In Serial communications I can't select port com, because I will use bluetooth. Do I use the USB_HID in Roborealm?


Thank you
Anonymous 15 year
Edward,

The camera would need to transmit its signal back to the PC and then a USB digitizer will be needed to get the video into the PC. So you need two components like:

http://www.geeks.com/details.asp?InvtId=203C-50MW-N&AID=10440852&CJPID=2194341&cm_ven=CJ&cm_pla=2194341&cm_ite=REDIRECT-ProductSpecific_Text_9-11-2006&cm_cat=1920981

and

http://www.hauppauge.com/pages/products/data_usblive.html

to get the image into the camera. See the tutorial on

http://www.roborealm.com/tutorial/ball_picker/slide010.php

as to how we did that.

Yes, you can select the COM port in serial with Bluetooth ... the Bluetooth connection looks like a serial COM port to the PC. So the change is easy from a physical serial cable to bluetooth.

STeven.
Steve Joblin from United States  [18 posts] 15 year
The other alternative to the recommended USBLIVE product noted above is to use a TV Tuner video card.  Hauppauge makes one and I've been using it on my laptop with no problems.
Anonymous 15 year
Good morning, I am using a bluetooth and eb500 with windows vista system. Every time that I click "run" the program tell me "Could not find the file ScriptSite.dll Please place in the c/windows/system32 You will find the ScriptSite.dll in the roborealm folder". After this I copy and paste this file in the folder system32 but always it tell me the same, and I can't sent date to Boe.

I have 1.8.23.4 version of Roborealm.

Anybody can help me?



Thank you
Edward from Spain  [10 posts] 15 year
Hello, I would like to make the vertical tilt movement but I don't know how introduce the variables in BS2. I have this in BS2:

x VAR Word
y VAR Word

main:
SERIN 0,84,[WAIT ("!"),DEC4 x,DEC4 y]
PULSOUT  14, x
PULSOUT  15, y
PAUSE 5
GOTO main

and  the vbscript:

  ' initialize our start motor values to neutral
left_base = 750
right_base = 750
tilt = 700  

  ' get current image size
  width = GetVariable("IMAGE_WIDTH")
  center = width / 2

  ' get the size (width or height) of the current
  ' bounding box
  size = GetVariable("COG_BOX_SIZE")

  ' if it is equal to "" then no object was detected
  if size <> "" then

    ' get the horizontal center of gravity found by the COG
    ' module
    cogX = GetVariable("COG_X")
    ' if it is less than 75 the blob is on the left side
    ' of the screen so move that way
    if cogX < center-5 then
  left_base = 750
      right_base = 750-(cogX-center)/2  
    ' otherwise move to the right if above 85 pixels (and no
    ' movement if 75 < cogX < 85 )
    elseif cogX > center+5 then
left_base = 750+(center-cogX)/2
      right_base = 750
      
    end if
    ' if the ball is too close then we have to move backwards
size = GetVariable("COG_BOX_SIZE")
  if  (size > 60)  then
left_motor = left_base+((60-size)*2)
right_motor = right_base-((60-size)*2)
    else
left_motor = left_base-((size-60)*3)
     right_motor = right_base+((size-60)*3)
   end if
    ' set the final motor values to be picked up by
    ' the SSC module
end if
if (size<10) then
left_motor=750
right_motor=750
end if
SetVariable "LEFT_MOTOR", CInt(left_motor)
SetVariable "RIGHT_MOTOR", CInt(right_motor)
' now lets work on the tilt ... grab the current
    ' tilt value
    tilt = GetVariable("TILT")
    ' if it was not set then default to 700 (in our case
    ' this is horizontal to the floor)
    if tilt = "" then
        tilt = 700
    end if

    ' if the blob is below 55 then tilt down up a bit more
    ' otherwise tilt up a little more
    cogY = GetVariable("COG_Y")
    if cogY < 55 then
        tilt = tilt - (60-cogY)/5
    elseif cogY > 65 then
        tilt = tilt + (cogY-60)/5
    end if
    ' we don't want to look up more than horizontal to the
    ' floor as we don't expect the
    ' ball to be on the ceiling
   if (cogY<5)or(cogY>105) then
tilt =700
end if

I saw this code in a previous post. He say that introduce in BS2    SetVariable "TILT", CInt(tilt)  but the Stamp editor has a error.

How can I insert the tilt variable in Bs2?

Thank you very much
Anonymous 15 year
Anonymous,

Try to use

regsvr32 ScriptSite.dll

in one of those folders. That will tell the Windows OS to register that component. OR try running RoboRealm as an Administrator at least once and it will try to do that too. (See the FAQ for more information)

http://www.roborealm.com/FAQ.php#q13

Albert,

The SetVariable is in RoboRealm in the VBScript module NOT in the BS2 code.

The two parts you have there seem about right. The part that you are missing is in the serial communication to the boebot. I assume you are using the serial module to send commands to the boebot. You will need to modify that send sequence to include the Y or tilt component.

so the send sequence would be something like

![Left_motor]<lf>[Right_motor]<lf>[tilt]<lf>

and your BS2 code would be

x VAR Word
y VAR Word
tilt VAR Word

main:
SERIN 0,84,[WAIT ("!"),DEC4 x,DEC4 y,DEC4 tilt]
PULSOUT  14, x
PULSOUT  15, y
PULSOUT  16, tilt
PAUSE 5
GOTO main

STeven.
Anonymous 15 year
Thank you very much. Now the RR it's running with vista.
Edward from Spain  [10 posts] 15 year
Hello Steven, I have changed the program but it doesn't work correctly. When I click "run" in RR the boe moves but after the 3 servo (vertical tilt movement) it gives a strong turn and later doesn't work anything.
I'm using the eb500,a battery of 9v, two servos (x,y) and a miniservo (tilt).

You have my project here, could you please take a look at it, to know if there are any mistakes?

and BS2 code (that you told me).  

x VAR Word
y VAR Word
tilt VAR Word

main:
SERIN 0,84,[WAIT ("!"),DEC4 x,DEC4 y,DEC4 tilt]
PULSOUT  14, x
PULSOUT  15, y
PULSOUT  13, tilt
PAUSE 5
GOTO main


Thank you for your time
program.robo
Anonymous 15 year
Has anyone tried to get the L2F light intensities?

I want to get the light intensity values of a photo resistor loaded on the Boe-Bot but I am not getting a handshake if I add code to receive 2 more values of buffer in basic stamp. Has anyone done that before?

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index