Robotic fish help BS1 servo trouble
I am using a basic stamp one to control two servos for a fish tail. I need to actuate the servos left and right repeatedly. I'm having a bunch of trouble getting the servos to actuate. I am using a traxxas 2019 non modified servo. please help me get started with a code to actuate the servos. Also the movement needs to be pretty quick.
Thanks
Thanks
Comments
Down toward the bottom of this page, you can find some code you can download for some instant fun...
http://www.parallax.com/Store/Accessories/MotorServos/tabid/163/CategoryID/57/List/0/SortField/0/Level/a/ProductID/101/Default.aspx
But you will get more use from this link though...
http://www.parallax.com/Store/Books/EducationalTexts/tabid/181/List/0/CategoryID/66/Level/a/SortField/0/Default.aspx
And You can download the pdf files for free, if you don't want to buy the hard copies...:thumb:
-Tommy
start:
pulsout 7, 85
pause 50
pulsout 7, 175
pause 50
goto start
it will go to the first position at pulsout7, 85 then just stops and twitches. I've been at this for hours and all I want to do is make it turn about 120 degrees back and forth non stop.
start:
for b0=1 to 50
pulsout 7, 85
pause 20
next
pause 1000
for b0=1 to 50
pulsout 7, 175
pause 20
next
pause 1000
goto start
start:
for b0=85 to 175
pulsout 7, b0
pause 20
next
pause 1000
goto start
red wire to vdd
black wire to vss
white wire to pin 7
again all the motor is doing is going to the first programmed position and staying there and oscillating slightly.
If you're using a 9V battery, connect the red wire to Vin, which is the same as the +9V terminal.
Then try those previous programs and also:
a:
FOR B0=1 TO 50 'left
PULSOUT 0,236
PAUSE 20
NEXT
PAUSE 1000
b:
FOR B0=1 TO 50
PULSOUT 0,134' center
PAUSE 20
NEXT
PAUSE 1000
c:
FOR B0=1 TO 50 'right
PULSOUT 0,52
PAUSE 20
NEXT
PAUSE 1000
GOTO a
If pinx = 1 then turnleft
If pinx = 0 then gostraight
turnleft:
PULSOUT 1, xxxx 'left turn
PAUSE 4500 'rudders left for 4.5 seconds
PULSOUT 1, xxxx 'neutral position
FOR B0=1 TO 10 'left
PULSOUT 0,210
PAUSE 20
NEXT
FOR B0=1 TO 10 'right
PULSOUT 0,152
PAUSE 20
NEXT
I can't quite figure out what I'm doing wrong. any advice? Thanks.
I haven't used a BS1, but I'd image it has an ELSE statement. You have it check for the button press and do one thing if it's press and then use ELSE to have it do something if the button isn't pressed.
whatever erco says is the way to go, cuz he do crasy stufffs with the stamp...
You can switch the 5V and gound (the triangle symbol) to make the pin normally low. The schematic I posted is normally high (goes low when button is pressed). The resistor isn't in line with the button. The BS1 pin get connected to two things, the button and the resistor. Not the button through the resistor. (Not " bs1 pin --> resistor --> pushbutton --> GND", that wont work.)
I don't know of any solenoids that can be savely driven from a BS1 (not that I'm a solenoid expert). Usually one drives a solenoid with a transistor. You might also need a flyback diode across the solenoid.
Are the motors "m" servos?
I wonder (just a little) about having the switch on the ground side of the two batteries. Does anyone here know if there's a danger of having a voltage potential across the two batterys' positive sides? I doubt it's a problem but I think I would have gone for a DPDT switch on the two positive ends of the batteries.
would yall say something of the configuration shown on page 2 of this document would work? http://www.parallax.com/dl/docs/cols/nv/vol1/col/nv6.pdf
Thanks.
' {$PBASIC 1.0}
start:
'fin motors
IF PIN0 = 1 THEN left
IF PIN1 = 1 THEN right
a:
FOR B0=1 TO 10 'left
PULSOUT 6,210
PAUSE 20
NEXT
FOR B0=1 TO 10 'right
PULSOUT 6,152
PAUSE 20
NEXT
GOTO a
ballast:
HIGH 3 'opens ballast solenoid valve and starts to sink
PAUSE 15000 'allows 15 seconds to flood ballast
LOW 3 'closes ballast
PAUSE 20000 'allows fish to swim and lowest depth for 20 seconds
HIGH 4 'opens solenoid valve
PAUSE 100 'burst of 20 psi CO2 to partially blow ballast
LOW 4 'closes solenoid valve
PAUSE 20000 'swims at new depth for 20 seconds
HIGH 4
PAUSE 100
LOW 4
PAUSE 20000
HIGH 4
PAUSE 100
LOW 4
PAUSE 20000
GOTO ballast 'returns to ballast program
'
turning >>fixes tail motor for about 5 seconds while the fin motor continues to oscillate
left:
PULSOUT 5, 152 'left turn
PAUSE 5000 'rudders left for 4.5 seconds
PULSOUT 5, 134 'neutral pos
IF PIN1 = 1 THEN left
IF PIN1 = 0 THEN start
right:
PULSOUT 5,210 'right turn
PAUSE 4500 'rudders right for 4.5 seconds
PULSOUT 5,134 'neutral pos
IF PIN0 = 1 THEN right
IF PIN0 = 0 THEN start
Ok here's my initial attempt at a program. I tested all the parts with simple pulsouts, high's and low's and they all work individually so the wiring is good. I want the fin motor to actuate continuously throughout the whole program, I want the rudder motor to turn left or right depending on the bump sensor that gets hit and hold position for about 5 seconds then return to neutral, and the ballast program to run continuously like the fin motor. I downloaded this program and didn't get any of those things =/ any advice guys?
Thanks.
I don't see a way for the program to leave loop "a" once it has been entered.
Is the "fin" servo on pin 5? You want the fin to move back and forth even when the rudder servo (on pin 6?) has been moved?
If you want to keep the fin moving while the rudder is moved to one side, you wont want long pauses (I don't think you'll want them at all). Both servos should be receiving a pulse every 20 ms.
Can you use variables to store data with the BS1? If so, about how many?
The fin servo is on pin 6
the rudder servo is on pin 5
i believe you can store variables on the bs1. I found, on page 87 of the document, http://www.parallax.com/Portals/0/Downloads/docs/prod/stamps/web-BSM-v2.2.pdf, some material on it, but i have to read it a few times and try to figure out what its saying.