Can a STAMP do this
in BASIC Stamp
Hi everyone. I've been lurking for a while and decided to finally take the plunge. I'm wanting to apply motion to a sphere and make it move very similar to an owl's head. So 3 motions involved. Rotation, say 180º max, Tilt backwards and forwards say 45º and Tilt sideways to left and right again 45º max. It would need to be both a sequential movement and a combined movement and totally random interspersed with various periods of inactivity, so think owl.
What I have from my junk drawer is a Board of Education Rev B, 2 Basic Stamps BS2e Rev D, some servos 0.1sec/60degree 1.4 kg/cm torque. a bunch of various resistors and capacitors.
What I DON'T have is any programming skills or knowledge. I've been playing around trying to program the stamps with what I think are some possibilities but getting nowhere fast. Maybe I'm approaching this all wrong and need something a bit more sophisticated than the Stamp.
So any help would be really appreciated and maybe save me a lot of time going in the wrong direction.
Thanks
What I have from my junk drawer is a Board of Education Rev B, 2 Basic Stamps BS2e Rev D, some servos 0.1sec/60degree 1.4 kg/cm torque. a bunch of various resistors and capacitors.
What I DON'T have is any programming skills or knowledge. I've been playing around trying to program the stamps with what I think are some possibilities but getting nowhere fast. Maybe I'm approaching this all wrong and need something a bit more sophisticated than the Stamp.
So any help would be really appreciated and maybe save me a lot of time going in the wrong direction.
Thanks

Comments
A Stamp can do only one thing at a time. In this case, it has to output a 0.5 to 2.5ms control pulse to each of the three servos in turn in a 20ms cycle. During the left over time (12.5ms) in each cycle, your program has to figure out the next positions for the subsequent cycle ... not hard to do. Typically your program keeps a "current position" for each servo (a number from 250 to 1250) and an increment / decrement value for the position. Each cycle the current position is used in a PULSOUT statement to generate the control pulse, then the increment / decrement value is added to the current position limited by the bounds you place on servo position (use MIN and MAX operators). After that, your program would generate a random number and use that to figure out what to do next.
As far as I can tell all the servos are "standard" servos as the max amount of movement I have managed to get is about 100º.
Here's what I've been playing with.
'{$STAMP BS2e}
'{$PBASIC 2.5}
counter VAR WORD
DO
DEBUG "Pulse width increment by 8", CR
FOR counter = 500 TO 1000 STEP 6
PULSOUT 15, counter
PAUSE 10
DEBUG DEC5 counter, CR, CRSRUP
NEXT
DEBUG CR, " Pulse width decrement by 4", CR
FOR counter = 1000 TO 500 STEP 4
PULSOUT 15, counter
DEBUG DEC5 counter, CR, CRSRUP
NEXT
DEBUG CR, "Repeat", CR
LOOP
Another
'What's a Microcontroller - ServoTestbs2
'Test the servo at three different position signals
'{$STAMP BS2e}
'{$PBASIC 2.5}
counter VAR WORD
DO
DEBUG "Center 12 o'clock", CR
FOR counter = 1 TO 150
PULSOUT 15, 500
PAUSE 20
NEXT
DEBUG "counter 10 o'clock", CR
FOR counter = 1 TO 500
PULSOUT 15, 500
PAUSE 20
NEXT
DEBUG "Clockwise 3 o'clock", CR
FOR counter = 1 TO 150
PULSOUT 15, 500
PAUSE 20
NEXT
DEBUG "Center 12 o'clock", CR
FOR counter = 1 TO 150
PULSOUT 15, 750
PAUSE 20
NEXT
DEBUG "All Done."
LOOP
END
All from the "What's a controller? book from Parallax
I cannot find any way to stop the rotation. It just performs like a windshield wiper.
Altering PULSOUT values just seems to alter speed not the distance.
Thanks again
Here is some code I used to test a pan and tilt mechanism for an Owl head.
' {$STAMP BS2} ' {$PBASIC 2.5} ' random movements for tilt and pan movements ' Change the STEP command number higher to speed the scan up ' By: GWJax ' variables Tilt PIN 12 ' set tilt to pin 1 Pan PIN 13 ' 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 = 750 'set for center of tilt LastDelayPan = 750 '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 10000 '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 > 750 OR pandelay < 500 ) ' 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 10000 'Change Step Number Higher to go faster PULSOUT pan, i PAUSE 30 NEXT LastDelayPan = PanDelay RETURNI believe I was using the Servocity Pan and Tilt system at the time:
https://www.servocity.com/spt100
Do remember that some Stamp Basic statements (including PULSOUT) have timing values that vary depending on the Stamp model. Look at the chapter in the Stamp Reference Manual on the PULSOUT statement for details.
He mentioned that he's not a programmer and that he needs to blend servo movements. The "new processor" block in Blockly would make this really easy to program.
Ken Gracey
A turntable of some kind for rotation could be on the bottom with a continuous servo geared down or pulley arrangement.
On top of that you have the tilt (nod) servo which may or may not need to be geared. If not, the standard servo would do. So far you have a standard "elevation over azimuth" telescope mount.
Finally you have the tilt sideways which likely could be a standard servo with the owl mounted directly on the shaft.
A BS-2e can easily handle three Parallax servos with 75% of its time available to decide what to do next.
Once again many thanks to all, you guys are great. Now for some serious construction
https://www.servocity.com/spt200
The owl head was just at 2 lbs, so you need to use the servos they recommend. Those small 9 gram ? servos will not cut it.
I've used the program and connected 2 servos but the amount of movement on both of them is very small, less than 5º. Also there are no long pauses on the pan. Is there any way to pause the pan for something like 2 minutes?
Here's the prototype. The body can be made bigger to accommodate a tilt and pan mechanism plus servos and batteries with a slide switch underneath. Head is 5" diameter and is solid wood. Weighs 12 ounces but can be hollowed.
I tried to upload a small video but unfortunately the forum doesn't allow it. I would definitely like to make the pan move in bigger increments up to 180º right now the max seems to be about 15º
Thanks
Check your batteries because servos use a lot of power especially when they are trying to maintain their position.
In the old days you needed to modify a servo to make it rotate continuously but today you can buy servos that were built for continuous rotation.
What is the rating of your power supply and is it regulated?
You could drop the voltage using a voltage divider or diodes but using batteries or a 6V REGULATED power supply is much simpler.
This is using a voltage divider: 9V ___/\/\/\___.___/\/\/\___.___/\/\/\___ Ground or Vss 330 ohm ^ 330 ohm 330 ohm | |_ Get 6V from here since 2/3 of 9 is 6 This is using diodes: 9V ---|>|---.---|>|---.---|>|---.---|>|--- 6.2V (Each diode drops about 0.7V) 1N400x 1N400x 1N400x 1N400xA: There is nothing a Stamp can't do.
As you have found, Kinectricity!