servo on tripod code help
Cline
Posts: 36
im using a countinous servo for rotation, and a regular servo for elevation , problem is the elevation servo needs to pick up· a few ounces and i cant figure out how to keep "power" to it to keep it up. when i do
pulsout 14,850··· it picks up then drops, when i use a loop command it does great but the program doesnt progress, if i add it inside each irdetectleft=0 then it jerks up and down,
the rotation servo is pin 15· the elevation servo is pin 14, 14 is not inhere cause i cant get it to work,
ive tried the counter, but it wont progress either,,
thanks
' {$STAMP BS2}
' {$PBASIC 2.5}
· 'variables
irdetectleft· VAR Bit
irdetectright· VAR Bit
·'initialize
·DEBUG "testing speaker"
·FREQOUT 4, 2000, 3000
·DEBUG CLS,
····· "ir detectors",CR,
····· "left···· right",CR,
····· "_____· ______"
····· main:
·DO
····· FREQOUT 8,1, 38500
····· irdetectleft = IN9
····· FREQOUT 2,1,38500
····· irdetectright = IN0
······· IF (irdetectleft = 0) AND (irdetectright=0) THEN
······· HIGH 7
·············· ELSE
·············· LOW 7
·············· ENDIF
····· IF (irdetectleft = 0) THEN
····· HIGH 10
····· PULSOUT 15,1000
····· ELSE
····· LOW 10
····· ENDIF
····· IF (irdetectright = 0)THEN
····· HIGH 1
····· PULSOUT 15,500
····· ELSE
····· LOW 1
····· ENDIF
····· DEBUG CRSRXY, 2, 3, BIN1 irdetectleft,
··········· CRSRXY, 9, 3, BIN1 irdetectright
······· PAUSE 100
······· LOOP
·
pulsout 14,850··· it picks up then drops, when i use a loop command it does great but the program doesnt progress, if i add it inside each irdetectleft=0 then it jerks up and down,
the rotation servo is pin 15· the elevation servo is pin 14, 14 is not inhere cause i cant get it to work,
ive tried the counter, but it wont progress either,,
thanks
' {$STAMP BS2}
' {$PBASIC 2.5}
· 'variables
irdetectleft· VAR Bit
irdetectright· VAR Bit
·'initialize
·DEBUG "testing speaker"
·FREQOUT 4, 2000, 3000
·DEBUG CLS,
····· "ir detectors",CR,
····· "left···· right",CR,
····· "_____· ______"
····· main:
·DO
····· FREQOUT 8,1, 38500
····· irdetectleft = IN9
····· FREQOUT 2,1,38500
····· irdetectright = IN0
······· IF (irdetectleft = 0) AND (irdetectright=0) THEN
······· HIGH 7
·············· ELSE
·············· LOW 7
·············· ENDIF
····· IF (irdetectleft = 0) THEN
····· HIGH 10
····· PULSOUT 15,1000
····· ELSE
····· LOW 10
····· ENDIF
····· IF (irdetectright = 0)THEN
····· HIGH 1
····· PULSOUT 15,500
····· ELSE
····· LOW 1
····· ENDIF
····· DEBUG CRSRXY, 2, 3, BIN1 irdetectleft,
··········· CRSRXY, 9, 3, BIN1 irdetectright
······· PAUSE 100
······· LOOP
·
Comments
Whether right or wrong, let's presume for the moment that all you need to refresh the R/C servo to where you want it to be is:
pulsout 14,850
Let's further assume that your program is structured as follows, and notice what I do to perform the refresh:
Initialize:
'Do one time housekeping
Mainloop:
'Do something
GOSUB Refresh
'Do something else
'Do other things
GOSUB Refresh
'Go on doing things
GOSUB Refresh
etc
GOTO Finish
Refresh:
pulsout 14,850
RETURN
Finish:
END
That's the basic technique. As you do other things in your program, you must continually refresh the servo's position for it to "hold" position.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
Post Edited (PJ Allen) : 7/13/2006 3:29:32 PM GMT
When you say you tried puting the servo code inside each "irdetect" if-then statement that could mean that the servo would not get a command unless the if-then statement is true. The goal in controlling a servo is to refresh the command around every 20mS. As long as you do that it should be stable. It could be that your loop along with the debug statements is taking too long.
When you go through the irdetect if-then, servo 15 is likely to get a pulse only once in a while. When you send a command to a servo, it is highly possible that the servo will take longer to get to the commanded position that the pulse lasts. It is usually necessary to send a few pulses to a servo to make sure it gets where it's going.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Post Edited (Chris Savage (Parallax)) : 7/12/2006 2:56:29 PM GMT
what im trying to do is this, Using a tripod with rotation and elevation, using Ir and thermal i want to track movement. once this works ill add it to my camera in the warehouse and it will hopefully have a scan routine(move back and forth elevation as well) so it can see all the area of the warehouse.(employees steal!!!)
the thermal i think i would like to place in the middle of the irs so that when they center on you(or motion)
it checks the ambient temp to see if its human, then starts recording and tracking,·· I have an appmod bluetooth 5b500 i would like to use to send me a message through the server.but thats later,SO,,,· ive tried small routines first to make sure they work, this one is the irtester program from the boebot book, i do need elevation and rotation,
i thought originaly that if i created a (headlight) ir (flashlight reworked to hold 5 phototransisitor qsd122 880nm)
that i could get 15/20 ' distance,· but after working all night, the only result i got was TWO INCHES AWAY,
i almost tossed it through the window,,,, i think i have a wiring problem or program problem because of the distance. I was used to the boebot irs that had three prongs and these had two and the flashlight doesnt even hook up to the board.· so i have lots of problems, but i am learning everyday and will succeed with the help of friends.
' {$STAMP BS2}
' {$PBASIC 2.5}
· 'variables
irdetectleft· VAR Bit
irdetectright· VAR Bit
·'initialize
·DEBUG "testing speaker"
·FREQOUT 4, 2000, 3000
·DEBUG CLS,
····· "ir detectors",CR,···· 'shows on debug whether they are working
····· "left···· right",CR,
····· "_____· ______"
····· 'main routine
·DO
····· FREQOUT 8,1, 38500······ 'send left channel
····· irdetectleft = IN9
····· FREQOUT 2,1,38500
····· irdetectright = IN0····· 'send right
······· IF (irdetectleft = 0) AND (irdetectright=0) THEN
······· HIGH 7··················· 'going to add a prog here for camera,lcd now
·············· ELSE
·············· LOW 7
·············· ENDIF
····· IF (irdetectleft = 0) THEN
····· HIGH 10·························· 'rotate left
····· PULSOUT 15,1000
····· ELSE
····· LOW 10
····· ENDIF
····· IF (irdetectright = 0)THEN
····· HIGH 1···························· 'rotate right
····· PULSOUT 15,500
····· ELSE
····· LOW 1
····· ENDIF
····· DEBUG CRSRXY, 2, 3, BIN1 irdetectleft,··· 'show in debug pin states
··········· CRSRXY, 9, 3, BIN1 irdetectright
······· PAUSE 100
······· LOOP
this emiiter.collecter, qsd122 silicon infrared phototransistor, right side only, i have pin2 to 10k resistor to collector, then a jumper from emitter to pin0. ok, now on pin 2 i use freqout 2,1,38500, and IN0
so, since the flashlights are separate, i run this through the debug and the pins show 1,, turn on flashlight, 0
but its only from TWO INCHES away, and unlike the irs that came in bobot they dont pick up reflection, only shinning it right on the colector/emmitter,
i thought the freqout command was for the ir[noparse][[/noparse]flashlight] not the colector, am i wrong????