Shop OBEX P1 Docs P2 Docs Learn Events
help with servo — Parallax Forums

help with servo

piezyxwpiezyxw Posts: 9
edited 2011-09-15 22:57 in General Discussion
Hi I recently made a sun tracker with solar panels and all that good stuff but when nearly completed I couldn't figure out how to make the servo go in reverse if it's just code fine, if it's just that I need to tweak the servo fine. Thank you for your help. by the way I'm using the basic stamp 2 with the board of education.

Comments

  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2011-09-15 17:32
    Can you post the code that you are currently using, along with a schematic or a description of how you have things connected? That would help give us a better picture of your set-up and what you have tried.
  • piezyxwpiezyxw Posts: 9
    edited 2011-09-15 17:39
    I just need to know how to get the servo to go the opposite way. But here's the code. The timeTop, Bottom, and Middle are just the photo resistors to tell it were the sun is most concentrated. The servo is plugged into p12

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}

    timeTop VAR Word
    timeBottom VAR Word
    timeMiddle VAR Word
    DO

    HIGH 6
    HIGH 1
    HIGH 10
    PAUSE 2
    RCTIME 1,1,timeBottom
    RCTIME 6,1,timeMiddle
    RCTIME 10,1,timeTop

    DEBUG HOME, "timeTop = ", DEC5 timeTop, "timeBottom = ", DEC5 timeBottom, "timeMiddle = ", DEC5 timeMiddle
    PAUSE 100

    IF (timeTop+30<timeMiddle) THEN
    PULSOUT 12, 625
    ELSEIF (timebottom+30<timeMiddle) THEN
    PULSOUT 12, 625 'this is were i'm having trouble with getting the servo to go the opposite way
    ENDIF
    LOOP
  • PublisonPublison Posts: 12,366
    edited 2011-09-15 17:49
    What values do you get in the Debug window in the different lighting situations? When do you want it to change directions?

    BTW "I just need to know" is not a good way to get an answer. "I'd like to know" would be more appropriate.
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2011-09-15 17:54
    Let me direct you to the PDF "What’s a Microcontroller"...

    http://www.parallax.com/Portals/0/Downloads/docs/prod/edu/28123-WAM-v3.0.pdf

    ... Specifically Chapter 4 Activity #2 "ACTIVITY #2: SERVO CONTROL TEST PROGRAM"
  • piezyxwpiezyxw Posts: 9
    edited 2011-09-15 17:57
    I want it to turn so light is more direct on the solar panels it works going one way but it won't go the other ways everything else works perfectly. If there is more light on the bottom it turns so there is more light on the middle however I want it so when there is more light on the top it will spin the other way so the light is more direct on the middle. But it only spins one way so if there's more light on the bottom it wants to spin all the way back around instead of just going backwards.
  • Matt GillilandMatt Gilliland Posts: 1,406
    edited 2011-09-15 18:12
    Hi piezyxw-
    As Beau suggested - Specifically check out:
    Figure 4-18: Servo Horn Positions, PULSOUT Commands, and ms Pulse Duration
    on page 109.

    That should get you started, plus by entering different values for the duration of the pulses, you'll get a feel for how a servo works.

    In other words, make mistakes and see what happens :-)

    That's the way I learn best - and remember that "letting the smoke out" isn't always bad - I've learned a lot by doing exactly that :)

    Oh, and BTW, welcome to the Forums!
    -Matt
  • piezyxwpiezyxw Posts: 9
    edited 2011-09-15 18:33
    thanks for the help however just telling me that I had to enter a value lower than 350 or whatever would have made this go much faster. But it's working so thanks I can now track the sun so my solar panels are more efficient. keep up the good work!
  • graffixgraffix Posts: 389
    edited 2011-09-15 19:35
    Less than an hour after you posted code,and its fixed.Thats not a bad turn around.
  • Matt GillilandMatt Gilliland Posts: 1,406
    edited 2011-09-15 22:56
    however just telling me that I had to enter a value lower than 350 or whatever would have made this go much faster.

    That is absolutely true, piezyxw!

    However, a "head full of answers" isn't nearly as good as a "thinking head". :-) You asked a question, got some advice on where to find the info you needed, did the research yourself - and came up with the answer you were looking for.

    Well done! Build upon this and the sky's the limit ;-)

    -Matt
  • Matt GillilandMatt Gilliland Posts: 1,406
    edited 2011-09-15 22:57
    Hey piezyxw -

    Could you post a pic of what you've done? It sounds pretty cool :-)
    -Matt
Sign In or Register to comment.