Simple Stamp Program for an eager newbie

I have a printing machine that has run since 1987 chewing through solenoids at the rate of 3/year. I just got a HSR-5990TG servo, a Basic Stamp 2, and Bot Board II to replace.

I’m in trouble… It will take time to figure out the programming for this application and I don’t have it.

The stroke for this machine is triggered by a +5W output pulse from our computer’s serial cable.

When triggered, I need to have the servo rotate CW for 500ms then CCW for 500ms and then wait for the next pulse.

I have only a vague idea as to how to program this…

I’m a little rusty on my BS2 foo…

Dusting off the manual…

[code]'servo connects to I/O pin 4
'parallel port line (pulse) goes on I/O pin 0.
'make sure there is a ground connection from Bot Board and PC port.

x var word

main:
if in0 = 1 then pos1 'if pin0 is high goto label pos1 else goto pos2.

pos2: 'this rotates the servo to -45° CCW as long as the input is low.
pulsout 4, 500 'change the 500 to adjust the position.
pause 20
goto main

pos1: 'this rotates the servo to 45° CW as fast as possible and holds for ~500mS
for x=1 to 20 'change the 20 to adjust how long it stays in this position.
pulsout 4, 1000 'change the 1000 to adjust the position.
pause 20
next
goto main[/code]

I didn’t try to run it. Let me know if it works out.

I just edited the post. I had some things out of order…