The Elvinator Source Code and Video along with other helpfull code and Video

104 posts / 0 new
Last post
Nocturnal
Nocturnal's picture

 *Laughs* Dont use PIC's either.

GWJax
GWJax's picture

Well what do you program in then Noctural? don't keep me on edge!

Nocturnal
Nocturnal's picture

*Evil Grin* Whatever I need to, to get the job done.

RobosapienV2-4mem8
RobosapienV2-4mem8's picture

Quit true Nocturnal, I would tend to agree. I would expect at least 2amps as Thats what the RSV2 is rated at 9v @ 2amps I believe, The stall current is 2 amps.

RobosapienV2-4mem8
RobosapienV2-4mem8's picture

GWjax, Nocturnal is quit elusive with his programming isn't he, He's not game to divulge what programming he use's. *Evil Grin* Whatever I need to, to get the job done*. Doesn't really tell us anything. *Laughs*. I know he uses Atmel CPU's?. It could be Forth or Java.

Nocturnal
Nocturnal's picture

Damn you 4mem8! giving away my secrets!

When working with Atmel's AVR line, I usually use C, with a bit of assembler thrown in if speed is critical. 

RobosapienV2-4mem8
RobosapienV2-4mem8's picture

Ah, Now we are getting somewhere He He.

GWJax
GWJax's picture

lol, good one 4mem8 I was thinking C and Java, but i'm impressed not many people know Assembly aka machine coding. This is good information for me. hehehe

As of the h-bridge I'm working on a new circuit with higher rateing transistors and I'll use my rsV2 motors to test it out for you. So hang tight.

RobosapienV2-4mem8
RobosapienV2-4mem8's picture

Your saving me heaps of time while I am working on Wall-E GWjax, thanks for  testing out the H bridge, It would have just taken me longer  to get around to it. i thought I had enough time on my hands, Where do you find all yours??

Nocturnal
Nocturnal's picture

GWJax said: lol, good one 4mem8 I was thinking C and Java, but i'm impressed not many people know Assembly aka machine coding.

Not a fan of Java, C++ isn't to bad though. Assembly and Machine code are two different things, though there is usually a one to one corellation between them. The primary difference is assembler needs to be "assembled" into machine code, and machine code is what the CPU see's and executes.

Personally, I don't find ignorance impressive. I'd be much happier if people knew and understood more (that includes me in a variety of areas) .

RobosapienV2-4mem8
RobosapienV2-4mem8's picture

Personally I wish I could write code of any type, it would solve a lot of my problems in robotics. So that makes me totally ignorant. Oh well.Frown

RobosapienV2-4mem8
RobosapienV2-4mem8's picture

Here is the first attempt at WALLE'S PAN/TILT head movements useing GWjax's code. I just have to sort out the tilt section as it seems to have the jitters in the forward/back movements, this I think is due to the speed inertia and weight of the head, [althought not heavy] I have tried decreasing the number value stated by GW but so far this has not altered the effect. Will have another go Sunday.

I have underlined the section that I altered for tiltseed from 460 to 50 is this the correct part GW

' {$STAMP BS2}
' {$PBASIC 2.5}
' random movements for tilt and pan movements

' variables
Tilt PIN 14 ' set tilt to pin 14
Pan PIN 13 ' set pan to pin 13
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 Byte 'counter
tilttime VAR Byte 'tilttime
pantime VAR Byte 'pantime

' initialization/maxline
LOW tilt
LOW pan
tilttime = 10
pantime = 30
tiltdelay = 450
pandelay = 700
tiltseed=50
panseed=1100
TPseed=1
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 > 450 OR tiltdelay < 101 ) '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 = 0 TO tilttime
PULSOUT tilt, tiltdelay 'send out pulse to servo
PAUSE 18
NEXT
RETURN

PanIt:
RANDOM panseed ' mix random number with seed value
pandelay=panseed
DO WHILE (pandelay > 1100 OR pandelay < 101 ) ' wait till within movement specs
RANDOM panseed ' mix numbers up again
pandelay=panseed
LOOP ' loop until numbers are within correct movement range

FOR i = 0 TO pantime 'Start pan movements
PULSOUT pan,pandelay
PAUSE 18
NEXT
RETURN

GWJax
GWJax's picture

No you just set your random seeding to start at a lower value you need to change the part I underline to 50:

