Hey GW, I see now how this section of code opporates the A-B + A-B of the two H bridges.
LegLeftBack PIN 8 'sets left legs backwards to pin 8 LegLeftFront PIN 9 'sets left legs foward to pin 9 LegRightBack PIN 10 'sets right legs backwards to pin 10 LegRightFront PIN 11 'sets right legs foward to pin 11
One controller for:
LegLeftBack PIN 8 'sets left legs backwards to pin 8
LegRightBack PIN 10 'sets right legs backwards to pin 10
And one for:
LegLeftFront PIN 9 'sets left legs foward to pin 9
LegRightFront PIN 11 'sets right legs foward to pin 11
Sending a 0 or 1 to any of the A-B controllers make it go fwd,back,cw,cc,spin ect.
I knew this of course for a two wheel system but wasn't sure if you could use spider configuiration [two H bridges] code for a two wheel system, But really it's the same setup. Just different mechanics.
You nailed it right on the head 4mem8, Congrats your learning something and this is what this thread is for. The spider that I have is driven by two motors in a gearbox, thats why I chose this one. If you look further down the code in the GoFoward: subroutine you'll see that I have a pause in this along with a FOR NEXT command this will slow down the motors and by changing the value of the PAUSE to a higher number will slow down the Motor speed and decreasing the value will speed it up or get rid of it along with the FOR NEXT commands and leave the pins HIGH will run the motors on fast until you shut them down back to LOW. I have changed my program and once I post it please compair the diffrence regarding the leg movements. This will help you better understand the functions of making your motors move under a Hbridge configuration. There are diffrent ways to do this as well but I'm making it easy to understand. Then you can make changes to it to make the program run faster and less programming lines. I'll show you the diffrence in later post.
Thanks for the confidence GW I'm really enjoying it, I just have to find more time to swat up. Had a busy week at work so not much robotics done this week. See if I can get a few hrs over the weekend.
no problem 4mem8, I had a hard week too. and know I'm taking my bike a Honda VTX1300R 2006and wife to bike-week in Daytona, FL for the day so no robotics for me on Saturday aka Sunday for you.. lol
New changes to the random Tilt/Pan code. You can now step the speed of the tilt and pan by changing the STEP commands number. 1 being the slowest and all other higher is faster. Also look at the diffrent Variables added and the "i VAR" changed to a Word rather than a Byte. Hope this helps you out 4mem8. Here is the NEW code:
' {$STAMP BS2} ' {$PBASIC 2.5} ' random movements for tilt and pan movements ' Change the STEP command number higher to speed the scan up ' variables Tilt PIN 1 ' set tilt to pin 1 Pan PIN 0 ' set pan to pin 0 tiltseed VAR Word ' set var seed for tilt panseed VAR Word ' set var seed for pan TPseed VAR Word ' set to check for tilt or pan tpselect VAR tpseed.BIT0 ' Bit0 of the random number tiltdelay VAR Word 'tiltdelay pandelay VAR Word 'pandelay i VAR Word 'counter tilttime VAR Byte 'tilttime pantime VAR Byte 'pantime LastDelayTilt VAR Word ' used to ramp down speed for tilt LastDelayPan VAR Word 'used to ramp down speed for pan ' initialization/maxline LOW tilt LOW pan LastDelayTilt = 550 'set for center of tilt LastDelayPan = 650 'set for center of pan tiltdelay = 400 pandelay = 1000 TiltSeed = 400 PanSeed = 1000 TPseed = 1 TiltTime = 10 PanTime = 30
FOR i = 0 TO TiltTime 'center tilt/pan unit PULSOUT tilt, LastDelayTilt PAUSE 18 NEXT FOR i = 0 TO PanTime PULSOUT pan, LastDelayPan PAUSE 18 NEXT main:
RANDOM tpseed IF tpselect = 0 THEN GOSUB panit 'for tilt or pan direction
RANDOM TiltSeed ' give a random number tiltdelay = tiltseed DO WHILE (tiltdelay > 750 OR tiltdelay < 550 ) 'check to see if tilt is within specs RANDOM TiltSeed ' mixup numbers tiltdelay = tiltseed LOOP 'continue till values are right for movement GOSUB tiltit
GOTO main ' start all over
tiltIt: FOR i = LastDelayTilt TO TiltDelay STEP 1 'Change Step Number Higher to go faster PULSOUT tilt, i 'send out pulse to servo PAUSE 30 NEXT LastDelayTilt = TiltDelay RETURN
PanIt: RANDOM panseed ' mix random number with seed value pandelay=panseed DO WHILE (pandelay > 1000 OR pandelay < 200 ) ' wait till within movement specs RANDOM panseed ' mix numbers up again pandelay=panseed LOOP ' loop until numbers are within correct movement range
FOR i = Lastdelaypan TO pandelay STEP 1 'Change Step Number Higher to go faster PULSOUT pan, i PAUSE 30 NEXT LastDelayPan = PanDelay RETURN
It's limited because you can not pull the BS2 Stamp off the board, It is incorporated into it, But it is a good base to start with learning Pbasic. As long as you don't mind having the full board in your projects , I say it's a good investment. The servo I think s a continus rotation servo, great for wheel bots so you don't have to mod it. It is well worth the price.
GWjax: Thanks for the code I will check it out tonight, and will compare to the other and see what you have done.
Nocturnal: I will post another pic tonight of the rivet detal and paint, Not to brilliant at present until I scratch and rub the right area's to get the weathered effect.
Testing your Ping sensor. Use this program to test for both Inch and cm distance. When you find the right distance you want write down the number of the Time it took to get the Ping back to the RX and use this number to calculate your desired distance for your bot.
' Measure distance with Ping))) sensor and display in both in & cm ' you'll find out that you should get 134 in max and 364 cm max ' use this program to get the maximum distance required you need and write down the numbers ' {$STAMP BS2} ' {$PBASIC 2.5} ' Conversion constants for room temperature measurements. CmConstant CON 2260 InConstant CON 890 cmDistance VAR Word inDistance VAR Word Time VAR Word DO PULSOUT 15, 5 ' ping 5 times on pin 15 PULSIN 15, 1, time ' get one ping back on pin 15 cmDistance = cmConstant ** time ' convert in cm inDistance = inConstant ** time ' convert in inch
DEBUG HOME, DEC3 cmDistance, " cm" DEBUG CR, DEC3 inDistance, " in", cr DEBUG DEC Time, " = Time it took to get Ping back" PAUSE 100 LOOP
4mem8 I need you to run this program and give me the data that comes out on the debug screen before I do any movement routines, Please put Wall-E in a place on the floor where there is a lot of distance all around him. I need to get the Max data for the movement routines. Also check and see if your LED are on when you run the program. I've made a lot of changes so look it over. Thanks GWJax
Here is the Code:
' {$STAMP BS2} ' {$PBASIC 2.5} ' Wall-E move routine for tilt/pan, eye detection and body movement ' for robosienianv2-4mem8 @ WWW.RoboCommunity.com ' By: GWJax 3/28/2008 '============================================================================== ' Set Wall-E's Varaibles inDistance VAR Byte 'holds data for inch for distance 0-255 Time VAR Word 'holds data for time it takes to get a ping reply i VAR Byte 'counter CenterFront VAR Byte 'Holds center head front distance RightCenter VAR Byte 'Holds right center distance LeftCenter VAR Byte 'holds left center distance DownCenter VAR Byte 'holds down head center distance UpCenter VAR Byte 'holds up center head distance LeftDownMax VAR Byte 'holds head left down max distance RightDownMax VAR Byte 'holds head right down max distance CenterUpMax VAR Byte 'Holds head center up max distance RightUpMax VAR Byte 'Holds head right up max distance LeftUpMax VAR Byte 'holds head left up max distance '------------------------------------------------------------------------------ ' Set constants InConstant CON 890 'set for inch in room temp 70 deg F '------------------------------------------------------------------------------ ' Set Wall-E pin lay out Tilt PIN 0 'sets tilt to pin 1 Pan PIN 1 'sets pan to pin 0 Eyes PIN 7 'sets Ping eyes to pin 7 Wall_E_LfBack PIN 8 'sets left legs backwards to pin 8 Wall_E_LfFront PIN 9 'sets left legs foward to pin 9 Wall_E_RtBack PIN 10 'sets right legs backwards to pin 10 Wall_E_RtFront PIN 11 'sets right legs foward to pin 11 '------------------------------------------------------------------------------ ' setup pin I/O's HIGH Wall_E_lfBack HIGH Wall_E_LfFront HIGH Wall_E_RtBack HIGH Wall_E_RtFront LOW Tilt LOW Pan '------------------------------------------------------------------------------ 'set Wall-E's head looking front and center GOSUB PanItCenter '------------------------------------------------------------------------------ 'main routine Main: GOSUB LookAround STOP 'stop program to read results to continue programming
IF CenterFront > 11 THEN 'is object greater than 11" from eyes center GOTO Wall_E_Foward ELSEIF CenterFront <= 11 THEN 'is object = to or less than 11" from eyes center 'GOTO LookAround ' look for the best route to take
ENDIF
GOTO Main ' do it all over again '------------------------------------------------------------------------------ 'Wall-E stop moving Wall_E_STOP: HIGH Wall_E_lfBack HIGH Wall_E_LfFront HIGH Wall_E_RtBack HIGH Wall_E_RtFront GOTO Main '------------------------------------------------------------------------------ 'Pan Wall-E's head Center and Fast PanItCenter: FOR i = 0 TO 10 PULSOUT Tilt, 650 'sends out pulse to tilt servo and center Change 650 to your setting PAUSE 18 'wait for 18ms to complete turning NEXT FOR i = 0 TO 30 'Start pan movement to center PULSOUT Pan,650 'sends out pulse to pan servo and center Change 650 to your setting PAUSE 18 'wait for 18ms to complete turning NEXT RETURN '------------------------------------------------------------------------------- 'eyes ping CkEyes:
PULSOUT Eyes, 5 ' ping 5 times PULSIN Eyes, 1, time ' get one ping back InDistance = InConstant ** time ' convert in inch RETURN '------------------------------------------------------------------------------- LookAround:
FOR i = 0 TO 10 PULSOUT Tilt, 650 PAUSE 18 NEXT RETURN
LookUpMax: FOR i = 0 TO 10 PULSOUT Tilt, 300 PAUSE 18 NEXT RETURN
LookDownCenter:
GOSUB PanItCenter FOR i = 0 TO 10 PULSOUT Tilt,650 PAUSE 18 NEXT RETURN
PanItRightMax: 'pans head right to max FOR i = 0 TO 30 PULSOUT Pan, 200 PAUSE 18 NEXT RETURN
PanItRightCenter: 'pans head max to right with center tilt FOR i = 0 TO 10 PULSOUT Tilt, 550 PAUSE 18 NEXT FOR i = 0 TO 30 PULSOUT Pan, 200 PAUSE 18 NEXT RETURN
PanItLeftCenter: 'pans head max to left with center tilt FOR i = 0 TO 10 PULSOUT Tilt, 550 PAUSE 18 NEXT FOR i = 0 TO 30 PULSOUT Pan, 1000 PAUSE 18 NEXT RETURN
PanItLeftMax: 'pans head max to left only FOR i = 0 TO 30 PULSOUT pan, 1000 PAUSE 18 NEXT RETURN '------------------------------------------------------------------------------- Wall_E_Foward: GOSUB CkEyes LOW Wall_E_RtFront LOW Wall_E_LfFront DO WHILE InDistance < 11 GOSUB CkEyes LOOP GOTO Wall_E_Stop GoFowardMedium: 'moves foward Medium rate DO WHILE InDistance < 6 GOSUB CkEyes LOW Wall_E_RtFront PAUSE 50 HIGH Wall_E_RtFront LOW Wall_E_LfFront PAUSE 50 HIGH Wall_E_LfFront LOOP GOTO Wall_E_Stop GoFowardSlow:
GOSUB CkEyes DO WHILE InDistance > 4 LOW Wall_E_RtFront PAUSE 50 HIGH Wall_E_RtFront LOW Wall_E_LfFront PAUSE 50 HIGH Wall_E_LfFront GOSUB CkEyes LOOP GOTO Wall_E_Stop
GoBackFast: GOSUB CkEyes LOW Wall_E_RtBack LOW Wall_E_LfBack DO WHILE InDistance < 17 GOSUB CkEyes LOOP GOTO Wall_E_Stop
GoBackMedium: ' Moves back medium rate
GOSUB CkEyes DO WHILE indistance < 6 LOW Wall_E_RtBack PAUSE 50 HIGH Wall_E_RtBack LOW Wall_E_LfBack PAUSE 50 HIGH Wall_E_LfBack LOOP GOTO Wall_E_Stop
GoBackSlow: GOSUB CkEyes DO WHILE InDistance < 4 LOW Wall_E_RtBack PAUSE 100 HIGH Wall_E_RtBack LOW Wall_E_LfBack PAUSE 100 HIGH Wall_E_LfBack LOOP GOTO Wall_E_Stop
Thanks GW, It may be a while before I get to this as Wall-E is not complete yet and the Hbridge is still on the bread board. We have to decorate the lounge and rip up carpet, Worst of all dismantle my workstation, A huge job if you were to see my system. Which means I will have to upgrade my Electronics Pc for email ect. M'mmm.
Here is the H bridge Test routine you asked me to make for you. I hope It works as I can not test it here without building the H-Bridge you made. But I'm sure it will it has no syntax errors in it so it should do fine, It will go foward fast, stop, go back fast, a hard break and float break, clock wise, stop, counter clockwise, stop and loop to do again in 2 sec. Let me know If tis works!
' {$STAMP BS2} ' {$PBASIC 2.5} ' Motor movement for Wall-E H-Bridge Test routine ' By GWJax 28 Mar 2008 '============================================================================== ' Set Wall-E's Varaibles
'------------------------------------------------------------------------------ ' Set Wall-E pin lay out Wall_E_LfBack PIN 8 'sets left track backwards to pin 8 Wall_E_LfFront PIN 9 'sets left track foward to pin 9 Wall_E_RtBack PIN 10 'sets right track backwards to pin 10 Wall_E_RtFront PIN 11 'sets right track foward to pin 11 '------------------------------------------------------------------------------ ' setup pin I/O's HIGH Wall_E_lfBack HIGH Wall_E_LfFront HIGH Wall_E_RtBack HIGH Wall_E_RtFront '------------------------------------------------------------------------------ Main: GOSUB Wall_E_STOP GOSUB Wall_E_FowardFast PAUSE 1000 ' let run for one sec. GOSUB Wall_E_STOP GOSUB Wall_E_BackFast PAUSE 1000 ' let run for one sec GOSUB Wall_E_HBStop ' opps put on the breaks! PAUSE 250 ' pause 1/4 sec GOSUB Wall_E_Stop ' reset lines for floating GOSUB Wall_E_CW PAUSE 500 ' run for 1/2 sec GOSUB Wall_E_Stop GOSUB Wall_E_CCW PAUSE 500 ' run for 1/2 sec GOSUB Wall_E_Stop PAUSE 2000 ' wait for 2 sec GOTO Main ' return to the start and do again
Great Gw, Thanks for the code, Will test asp. I have been moving ALL my PC grear today, The whole dinning room table is choka full of gear + 4 banana box's of cables. I have just setup my laptop for communication to this site. I don't want to miss anything, Ha Ha.
I was hopping you would get it before you riped everything down. Let me know how it goes! Thanks GWJax
ps. not much happing here in robo world lol. I had just done some coding for a client of mine for a mail merge to over 1/2 million people. That was a lot of coding but it works great and I'll install it on sat for them on their computer. It only took 6 hrs to do it, not bad I think. Its a good thing I have a stash of routines that are plug and play that I made. by the way it was programed Visual Basic 6.0. I must have a think for basic programming, I tried C and C++ and Visual C++ but it just does not make sence to me for some reason. now Assembly I'm a bit rusty but catching up on it for the Elivnator.
Assembly!! I thought that you were coding in P-basic for Elvinator!! Don't worry about me dissmantling my PC GW, I still have my Electronics room PC for the coding so I will download it tomorrow and let you know. I was only going to use my lapyop for Robot stuff but I have now decided to also use it for this site to keep in touch whilst our living room is upgraded. I will load M/S picture it to upload my photo's.
Yep Assembly! for some of the movements for the Pics I plan on installing, The pics will intertwine with the Basic Stamps and the will run faster while the Basic Stamps can do other monitoring sensors and the such.. Sorry I thought I told you this. But if I did not SUPPRISE!!! I told you I would through in a few hard coding... I glade you have the laptop as that is what I use instead of my PC so I can bring all my stuff in the car while I work. Some of the short post I do is while I'm driving to the next client, and I know that dangerious but its still fun.hehehehe
Yes it is a surprise to hear you are using assembly GW, I must not have been paying attention. So you are going to use some pics? What type? I may need to get some if I am to follow your code for Elvinator! Is there a special program for pasting assembly into Gw?. Laptop is working well, Just need to plug in some more periphials like my usb Hdd for photo storage and files, If I get a chance I will start a gallery.
I havent picked my PIC yet, I'm still looking around for the most I/O pins and how much EEprom memory I can use with it. The Elvinator code that I have right now is 95% full on the BS2 and all Data memory is full, This is one reason why I'm using the BSp40 and PIC chips. as of the coding being sent to the PIC there is another compiler that needs to be used and I'll make the jumper programming board for that instead of buying one. I can't think of the names right now of the compilers but I'll get back to ya on that.
Add a clyon eye to your projects. here is the code for using 10 leds and connect them to a 220 ohm resistor to pin 0 - 9: enjoy
' {$STAMP BS2} ' {$PBASIC 2.5} 'Cylon Eye - this program will scan 10 Led ' connect 10 LED starting at pin 0 to 9 with a 220 ohm resistor ' variables Direction VAR Byte LSB PIN 0 'least sigificant led bit MSB PIN 9 ' most significant led bit
'init OUTS = %1111111110 'make all the led pins an output DIRS = %1111111111 Direction = 0 ' start running up the leds DO IF (Direction =0) THEN OUTS = OUTS << 1 +1 'shift the led up by 1 IF (MSB =0) THEN Direction = 1 'change direction of led travel ENDIF ELSE OUTS = OUTS >> 1 'shift led down MSB = 1 'make sure MSB bit is set IF (LSB = 0) THEN Direction = 0 ENDIF ENDIF
PAUSE 100 ' takes 1 sec to run across 10 leds LOOP
These damn opto couplers are doing my head in, This should be the easy part, but for some reason they are not playing ball, I have tried 4N33, 4N25 and H111A And none want to work as they are supposed to. Looks like this is going to hold me up for a while compleating this H-bridge.
After a lot of circuit testing and code running the EAAR "Elvis Always Alive Remote" is finnished. My Elvinator has been running this program for 2 day straight and has never shut down. So I will now present you with the simple code that ran me crazy in circles. I'll post an article on showing you how to duplicate the remote. And now heres the program:
' {$STAMP BS2}
' {$PBASIC 2.5}
' WowWee's Elvis Alive Always Alive Remote EAAR
' designed for dontknowdiddly at www.robocommunity.com
' by: GWJax Started: May 15, 2008 Completed: June 6, 2008
' Set pin functions
Play PIN 0 ' play audio
SongOrSpeak PIN 1 ' shift from audio to speak
NextSC PIN 2 ' shift to next song or comments
'set varaibles
TimeHold VAR Word ' Used for pausing the program
I VAR Byte ' counter
' Initalize Varables
LOW Play 'set pin low
LOW SongOrSpeak 'set pin low
LOW NextSC 'set pin low
TimeHold = 60000 ' hold time for 1 min
PAUSE TimeHold / 2 'pause for 1/2 min before starting program
' main routine
Main:
GOSUB Song
GOSUB Talk_Song ' change to talking mode
GOSUB ChangeSC ' play comment
GOSUB Hold2
GOSUB ChangeSC ' play comment
GOSUB Hold2
GOSUB ChangeSC ' play comment
GOSUB Hold ' wait in alive mode for 4 min
GOSUB Talk_Song ' change to song mode
GOSUB ChangeSC 'change Song and get ready for next song to be played
GOTO Main ' Start all over
Talk_Song: ' routine for changing for fron Singing to Commenting
HIGH SongOrSpeak ' press talk/song key
PAUSE 200 ' hold for 200 ms
LOW SongOrSpeak ' release button
PAUSE 8000 ' wait for 8 sec to finnish saying its command
RETURN ' Return to the calling routine
Song: ' Play a song
HIGH Play ' Press the Play/Pause button
PAUSE 200 ' hold down the play button for 200 m/s
LOW Play ' release the play button
PAUSE TimeHold / 2
PAUSE TimeHold ' Pause for 1 1/2 min to let song complete
RETURN ' Return to calling routine
ChangeSC:
HIGH NEXTSC ' play next Comment or change next song
PAUSE 200 ' Pause for 200 ms
LOW NextSC ' release the button
PAUSE 1000 ' Hold for 1 sec.
RETURN
Talk:
PAUSE 1000 ' wait 1 sec before pressing the play/pause button
HIGH Play ' press button
PAUSE 200 ' hold it for 200 ms
LOW play ' release Button
PAUSE TimeHold 'hold for 1 min.
PAUSE TimeHold / 2 ' hold another 1/2 min
RETURN ' return to calling routine
Hold: ' Hold routine for Alive Mode for 4 min.
FOR I = 1 to 4
PAUSE HoldTime
NEXT
RETURN
Hold2:
FOR i = 1 TO 3 ' hold for 1 1/2 min
PAUSE timehold / 2
NEXT
RETURN
It feel good to have this remote under my belt and now I can go back on the wall-e project to get it ready, which I think you'll be happy to hear. I have another voice changer tha records and playback with a warping wound, I'm going to try to hack this and get rid of the recorder and use the warping sound to fine turn the Wall-E voice, but I keep you informed on this new devise which is very small since space is like gold in him.
Ha ha, no I have not sent you this module. If it works, then we'll use both units, the one I sent you plus the one I'm working on or I should say testing with. I bought this module after I sent your package.
Hey GW, I see now how this section of code opporates the A-B + A-B of the two H bridges.
LegLeftBack PIN 8 'sets left legs backwards to pin 8
LegLeftFront PIN 9 'sets left legs foward to pin 9
LegRightBack PIN 10 'sets right legs backwards to pin 10
LegRightFront PIN 11 'sets right legs foward to pin 11
One controller for:
LegLeftBack PIN 8 'sets left legs backwards to pin 8
LegRightBack PIN 10 'sets right legs backwards to pin 10
And one for:
LegLeftFront PIN 9 'sets left legs foward to pin 9
LegRightFront PIN 11 'sets right legs foward to pin 11
Sending a 0 or 1 to any of the A-B controllers make it go fwd,back,cw,cc,spin ect.
I knew this of course for a two wheel system but wasn't sure if you could use spider configuiration [two H bridges] code for a two wheel system, But really it's the same setup. Just different mechanics.
You nailed it right on the head 4mem8, Congrats your learning something and this is what this thread is for. The spider that I have is driven by two motors in a gearbox, thats why I chose this one. If you look further down the code in the GoFoward: subroutine you'll see that I have a pause in this along with a FOR NEXT command this will slow down the motors and by changing the value of the PAUSE to a higher number will slow down the Motor speed and decreasing the value will speed it up or get rid of it along with the FOR NEXT commands and leave the pins HIGH will run the motors on fast until you shut them down back to LOW. I have changed my program and once I post it please compair the diffrence regarding the leg movements. This will help you better understand the functions of making your motors move under a Hbridge configuration. There are diffrent ways to do this as well but I'm making it easy to understand. Then you can make changes to it to make the program run faster and less programming lines. I'll show you the diffrence in later post.
Thanks for the confidence GW I'm really enjoying it, I just have to find more time to swat up. Had a busy week at work so not much robotics done this week. See if I can get a few hrs over the weekend.
no problem 4mem8, I had a hard week too. and know I'm taking my bike a Honda VTX1300R 2006and wife to bike-week in Daytona, FL for the day so no robotics for me on Saturday aka Sunday for you.. lol
Cool GW, Have a nice day.
New changes to the random Tilt/Pan code. You can now step the speed of the tilt and pan by changing the STEP commands number. 1 being the slowest and all other higher is faster. Also look at the diffrent Variables added and the "i VAR" changed to a Word rather than a Byte. Hope this helps you out 4mem8. Here is the NEW code:
' {$STAMP BS2}
' {$PBASIC 2.5}
' random movements for tilt and pan movements
' Change the STEP command number higher to speed the scan up
' variables
Tilt PIN 1 ' set tilt to pin 1
Pan PIN 0 ' set pan to pin 0
tiltseed VAR Word ' set var seed for tilt
panseed VAR Word ' set var seed for pan
TPseed VAR Word ' set to check for tilt or pan
tpselect VAR tpseed.BIT0 ' Bit0 of the random number
tiltdelay VAR Word 'tiltdelay
pandelay VAR Word 'pandelay
i VAR Word 'counter
tilttime VAR Byte 'tilttime
pantime VAR Byte 'pantime
LastDelayTilt VAR Word ' used to ramp down speed for tilt
LastDelayPan VAR Word 'used to ramp down speed for pan
' initialization/maxline
LOW tilt
LOW pan
LastDelayTilt = 550 'set for center of tilt
LastDelayPan = 650 'set for center of pan
tiltdelay = 400
pandelay = 1000
TiltSeed = 400
PanSeed = 1000
TPseed = 1
TiltTime = 10
PanTime = 30
FOR i = 0 TO TiltTime 'center tilt/pan unit
PULSOUT tilt, LastDelayTilt
PAUSE 18
NEXT
FOR i = 0 TO PanTime
PULSOUT pan, LastDelayPan
PAUSE 18
NEXT
main:
RANDOM tpseed
IF tpselect = 0 THEN GOSUB panit 'for tilt or pan direction
RANDOM TiltSeed ' give a random number
tiltdelay = tiltseed
DO WHILE (tiltdelay > 750 OR tiltdelay < 550 ) 'check to see if tilt is within specs
RANDOM TiltSeed ' mixup numbers
tiltdelay = tiltseed
LOOP 'continue till values are right for movement
GOSUB tiltit
GOTO main ' start all over
tiltIt:
FOR i = LastDelayTilt TO TiltDelay STEP 1 'Change Step Number Higher to go faster
PULSOUT tilt, i 'send out pulse to servo
PAUSE 30
NEXT
LastDelayTilt = TiltDelay
RETURN
PanIt:
RANDOM panseed ' mix random number with seed value
pandelay=panseed
DO WHILE (pandelay > 1000 OR pandelay < 200 ) ' wait till within movement specs
RANDOM panseed ' mix numbers up again
pandelay=panseed
LOOP ' loop until numbers are within correct movement range
FOR i = Lastdelaypan TO pandelay STEP 1 'Change Step Number Higher to go faster
PULSOUT pan, i
PAUSE 30
NEXT
LastDelayPan = PanDelay
RETURN
Anyone have an opinion if the Radio Shack Basic Stamp kit is worth it at $79? It includes one servo as well.
It's limited because you can not pull the BS2 Stamp off the board, It is incorporated into it, But it is a good base to start with learning Pbasic. As long as you don't mind having the full board in your projects , I say it's a good investment. The servo I think s a continus rotation servo, great for wheel bots so you don't have to mod it. It is well worth the price.
Pretty good price to me milw, I'd go for it.
GWjax: Thanks for the code I will check it out tonight, and will compare to the other and see what you have done.
Nocturnal: I will post another pic tonight of the rivet detal and paint, Not to brilliant at present until I scratch and rub the right area's to get the weathered effect.
Hey everybody - part 4 of the "Elvinator" hack is now posted!!!!
Head on over and check it out!
Thanks to GWJax for all his hard work on this awesome project!!
Pete
Testing your Ping sensor. Use this program to test for both Inch and cm distance. When you find the right distance you want write down the number of the Time it took to get the Ping back to the RX and use this number to calculate your desired distance for your bot.
' Measure distance with Ping))) sensor and display in both in & cm
' you'll find out that you should get 134 in max and 364 cm max
' use this program to get the maximum distance required you need and write down the numbers
' {$STAMP BS2}
' {$PBASIC 2.5}
' Conversion constants for room temperature measurements.
CmConstant CON 2260
InConstant CON 890
cmDistance VAR Word
inDistance VAR Word
Time VAR Word
DO
PULSOUT 15, 5 ' ping 5 times on pin 15
PULSIN 15, 1, time ' get one ping back on pin 15
cmDistance = cmConstant ** time ' convert in cm
inDistance = inConstant ** time ' convert in inch
DEBUG HOME, DEC3 cmDistance, " cm"
DEBUG CR, DEC3 inDistance, " in", cr
DEBUG DEC Time, " = Time it took to get Ping back"
PAUSE 100
LOOP
Great GW, Thanks.
4mem8 I need you to run this program and give me the data that comes out on the debug screen before I do any movement routines, Please put Wall-E in a place on the floor where there is a lot of distance all around him. I need to get the Max data for the movement routines. Also check and see if your LED are on when you run the program. I've made a lot of changes so look it over. Thanks GWJax
Here is the Code:
' {$STAMP BS2}
' {$PBASIC 2.5}
' Wall-E move routine for tilt/pan, eye detection and body movement
' for robosienianv2-4mem8 @ WWW.RoboCommunity.com
' By: GWJax 3/28/2008
'==============================================================================
' Set Wall-E's Varaibles
inDistance VAR Byte 'holds data for inch for distance 0-255
Time VAR Word 'holds data for time it takes to get a ping reply
i VAR Byte 'counter
CenterFront VAR Byte 'Holds center head front distance
RightCenter VAR Byte 'Holds right center distance
LeftCenter VAR Byte 'holds left center distance
DownCenter VAR Byte 'holds down head center distance
UpCenter VAR Byte 'holds up center head distance
LeftDownMax VAR Byte 'holds head left down max distance
RightDownMax VAR Byte 'holds head right down max distance
CenterUpMax VAR Byte 'Holds head center up max distance
RightUpMax VAR Byte 'Holds head right up max distance
LeftUpMax VAR Byte 'holds head left up max distance
'------------------------------------------------------------------------------
' Set constants
InConstant CON 890 'set for inch in room temp 70 deg F
'------------------------------------------------------------------------------
' Set Wall-E pin lay out
Tilt PIN 0 'sets tilt to pin 1
Pan PIN 1 'sets pan to pin 0
Eyes PIN 7 'sets Ping eyes to pin 7
Wall_E_LfBack PIN 8 'sets left legs backwards to pin 8
Wall_E_LfFront PIN 9 'sets left legs foward to pin 9
Wall_E_RtBack PIN 10 'sets right legs backwards to pin 10
Wall_E_RtFront PIN 11 'sets right legs foward to pin 11
'------------------------------------------------------------------------------
' setup pin I/O's
HIGH Wall_E_lfBack
HIGH Wall_E_LfFront
HIGH Wall_E_RtBack
HIGH Wall_E_RtFront
LOW Tilt
LOW Pan
'------------------------------------------------------------------------------
'set Wall-E's head looking front and center
GOSUB PanItCenter
'------------------------------------------------------------------------------
'main routine
Main:
GOSUB LookAround
STOP 'stop program to read results to continue programming
IF CenterFront > 11 THEN 'is object greater than 11" from eyes center
GOTO Wall_E_Foward
ELSEIF CenterFront <= 11 THEN 'is object = to or less than 11" from eyes center
'GOTO LookAround ' look for the best route to take
ENDIF
GOTO Main ' do it all over again
'------------------------------------------------------------------------------
'Wall-E stop moving
Wall_E_STOP:
HIGH Wall_E_lfBack
HIGH Wall_E_LfFront
HIGH Wall_E_RtBack
HIGH Wall_E_RtFront
GOTO Main
'------------------------------------------------------------------------------
'Pan Wall-E's head Center and Fast
PanItCenter:
FOR i = 0 TO 10
PULSOUT Tilt, 650 'sends out pulse to tilt servo and center Change 650 to your setting
PAUSE 18 'wait for 18ms to complete turning
NEXT
FOR i = 0 TO 30 'Start pan movement to center
PULSOUT Pan,650 'sends out pulse to pan servo and center Change 650 to your setting
PAUSE 18 'wait for 18ms to complete turning
NEXT
RETURN
'-------------------------------------------------------------------------------
'eyes ping
CkEyes:
PULSOUT Eyes, 5 ' ping 5 times
PULSIN Eyes, 1, time ' get one ping back
InDistance = InConstant ** time ' convert in inch
RETURN
'-------------------------------------------------------------------------------
LookAround:
GOSUB PanItCenter 'Center head
GOSUB CkEyes 'look at the distance in the center
CenterFront = InDistance 'set CenterHead with distance recorded
DEBUG CLS, "CenterFront=",DEC3 CenterFront, cr
GOSUB LookDownCenter
GOSUB CkEyes
DownCenter = InDistance
DEBUG "LookDownCenter=",DEC3 DownCenter, CR
GOSUB LookUpMax
GOSUB CkEyes
UpCenter = InDistance
DEBUG "LookUpMax =",DEC3 UpCenter, cr
GOSUB PanItRightCenter
GOSUB CkEyes
RightCenter = InDistance
DEBUG "RightCenter =",DEC3 RightCenter, CR
GOSUB LookUpMax
GOSUB CkEyes
RightUpMax = InDistance
DEBUG "RightUpMax =",DEC3 RightUpMax,cr
GOSUB LookDownLR
GOSUB CkEyes
RightDownMax = InDistance
DEBUG "RightDownMax =",DEC3 RightDownMax,cr
GOSUB PanItLeftCenter
GOSUB CkEyes
LeftCenter = InDistance
DEBUG "LeftCenter =",DEC3 RightCenter,cr
GOSUB LookUpMax
GOSUB CkEyes
LeftUpMax = InDistance
DEBUG "LeftUpMax =",DEC3 LeftUpMax,cr
GOSUB LOOKDOWNLR
GOSUB CkEyes
LeftDownMax = InDistance
DEBUG "LeftDownMax =",DEC3 leftDownMax,cr
GOSUB PanItCenter
RETURN
'-------------------------------------------------------------------------------
'Head Routines
LookDownLR:
FOR i = 0 TO 10
PULSOUT Tilt, 650
PAUSE 18
NEXT
RETURN
LookUpMax:
FOR i = 0 TO 10
PULSOUT Tilt, 300
PAUSE 18
NEXT
RETURN
LookDownCenter:
GOSUB PanItCenter
FOR i = 0 TO 10
PULSOUT Tilt,650
PAUSE 18
NEXT
RETURN
PanItRightMax: 'pans head right to max
FOR i = 0 TO 30
PULSOUT Pan, 200
PAUSE 18
NEXT
RETURN
PanItRightCenter: 'pans head max to right with center tilt
FOR i = 0 TO 10
PULSOUT Tilt, 550
PAUSE 18
NEXT
FOR i = 0 TO 30
PULSOUT Pan, 200
PAUSE 18
NEXT
RETURN
PanItLeftCenter: 'pans head max to left with center tilt
FOR i = 0 TO 10
PULSOUT Tilt, 550
PAUSE 18
NEXT
FOR i = 0 TO 30
PULSOUT Pan, 1000
PAUSE 18
NEXT
RETURN
PanItLeftMax: 'pans head max to left only
FOR i = 0 TO 30
PULSOUT pan, 1000
PAUSE 18
NEXT
RETURN
'-------------------------------------------------------------------------------
Wall_E_Foward:
GOSUB CkEyes
LOW Wall_E_RtFront
LOW Wall_E_LfFront
DO WHILE InDistance < 11
GOSUB CkEyes
LOOP
GOTO Wall_E_Stop
GoFowardMedium:
'moves foward Medium rate
DO WHILE InDistance < 6
GOSUB CkEyes
LOW Wall_E_RtFront
PAUSE 50
HIGH Wall_E_RtFront
LOW Wall_E_LfFront
PAUSE 50
HIGH Wall_E_LfFront
LOOP
GOTO Wall_E_Stop
GoFowardSlow:
GOSUB CkEyes
DO WHILE InDistance > 4
LOW Wall_E_RtFront
PAUSE 50
HIGH Wall_E_RtFront
LOW Wall_E_LfFront
PAUSE 50
HIGH Wall_E_LfFront
GOSUB CkEyes
LOOP
GOTO Wall_E_Stop
GoBackFast:
GOSUB CkEyes
LOW Wall_E_RtBack
LOW Wall_E_LfBack
DO WHILE InDistance < 17
GOSUB CkEyes
LOOP
GOTO Wall_E_Stop
GoBackMedium: ' Moves back medium rate
GOSUB CkEyes
DO WHILE indistance < 6
LOW Wall_E_RtBack
PAUSE 50
HIGH Wall_E_RtBack
LOW Wall_E_LfBack
PAUSE 50
HIGH Wall_E_LfBack
LOOP
GOTO Wall_E_Stop
GoBackSlow:
GOSUB CkEyes
DO WHILE InDistance < 4
LOW Wall_E_RtBack
PAUSE 100
HIGH Wall_E_RtBack
LOW Wall_E_LfBack
PAUSE 100
HIGH Wall_E_LfBack
LOOP
GOTO Wall_E_Stop
Thanks GW, It may be a while before I get to this as Wall-E is not complete yet and the Hbridge is still on the bread board. We have to decorate the lounge and rip up carpet, Worst of all dismantle my workstation, A huge job if you were to see my system. Which means I will have to upgrade my Electronics Pc for email ect. M'mmm.
Here is the H bridge Test routine you asked me to make for you. I hope It works as I can not test it here without building the H-Bridge you made. But I'm sure it will it has no syntax errors in it so it should do fine, It will go foward fast, stop, go back fast, a hard break and float break, clock wise, stop, counter clockwise, stop and loop to do again in 2 sec. Let me know If tis works!
' {$STAMP BS2}
' {$PBASIC 2.5}
' Motor movement for Wall-E H-Bridge Test routine
' By GWJax 28 Mar 2008
'==============================================================================
' Set Wall-E's Varaibles
'------------------------------------------------------------------------------
' Set Wall-E pin lay out
Wall_E_LfBack PIN 8 'sets left track backwards to pin 8
Wall_E_LfFront PIN 9 'sets left track foward to pin 9
Wall_E_RtBack PIN 10 'sets right track backwards to pin 10
Wall_E_RtFront PIN 11 'sets right track foward to pin 11
'------------------------------------------------------------------------------
' setup pin I/O's
HIGH Wall_E_lfBack
HIGH Wall_E_LfFront
HIGH Wall_E_RtBack
HIGH Wall_E_RtFront
'------------------------------------------------------------------------------
Main:
GOSUB Wall_E_STOP
GOSUB Wall_E_FowardFast
PAUSE 1000 ' let run for one sec.
GOSUB Wall_E_STOP
GOSUB Wall_E_BackFast
PAUSE 1000 ' let run for one sec
GOSUB Wall_E_HBStop ' opps put on the breaks!
PAUSE 250 ' pause 1/4 sec
GOSUB Wall_E_Stop ' reset lines for floating
GOSUB Wall_E_CW
PAUSE 500 ' run for 1/2 sec
GOSUB Wall_E_Stop
GOSUB Wall_E_CCW
PAUSE 500 ' run for 1/2 sec
GOSUB Wall_E_Stop
PAUSE 2000 ' wait for 2 sec
GOTO Main ' return to the start and do again
'------------------------------------------------------------------------------
'Wall-E stop moving
Wall_E_STOP:
HIGH Wall_E_lfBack
HIGH Wall_E_LfFront
HIGH Wall_E_RtBack
HIGH Wall_E_RtFront
RETURN
'-------------------------------------------------------------------------------
Wall_E_FowardFast:
LOW Wall_E_RtFront
LOW Wall_E_LfFront
RETURN
'-------------------------------------------------------------------------------
Wall_E_BackFast:
LOW Wall_E_RtBack
LOW Wall_E_LfBack
RETURN
'-------------------------------------------------------------------------------
'Wall-E move clock wise
Wall_E_CW:
LOW Wall_E_RtBack
LOW Wall_E_LfFront
RETURN
'-------------------------------------------------------------------------------
'Wall-E moving counter clock wise
Wall_E_CCW:
LOW Wall_E_LfBack
LOW Wall_E_RtFront
RETURN
'Wall-E hard break stop
Wall_E_HBStop:
LOW Wall_E_lfBack
LOW Wall_E_LfFront
LOW Wall_E_RtBack
LOW Wall_E_RtFront
RETURN
Great Gw, Thanks for the code, Will test asp. I have been moving ALL my PC grear today, The whole dinning room table is choka full of gear + 4 banana box's of cables. I have just setup my laptop for communication to this site. I don't want to miss anything, Ha Ha.
I was hopping you would get it before you riped everything down. Let me know how it goes! Thanks GWJax
ps. not much happing here in robo world lol. I had just done some coding for a client of mine for a mail merge to over 1/2 million people. That was a lot of coding but it works great and I'll install it on sat for them on their computer. It only took 6 hrs to do it, not bad I think. Its a good thing I have a stash of routines that are plug and play that I made. by the way it was programed Visual Basic 6.0. I must have a think for basic programming, I tried C and C++ and Visual C++ but it just does not make sence to me for some reason. now Assembly I'm a bit rusty but catching up on it for the Elivnator.
Assembly!! I thought that you were coding in P-basic for Elvinator!! Don't worry about me dissmantling my PC GW, I still have my Electronics room PC for the coding so I will download it tomorrow and let you know. I was only going to use my lapyop for Robot stuff but I have now decided to also use it for this site to keep in touch whilst our living room is upgraded. I will load M/S picture it to upload my photo's.
Yep Assembly! for some of the movements for the Pics I plan on installing, The pics will intertwine with the Basic Stamps and the will run faster while the Basic Stamps can do other monitoring sensors and the such.. Sorry I thought I told you this. But if I did not SUPPRISE!!! I told you I would through in a few hard coding... I glade you have the laptop as that is what I use instead of my PC so I can bring all my stuff in the car while I work. Some of the short post I do is while I'm driving to the next client, and I know that dangerious but its still fun.hehehehe
Yes it is a surprise to hear you are using assembly GW, I must not have been paying attention. So you are going to use some pics? What type? I may need to get some if I am to follow your code for Elvinator! Is there a special program for pasting assembly into Gw?. Laptop is working well, Just need to plug in some more periphials like my usb Hdd for photo storage and files, If I get a chance I will start a gallery.
I havent picked my PIC yet, I'm still looking around for the most I/O pins and how much EEprom memory I can use with it. The Elvinator code that I have right now is 95% full on the BS2 and all Data memory is full, This is one reason why I'm using the BSp40 and PIC chips. as of the coding being sent to the PIC there is another compiler that needs to be used and I'll make the jumper programming board for that instead of buying one. I can't think of the names right now of the compilers but I'll get back to ya on that.
Cool GW, Nice to start acquiring parts and compilers for later use.
Add a clyon eye to your projects. here is the code for using 10 leds and connect them to a 220 ohm resistor to pin 0 - 9: enjoy
' {$STAMP BS2}
' {$PBASIC 2.5}
'Cylon Eye - this program will scan 10 Led
' connect 10 LED starting at pin 0 to 9 with a 220 ohm resistor
' variables
Direction VAR Byte
LSB PIN 0 'least sigificant led bit
MSB PIN 9 ' most significant led bit
'init
OUTS = %1111111110 'make all the led pins an output
DIRS = %1111111111
Direction = 0
' start running up the leds
DO
IF (Direction =0) THEN
OUTS = OUTS << 1 +1 'shift the led up by 1
IF (MSB =0) THEN
Direction = 1 'change direction of led travel
ENDIF
ELSE
OUTS = OUTS >> 1 'shift led down
MSB = 1 'make sure MSB bit is set
IF (LSB = 0) THEN
Direction = 0
ENDIF
ENDIF
PAUSE 100 ' takes 1 sec to run across 10 leds
LOOP
These damn opto couplers are doing my head in, This should be the easy part, but for some reason they are not playing ball, I have tried 4N33, 4N25 and H111A And none want to work as they are supposed to. Looks like this is going to hold me up for a while compleating this H-bridge.
Stay in there and I'll get you going.
After a lot of circuit testing and code running the EAAR "Elvis Always Alive Remote" is finnished. My Elvinator has been running this program for 2 day straight and has never shut down. So I will now present you with the simple code that ran me crazy in circles. I'll post an article on showing you how to duplicate the remote. And now heres the program:
' {$STAMP BS2}
' {$PBASIC 2.5}
' WowWee's Elvis Alive Always Alive Remote EAAR
' designed for dontknowdiddly at www.robocommunity.com
' by: GWJax Started: May 15, 2008 Completed: June 6, 2008
' Set pin functions
Play PIN 0 ' play audio
SongOrSpeak PIN 1 ' shift from audio to speak
NextSC PIN 2 ' shift to next song or comments
'set varaibles
TimeHold VAR Word ' Used for pausing the program
I VAR Byte ' counter
' Initalize Varables
LOW Play 'set pin low
LOW SongOrSpeak 'set pin low
LOW NextSC 'set pin low
TimeHold = 60000 ' hold time for 1 min
PAUSE TimeHold / 2 'pause for 1/2 min before starting program
' main routine
Main:
GOSUB Song
GOSUB Talk_Song ' change to talking mode
GOSUB ChangeSC ' play comment
GOSUB Hold2
GOSUB ChangeSC ' play comment
GOSUB Hold2
GOSUB ChangeSC ' play comment
GOSUB Hold ' wait in alive mode for 4 min
GOSUB Talk_Song ' change to song mode
GOSUB ChangeSC 'change Song and get ready for next song to be played
GOTO Main ' Start all over
Talk_Song: ' routine for changing for fron Singing to Commenting
HIGH SongOrSpeak ' press talk/song key
PAUSE 200 ' hold for 200 ms
LOW SongOrSpeak ' release button
PAUSE 8000 ' wait for 8 sec to finnish saying its command
RETURN ' Return to the calling routine
Song: ' Play a song
HIGH Play ' Press the Play/Pause button
PAUSE 200 ' hold down the play button for 200 m/s
LOW Play ' release the play button
PAUSE TimeHold / 2
PAUSE TimeHold ' Pause for 1 1/2 min to let song complete
RETURN ' Return to calling routine
ChangeSC:
HIGH NEXTSC ' play next Comment or change next song
PAUSE 200 ' Pause for 200 ms
LOW NextSC ' release the button
PAUSE 1000 ' Hold for 1 sec.
RETURN
Talk:
PAUSE 1000 ' wait 1 sec before pressing the play/pause button
HIGH Play ' press button
PAUSE 200 ' hold it for 200 ms
LOW play ' release Button
PAUSE TimeHold 'hold for 1 min.
PAUSE TimeHold / 2 ' hold another 1/2 min
RETURN ' return to calling routine
Hold: ' Hold routine for Alive Mode for 4 min.
FOR I = 1 to 4
PAUSE HoldTime
NEXT
RETURN
Hold2:
FOR i = 1 TO 3 ' hold for 1 1/2 min
PAUSE timehold / 2
NEXT
RETURN
Nice job GW, perseverance has paid off, I knew you would resolve it.
It feel good to have this remote under my belt and now I can go back on the wall-e project to get it ready, which I think you'll be happy to hear. I have another voice changer tha records and playback with a warping wound, I'm going to try to hack this and get rid of the recorder and use the warping sound to fine turn the Wall-E voice, but I keep you informed on this new devise which is very small since space is like gold in him.
GW, is this what you have sent me or is this something different you are experimenting with? Sounds [pardon the pun] interesting.
Ha ha, no I have not sent you this module. If it works, then we'll use both units, the one I sent you plus the one I'm working on or I should say testing with. I bought this module after I sent your package.
Pages