Bot board ii + basic stamp 2ic

First I would like to say “HI!” 2 everyone! since I’m new to this forum.

I recently got a school asignment (finishing year) , that involves building a robot from scratch. My teacher gave me 1x BOT BOARD II, 1x BASIC STAMP 2IC , and 4x servos ( HS - 5645MG ), the bot board and basic stamp came with the “Basic stamp Syntax and reference Manual” - some yellow book, and 5-6 pages describing the Bot Board II.

Using my pre-electronics “skill” I managed to power up the BOT Board with the BS 2IC, downloaded stampw.exe, used the “Identify” feature and got a “Found BS2-IC (firmware 1.0).” message. My engineering senses tell me that it’s all well 'till now.

This is my description of the current situation.

Got all the hardware, controlling unit, servos, a programming software and a programming book.

My target:

I need to make a TRI-POD in about 4-5 days. I decided to use some light weight metals (from PC PSU - if you got any other suggestions please tell me) and some plastic.

As a first try I would want to connect 2-3 servos and make the work 1 after another :

1st servo moves 40degrees
2nd servo moves 40degrees
3rd servo moves 40 degrees

after this,

1st and 2nd servos moves 40degrees
3rd moves…smt

doesn’t have to be exactly 40degrees, I just want to know how I can program them to work simultaniously or 1 at a time.

After I learn how to control the servos I will begin building the robot.

So, if someone could give me a CODE SAMPLE that can get PROGRAMMED INTO the BBII using a BS2-IC and moves 1 servo, 2 servos or heck even 4.

This way I can see how it all works, modify stuff, make some calculations and make different sequence of movements.

Thank you all in advance,

Adrian

…4 servos? I don’t mean to rain on your parade or anything, but I don’t see a tripod with only 4 servos. Do you plan on getting more?

no, just 3 servos. my teacher told me it can be done. I got 4 servos just for the heck of it. It doesn`t have to be anything special, just to be able to get around 10-20cm. I plan on making it walk by dragging, 2 feet for support…anyway ill see about that.

im trying to make a servo move using BB2 + BS2IC.

I powered the VL by a 9Vdc battery (just about 7vdc got out of it with my multimetter).

Now I don`t know how to connect the servos to the BB2 and set the jumpers.

BTW, I got an AD adapter that gives 6,8-6,9Vdc, the limit is said to be 7.2Vdc for VS (servo supply on BB2), so I think I’m in the clear, or the value is 2 high.

Thank you for your replies!

Your challenge is going to be implementing a group move using the BS2 since the only way you can generate PWM pulses is inline code. using digital servos like the hs5645mg might help you though since they are not nearly as sensitive to the 20ms frame rate as an analog servo would be.

I’ll get you started… first thing you need to do is be able to send a pulse to every servo varying in duration from 500uS to 2500uS every 20mS… forever. with the digital servos the off time isn’t quite as important as the on time but it’s got to be close or the servo may decide to ignore you entirely.

Simple loop… initialize 4 variables to 1500, then start a loop and for each variable in turn set an output pin high, use the variable as a delay parameter, set the pin low, use 2500-variable as a delay parameter, do the next variable/output pin pair. Once you have done all 4 variables/pins you delay for 10mS… maybe use some of that time to adjust the the values in the variables… and start the whole loop over again.

pseudo code would be something like

init:
a=b=c=d=1500
low 1
low 2
low 3
low 4

loop_top:
high 1
delay a
low 1
delay 2500-a
high 2
delay b
low 2
delay 2500-b
… etc etc …
delay 10000
… do something to maybe change a, b, c, or d …
goto loop_top