' initialization/maxline
  LOW tilt
  LOW pan
  tilttime = 10 ' change this to 50 and re program the chip
  pantime = 30
  tiltdelay = 450
  pandelay = 700

I hear some binding as well did you change your max and min data locations and did you use the first programs I posted for testing the range of the servos first before installing the ramdom program?

GWJax
GWJax's picture

run the first program and test the tilt locations and write down the max number and min number and do the same for the pan. now look at this part of the code and change the numbers.

RANDOM tiltseed ' give a random number
tiltdelay=tiltseed
DO WHILE (tiltdelay > 450 OR tiltdelay < 101 ) 'check to see if tilt is within specs chage for your servo
RANDOM tiltseed ' mixup numbers
tiltdelay=tiltseed
LOOP 'continue till values are right for movement
GOSUB tiltit

PanIt:
RANDOM panseed ' mix random number with seed value
pandelay=panseed
DO WHILE (pandelay > 1100 OR pandelay < 101 ) ' wait till within movement specs change for your servo
RANDOM panseed ' mix numbers up again
pandelay=panseed
LOOP ' loop until numbers are within correct movement range

GWJax
GWJax's picture

I guess you could use this feature when he is scared! LOL

by the way nice job!

RobosapienV2-4mem8
RobosapienV2-4mem8's picture

Ah, I thought it was the speed to alter not time, Ok I will have a look shortly Gw. I will have to pay more attention to what you say. Also I here what you are saying about the binding, I have swapped servos and this does not occour wnen the tilt servo is swapped for the pan servo. When I used the first code for setup nothing happened the servo was stationary as if the center position was correct, is this right??

GWJax
GWJax's picture

yes but you have to input new values into the debug console from the keyboard and the servos will move to the new location.

GWJax
GWJax's picture

also you must keep the stamp plugged into the computer as well

GWJax
GWJax's picture

Please welcome one of my new robots that is made from the Radio Shack r/c spider. All electronics are gutted except for the Hbridge board. It now has a tilt/pan head with Ping sensor and can walk around and look for anything that in the way and avoid it. The code is being made and tested. When it is finnished a video and code will be placed here in this thread. I did this for 4mem8's Wall-E to bring life to his bot. Everything in this soon to be posted code will most likely be in the Wall-E with some changes. I may add a RX TX sensor in the rear also but not right now. So here is a picture of the RS R/C Spider after the mod.

RobosapienV2-4mem8
RobosapienV2-4mem8's picture

Awesome GW, Good work. Nice to see a different bot in action, Does it reverse when something is directly in front of him? then turn left or right at random?

RobosapienV2-4mem8
RobosapienV2-4mem8's picture

Awesome GW, Good work. Nice to see a different bot in action, Does it reverse when something is directly in front of him? then turn left or right at random?

GWJax
GWJax's picture

