Shop OBEX P1 Docs P2 Docs Learn Events
Standard Servo — Parallax Forums

Standard Servo

ManetherenManetheren Posts: 117
edited 2009-02-26 13:48 in BASIC Stamp
I had a question about the standard servo.·

I am building a project for school using a standard servo as a gate that opens and closes to allow a BOE-Bot through and wanted to know if it can be made to remember what position it is on and not have to fully open to close or fully close to open.·

·I also need it to check the sensor to see if the bot is through the gate before it closes or while it is closing.

Comments

  • ManetherenManetheren Posts: 117
    edited 2009-02-24 12:21
    After more troubleshooting and experimenting last night I came up with the following code, but I am sure there is a better way fo doing it.

    'Initialization

    Reset:

    FOR temp = 200 TO 200························ 'Reset the cate to closed'
    PULSOUT Servo_pin,temp
    PAUSE 20
    NEXT





    GateCode:

    IF (CloseGate = 1) THEN
    FOR temp = Temp TO 200········ 'Use currently stored word for TEMP as starting point.
    PULSOUT Servo_pin,temp
    PAUSE 20
    IF (interlock = 0)THEN············ 'Break the loop when the gate reaches the latch.'
    Gate = 2
    GOTO main
    ENDIF
    NEXT
    ELSEIF (OpenGate = 1) THEN
    FOR temp = Temp TO 700
    PULSOUT Servo_pin,temp
    PAUSE 20
    IF (interlock = 0) AND (closegate = 1) THEN············ 'Break the loop if the BOT reaks INTERLOCK while gate is closing.'
    gate = 2
    GOTO main
    ENDIF
    NEXT
    ENDIF
  • FranklinFranklin Posts: 4,747
    edited 2009-02-26 02:45
    Where is main? Where do you use Gate?
    200 to 200 is at most one time through the loop.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • ManetherenManetheren Posts: 117
    edited 2009-02-26 13:48
    THe 200 to 200 is jsut to reset the servo to the start of the cycle.· Attached is the current copy of the code used, but it is currently unfinished as I want to add in the 433 Hz tranceivers to control the BOE-Bot and have a password code used between the gate and the bot before it opens for the bot that is set by the RFID that the gate reads.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Manetheren
Sign In or Register to comment.