Say you want to move a servo 40 degrees over a period of 1 second. Typical servo resolution is about 0.09 degree per us so one over that is about 11 us per degree so you need to move the servo from whatever position it is in to +/- 440uS. What you (probably) can’t do is just send the servo to the new position and wait 1 second before moving it again because it will take about 0.15 seconds to get from one position to the other and then it’s going to sit still. What you need to do is move it incrementally by adjusting the pulse length over the 1 second travel time. There are nominally 50 servo pulses in a second so each pulse wants to move +/- 440 us / 50 = +/- 8.8 us from where it was last time, for 50 iterations. I really don’t recommend using floating point as it’s too slow… better instead to try just using 9 while you get the loop to work and then go back and figure out making a fractional accumulator using integers if you need some precision.

Should be enough to either panic you into buying an ssc-32 which does the servo movement details for you, or get you brain churnning away on how to write the code using what you’ve been handed. it is certainly do-able but you are going to have to think it out. first thing I’d recommend is getting familliar with using the bs2 syntax and how to do basic stuff (no pun intended) like declare variables and read/write the pin states.

@wowy, he might be going to just use long actuators on 3 of them as legs and the 4th to move one of the 3 other servos around or something to shift balance. it’ll be crude but it could work… which I’d bet is the point of the exercise. :wink:

6v is probably ok but be forewarned that usually these type of “universal” adapters are only rated a couple hundred mA which will not be enough to move servos with any sort of load on them. You would be a lot better off with a 4 or 5 AA-cell nimh pack for VS.

Welcome…

These questions usually get answered really fast. However no one is jumping on this because frankly the BS2 is the worst for controlling servos directly. I can show you how to move servos into positions, but there is simply no easy way to make these move in a slow or controlled manor. The example I am showing you will move the servo as fast as possible to the desired position. The only way to move a servo slowly is to send it a series of pulses where the position changes a little each repetition.

The following program is off the top of my head, you will need to properly assign your variables. It should work. It will move the two servos into three position with a 1 second delay in between. Good luck with it.

[code]'500 = ~45° CCW
'750 = ~ centered
'1000 = ~45° CW

temp1 = 500
temp2 = 1000
gosub makepulses
pause 1000

temp1 = 1000
temp2 = 500
gosub makepulses
pause 1000

temp1 = 750
temp2 = 750
gosub makepulses
pause 1000

makepulses:
for x=1 to 50
pulsout 0, temp1
pulsout 1, temp2
pause 20
next
return[/code]

it gives 500mA, or thats what it says on the package (it’s an adapter from a panasonic phone … i got angry for getting headshoted in CS and smashed it, so im left with the adapter). Didn’t bother to check it…this night I just plan on getting familiar with the programming and moving a servo.

I`ve read your comment and I’m starting to understand the technical details behind my task.

I could use some help with the jumper settings.

I’ve removed the Jumper that gives me support for PS2 controller.

The jumper that connects VS+VL to the same power source.

The rest is as it came in the package.

I’m guessing that the motors connect to the large batch of jumpers opposite to the serial connector… the ones that say “AX0 1,2,3 P0 1,2,3 , 4,5,6,7,”.

would really appreciate it if someone could tell me what they all mean so I can connect the 3 wired cable from my motor and start ‘pulsing’.

P.S. I know about the power supply issue regarding the servos. Saw at my school a hexapod powered by regular AA rechargebles…they lasted about 5sec. I just plan to make it move to get how it tick, so I`ll worry about a stronger PS at the end when it all comes togheter.

Thanks again eddieB for your help!

Ha! I cheezed out and gave a pseudo code example instead of going and looking up the details in the handbook. :stuck_out_tongue:

Ha ha Eddie I took the easy route to answering this. So Buzdugan read my reply, then Eddies. :wink:

Start here…
lynxmotion.com/images/data/bb2pdf.pdf

You’re not likely to make much progress with that adapter.

servos should plug directly into each set of 3 pins, the pins are grouped in 4 sets of 3 for each block. the inner most pins are signal, the outer most are gnd. there is for each block a jumper that selects VS or VL for the center pins for the block. if you are powering a servo use VS. if you are powering a sensor use VL. if I recall correctly it slowly dawned on me what the silkscreen was showing me on the board at some point after I have gone and d/l the manual and schematic for the bb2 the first time I played with one.