It will act as if it has AI built into it but AI is nothing more than the sight of being alive. it will determine which is the longest path of avoidence and take that route. I've been working on the program since I've been home and I'm running out of variables that the bs2 can handle, but I'll make due. the program right now is pretty long and I still have a lot to do. so when its finnished you'll be able to use it as a test bed for the Wall-E project. I think you may need at least 2 basic stamps in your finnished project to do all that you want it to do, but we'll see. the basic stamps can only have 16 word variables or 32 bytes or 64 nibs or 128 bits but no more that total up to 16 word varables. this is the only draw back:( I looked at the coding of the propeller and it is more designed for video than anything else but the real programming would be best in Assembly language which is a lot harder to program. so i'm going to put the propeller to the side for now until I really need one. I hope that will do for your question 4mem8.

RobosapienV2-4mem8
RobosapienV2-4mem8's picture

Yes, That is the draw back with the stamp, I do have two SX chips, can these hold any more variables?

Is the BS2P40 any better? I know the 40 has 32I/O but not sure if it can hold any more variables.

What I have is :

2 BS2's

2 BS2P40's

2 SX28AC/DC-G

GWJax
GWJax's picture

nope! all the same so will make it work with diffrent stamps tied togeather

GWJax
GWJax's picture

OK this is what I have as of now for the spider bot with tilt/pan and ping. The code takes up 32% of eeprom memory and I have 12 Byte variables left to work with. I think I will remove alot of the GOSUB RETURN commands in the LookAround: subroutine and replace it with a BRANCH command to make the program run smother and faster jumping to one subroutine to another. 4mem8 you can use this program for the Wall-E when you get your stamp back up and running. so here it is so far: Man did that mess up my structure format after the past command. Oh Well.

 'Radio Shack R/C spider converted into a self controlled spider
'by GWJax at www.robocommunity.com
' this spider has tilt/pan controls and ping sensor to find its way around

' {$STAMP BS2}
' {$PBASIC 2.5}
Tilt               PIN           1     'sets tilt to pin 1
Pan                PIN           0     'sets pan to pin 0
Eyes               PIN           7     'sets Ping eyes to pin 7
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
InConstant         CON           890   'set constant number for inch may change to cm if I have room
InDistance         VAR           Byte  'use to calculate inch distance may change to a Word for cm
Time               VAR           Word  'hold ping time bounce back
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

' initialization/maxline
  LOW Tilt                       'sets pin low before movements
  LOW Pan                        'sets pin low before movements
  LOW LegLeftback                'sets pin low before movements
  LOW LegLeftFront               'sets pin low before movements
  LOW LegRightBack               'sets pin low before movements
  LOW LegRightFront              'sets pin low before movements

Main:                            'Main program subroutine
 GOSUB LookAround

 GOTO Main

LookAround:

GOSUB PanItCenter                'Center head
  GOSUB CkDistance                 'look at the distance in the center
    CenterFront = InDistance        'set CenterHead with distance recorded
GOSUB LookDownCenter
  GOSUB CKDistance
    DownCenter = InDistance
GOSUB LookUpMax
  GOSUB CkDistance
    UpCenter = InDistance
GOSUB PanItRightCenter
  GOSUB CkDistance
    RightCenter = InDistance
GOSUB LookUpMax
  GOSUB CkDistance
    RightUpMax = InDistance
GOSUB LookDownLR
  GOSUB CkDistance
    RightDownMax = InDistance
GOSUB PanItLeftCenter
  GOSUB CkDistance
    LeftCenter = InDistance
GOSUB LookUpMax
  GOSUB CkDistance
    LeftUpMax = InDistance
GOSUB LOOKDOWNLR
  GOSUB CkDistance
    LeftDownMax = InDistance
GOSUB PanItCenter
DEBUG "center= ",DEC3 centerfront, " center down= ",DEC3 downcenter, CR
DEBUG "center up= ", DEC3 upcenter, " rt center= ",DEC3 rightcenter, CR
DEBUG "rt up= ",DEC3 rightupmax, " rt down= ",DEC3 rightdownmax, CR
DEBUG "lt center= ",DEC3 leftcenter, " lt up= ",DEC3 leftupmax, CR
DEBUG "lft down= ",DEC leftdownmax,CR
STOP  ' The debug commands are for testing locations prior to writing the walk movement codes

GOTO Main

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

GoFoward:                        'moves foward
FOR i = 0 TO 5                   'walk 6 times
  HIGH LegRightFront
    PAUSE 50
  LOW LegRightFront
  HIGH LegLeftFront
    PAUSE 50
  LOW LegLeftFront
NEXT
RETURN

GoBack:
FOR i = 0 TO 5                    ' walk back 6 steps
  HIGH LegRightBack
    PAUSE 50
  LOW LegRightBack
  HIGH LegLeftBack
    PAUSE 50
  LOW LegLeftBack
NEXT
RETURN

PanItCenter:
FOR i = 0 TO 10
  PULSOUT Tilt, 550              'sends out pulse to tilt servo and center
  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
  PAUSE 18                       'wait for 18ms to complete turning
NEXT
RETURN

CKDistance:

PULSOUT Eyes, 5            'send out 5 pings
PULSIN Eyes, 1, Time      'get one ping return
InDistance = InConstant ** Time  'convert to inches in whole numbers to save on variable space
RETURN

RobosapienV2-4mem8
RobosapienV2-4mem8's picture

I take it that this has to be modded to drive two wheel system GW? Nice.

GWJax
GWJax's picture

nope it has the same hbridge in it. so there will be little to modify in it a video is comming shortly.

GWJax
GWJax's picture

heres the video of the code above for the spider.

RobosapienV2-4mem8
RobosapienV2-4mem8's picture

Once again nice GW, Gotta envy you with your coding, I think I would be in my eliment if I could code like you GW. However with your code that you are posting here i hope that i can learn more with seeing code and learning from books. Thanks

GWJax
GWJax's picture

I'm trying to put information remarks in the code so to help you understand a little more on what everthing does

Pages