Porting PBASIC Boe-Bot code from BS2 to BS2px
Andy Lindsay (Parallax)
Posts: 1,919
BASIC Stamp upgrades are·NOT recommended for use with Stamps in Class kits and textbooks.
If you want to go through Stamps in Class material like What's a Microcontroller and Robotics with the Boe-Bot, use·the BASIC Stamp 2 included with the kit and avoid the temptation to upgrade.· Set aside·any money you saved on the kit over buying the parts indivudually for an upgrade in the future.· BASIC Stamp modules like the BASIC Stamp 2sx, 2p, 2pe, or 2px are·not recommended·for use with·Stamps in Class·kits.· Learn how to use the BASIC Stamp 2 on its own terms first, then upgrade later, and only if you really need to.· You'd be amazed at the projects you can accomplish with just the BASIC Stamp 2.· ·
Examples of what you·would have to do to every example program if you upgrade:
Robotics with the Boe-Bot is written for the BASIC Stamp 2.· If you are going to replace the BASIC Stamp 2 with a faster BASIC Stamp, like the BASIC Stamp 2sx, 2p or 2px, you'll need to update commands in the example programs that involve time measurements.· For example, let's say you replace the BASIC Stamp 2 with the BASIC Stamp 2px.· The following adjustments have to be made for timing.
·- Multiply all FREQOUT commands' Duration arguments by 6
·- Divide all FREQOUT commands' Freq arguments by 6
·- Multiply all PULSOUT commands' Duration arguments by 2.5
·-·Multiply all RCTIME command results by·0.375
·- Multiply all PULSIN command results by 0.4
To multiply by 2.5, you can use */640, and multiplying by 2.66 is about */ 682.· (*/ multiplies by a number of 256ths.)
Here are some examples of quick updates to time sensitive commands found in some Robotics with the Boe-Bot program examples.
FREQOUT 4, 1000, 3000 -> FREQOUT 4, 1000*6, 3000/6·· ' Piezospeaker
FREQOUT 8, 1, 38500 -> FREQOUT 8, 1*6, 38500/6········ ' IR detection
PULSOUT 12, 650 -> PULSOUT 12, 650*/640················· ' R servo forward
PULSOUT 13, 850 -> POLSOUT 13, 850*/640················· ' L servo forward
RCTIME 6, 1, time -> RCTIME 6, 1, time : time = time·** 24576
PULSIN 15, time· -> PULSIN 15,·time : time = time ** 26124
Three code examples are attached that demonstrate this "quick fix" for PBASIC Boe-Bot code examples for the BASIC Stamp 2px.· If you are using the BASIC Stamp 2p or 2sx, you'll need to look up the speed differences for FREQOUT, RCTIME, and PULSOUT in the BASIC Stamp manual and figure out how to adjust your code.·
You can also customize your code to work a variety of different BASIC Stamp modules with conditional compilation directives.· To get started with conditional compilation, open up the BASIC Stamp Editor's Help feature and look for #IF in the index.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Andy Lindsay
Education Department
Parallax, Inc.
Post Edited (Andy Lindsay (Parallax)) : 12/10/2008 2:21:35 AM GMT
If you want to go through Stamps in Class material like What's a Microcontroller and Robotics with the Boe-Bot, use·the BASIC Stamp 2 included with the kit and avoid the temptation to upgrade.· Set aside·any money you saved on the kit over buying the parts indivudually for an upgrade in the future.· BASIC Stamp modules like the BASIC Stamp 2sx, 2p, 2pe, or 2px are·not recommended·for use with·Stamps in Class·kits.· Learn how to use the BASIC Stamp 2 on its own terms first, then upgrade later, and only if you really need to.· You'd be amazed at the projects you can accomplish with just the BASIC Stamp 2.· ·
Examples of what you·would have to do to every example program if you upgrade:
Robotics with the Boe-Bot is written for the BASIC Stamp 2.· If you are going to replace the BASIC Stamp 2 with a faster BASIC Stamp, like the BASIC Stamp 2sx, 2p or 2px, you'll need to update commands in the example programs that involve time measurements.· For example, let's say you replace the BASIC Stamp 2 with the BASIC Stamp 2px.· The following adjustments have to be made for timing.
·- Multiply all FREQOUT commands' Duration arguments by 6
·- Divide all FREQOUT commands' Freq arguments by 6
·- Multiply all PULSOUT commands' Duration arguments by 2.5
·-·Multiply all RCTIME command results by·0.375
·- Multiply all PULSIN command results by 0.4
To multiply by 2.5, you can use */640, and multiplying by 2.66 is about */ 682.· (*/ multiplies by a number of 256ths.)
Here are some examples of quick updates to time sensitive commands found in some Robotics with the Boe-Bot program examples.
FREQOUT 4, 1000, 3000 -> FREQOUT 4, 1000*6, 3000/6·· ' Piezospeaker
FREQOUT 8, 1, 38500 -> FREQOUT 8, 1*6, 38500/6········ ' IR detection
PULSOUT 12, 650 -> PULSOUT 12, 650*/640················· ' R servo forward
PULSOUT 13, 850 -> POLSOUT 13, 850*/640················· ' L servo forward
RCTIME 6, 1, time -> RCTIME 6, 1, time : time = time·** 24576
PULSIN 15, time· -> PULSIN 15,·time : time = time ** 26124
Three code examples are attached that demonstrate this "quick fix" for PBASIC Boe-Bot code examples for the BASIC Stamp 2px.· If you are using the BASIC Stamp 2p or 2sx, you'll need to look up the speed differences for FREQOUT, RCTIME, and PULSOUT in the BASIC Stamp manual and figure out how to adjust your code.·
You can also customize your code to work a variety of different BASIC Stamp modules with conditional compilation directives.· To get started with conditional compilation, open up the BASIC Stamp Editor's Help feature and look for #IF in the index.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Andy Lindsay
Education Department
Parallax, Inc.
Post Edited (Andy Lindsay (Parallax)) : 12/10/2008 2:21:35 AM GMT
Comments
If you replace the IR detector that comes with the BoeBot with the Sharp IR device, you'll have to change the IR routines completely.
Post Edited (MovieMaker) : 12/10/2008 1:57:54 AM GMT
Could be that something is wired wrong. Because MOST of the tests wind up the same way. The robot chases it's tail like a dog or the ping bracket just has a muscle spasm.
:-(
I am going to attach some code that does work. But it is only a start. Let me find it.
We found out that I had a bad servo on my left wheel. It worked, but not correctly ie; the going around in circles like a dog.
Post Edited (MovieMaker) : 12/9/2008 5:16:27 AM GMT
When I change the code to match his, the robot acts really crazy or doesn't do much but just grunt.
Post Edited (MovieMaker) : 12/7/2008 3:16:19 AM GMT
Thanks, Mike. You are always a big help. Hope you have a nice holiday.
Post Edited (MovieMaker) : 12/7/2008 5:38:33 PM GMT
Also, for the instructions on centering your servos in the Robotics with the Boe-Bot text, it is crucial that you use the modification for the PULSOUT command when centering each servo.··See the first post in this thread for details.· The code adjustments have to be made to every example code in the book.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Andy Lindsay
Education Department
Parallax, Inc.
Post Edited (Andy Lindsay (Parallax)) : 12/9/2008 8:28:26 PM GMT
And, Andy, God Bless Your Sales Manager.
Everyone at Parallax is so wonderful to do business with and so helpful. Especially you.
Post Edited (MovieMaker) : 12/10/2008 2:15:42 AM GMT
' Make the Boe-Bot roll forward for three seconds.
' {$STAMP BS2p}
' {$PBASIC 2.5}
DEBUG "Program Running!"
counter VAR Word
FREQOUT 4, 2000, 3000 ' Signal program start/reset.
FOR counter = 1 TO 122 ' Run servos for 3 seconds.
PULSOUT 13, 850
PULSOUT 12, 650
PAUSE 20
NEXT
END"
heres an easy bit of code from the robotics with boe-bot. all i did was switch the stamp to bs2p... what this code DOES in real life to the boebot is make the wheels both go the same directions in lil pulses and never stop.
"' Robotics with the Boe-Bot - BoeBotForwardThreeSeconds.bs2
' Make the Boe-Bot roll forward for three seconds.
' {$STAMP BS2p}
' {$PBASIC 2.5}
DEBUG "Program Running!"
counter VAR Word
FREQOUT 4, 334, 500 ' Signal program start/reset. div by 6
FOR counter = 1 TO 122 ' Run servos for 3 seconds.
PULSOUT 13, 2125
PULSOUT 12, 1625 'both multiplied by 2.5
PAUSE 20
NEXT
END
"
heres the same code altered with your conversion...what it does in real life now is constantly spin both wheels one forward one backward. effectivly spinning the bot in circles. did i do something wrong?
and if i understand the process for bs2.
make the wheels spin at a value of 750
use screwdriver to turn the screw in the servor till the wheels stop
EDIT:
oops duh it should be 2.5 * 750 =1875 ill calibrate them to this and see if it works then
i set the switch on the boebot to position 1 and ran the program. i have led's going from 12 and 13 through a resistor to the ground just to see if wheels are "high/on". the LED's do infact stay on for 3ish seconds then turn off. but in position 2 the wheels just keep spinning in little bursts. so im wondering what could be causing this difference in position 1 and 2. maybe my batteries are going out by now?