Shop OBEX P1 Docs P2 Docs Learn Events
servo on tripod code help — Parallax Forums

servo on tripod code help

ClineCline Posts: 36
edited 2006-07-13 13:08 in BASIC Stamp
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

·

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-07-12 13:19
    Cline -

    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 -->
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-07-12 13:20
    You should·consider a PWMPAL·PSC (Parallax Servo Controller).· You program one/any of its outputs to position a servo thus and it stays doing that, over & over on its own without having to go back every 20ms in your program.

    Post Edited (PJ Allen) : 7/13/2006 3:29:32 PM GMT
  • Lee HarkerLee Harker Posts: 104
    edited 2006-07-12 13:22
    Cline,
    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 SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-07-12 14:48
    A better approach in this system would be to have all servos pulsed in the same section...The will be pulsed based on variables...During the sections of your program where you need to make changes, it simply changes the variable and the servos is automatically updated each refresh.· This is far more efficient than embedding several calls to refresh, especially when you are already refreshing other servos.· If you're not using a BOE-Bot configuration and you only need the one servo, the same concept applies...Refresh the servos in your loop that reads the sensors and in your conditional statements make changes to the values and they will be take affect on the next pass through the refresh loop.· If this doesn't seem to apply, try providing a description of the flow of your program, as far as what you're trying to do.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com


    Post Edited (Chris Savage (Parallax)) : 7/12/2006 2:56:29 PM GMT
  • AustinAustin Posts: 10
    edited 2006-07-12 20:19
    I am new to the Basic Stamp so I'm not thinking in the programming "box", but, couldn't you simply drive the elevation axis through a worm gear. You could do nothing and it would stay where-is as-is. Start the servo back up to move again. Getting an inexpensive worm gear and case may prove difficult. If worms arn't "tight" they will wobble some.
  • ClineCline Posts: 36
    edited 2006-07-13 12:26
    hi everyone,

    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
  • ClineCline Posts: 36
    edited 2006-07-13 13:08
    Let me ask this,

    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????
Sign In or Register to comment.