he might have read both our replies but you haven’t explained how to hook up a BB2 to 4 servos yet. :wink: :smiley:

Dude you are so ninja-ing my replies. :imp:

:mrgreen:

It’s so hard to phonetically spell out Bruce Lee ninja sounds.

Whaaaa! ohhaaaa! wheeeaaaaa!!! :open_mouth:

This is where you configure the I/O bus center row to use VL (+5vdc from
the onboard regulator) or VS (direct fromthe Servo Power Input). This is
done in banks of four I/O pins. Caution, applying the servo voltage to this
row with a 5vdc peripheral installed will cause damage to the peripheral.

SO i WANT THE JUMPER TO CONNECT

O O O - no jumper

to be

O X X for 5V

and not

X X O with 6.9V from the VS supply.

This is kinda keeping me in the dark…

Ill start reading the user guide maybe it will shed some light on the matter.

The I/O pins are needed for my servos im guessing…

hmm, I think maybe an important point is you really shouldn’t have 6.9V on the VS input if you plan to run servos from VS… which is realistically you only option since the 5V regulator on the BB2 can’t supply enough current to run them from VL either.

Im still stuck at this I/O pin to get power from the VS or VL.

I don’t understand what it means by peripheral, the MCU or the servo…

I connected the jumper just like in the pretty picture from the user guide (to the VS).

I just finished connecting 3 servos, connected the AC adapter…it’s all ready, as soon as I get the “OK” that it’s all good (im worried about that jumper not to burn the servos/MCU or smt) im gonna try to start programming it.

So I switch the pin to VS instead of VL (i think you made a mistake and you were refering to VL not VS).

and use the power I get from VS not VL.

Am I okay till now ?

VL is powered by 9VDc battery.

VS is powered by 6.9VDC adapter.

Jumper for VS+VL is disconnected.

now Ill move the pin for I/O from VL to VS.

so I should be okay, right?

1 more thing.

in the pretty picture from the UG with the description “Applies VS and VL to
analog inputs 0 and 1.”

am I to leave only the VS and take out the VL jumper?

I`m guessing yes since it will be 5+6.9 = ~12VDC for the servo…

um, ok…

VS is Voltage for Servos.

VL is Voltage for Logic.

Logic is defined as 5vdc for the electronics on the board, installed microcontroller, sensors, etc. Peripherals is defined as sensors or other electronics that can connect to 5vdc.

You are correct to remove the jumper to separate logic from servo supplies, but you are wrong in your thinking of what it would do if it was connected. The jumper in place would short 6.9vdc to 9vdc. The 9vdc battery would lose the battle.

I hope EddieB isn’t replying too. :cry:

okay so Now Im ready to go. (plugged it all in, the MCU still works so no damage till now)

tried to compile your program but as you said it needs a bit of polishing.

if it’s not to much to ask maybe you could write the whole thing with the allocated variables, since Im new to BS programming, and I dont seem to make any progress with the BS ref. manual.

I connected 3 servos, but just 2 moving is enough for me. they are connected to :

P0, P4, P8

so the

OOOO
OOOO
OOOO

look like

P0 P4 …and so on
XOOO XOOO XOOO
XOOO XOOO XOOO
XOOO XOOO XOOO

if you could help it would be swell … dont want some1 else to do the work for me but 5 days ain`t enough to learn a programming language, build a robot etc. :slight_smile: and I need an example of a code that has external consequences like moving a motor.

(BTW, i did the hellow world program xD )

thanks for all the replies!

You don’t need to read the entire programming guide to grasp setting up a variable. The numbers you need to store are from 250 to 1250. So can you tell me what size variable is required.

I’m sorry to hear you only have 1 week to complete your project. I will tell you what you need to figure out. I’ve already given you ample info to get started.

Crack the manual and read the section for setting up the variables. You will have a better feeling if you figure it out.