Shop OBEX P1 Docs P2 Docs Learn Events
microswitch mounting help — Parallax Forums

microswitch mounting help

ltmhallltmhall Posts: 102
edited 2006-11-27 04:48 in BASIC Stamp
I have just connected two micro-switches to my robot. Each switch
has a hinge , so when it pressed it sends a 0 to the micro-controller
to jump to a subroutine to manuver around an object. The problem
i have is when it collides into a object the switch is pressed, but it
doesn't manuver, instead the robot stays stuck on the object it
collided into. If any one has an ideas on how to mount them please
help.

Comments

  • TechnoRobboTechnoRobbo Posts: 323
    edited 2006-11-26 04:34
    Are you using a pulldown resistor? Or is this a programming question? If it's the latter please upload the code.

    Other wise look at this diagram for help.
    attachment.php?attachmentid=44302
    If you're not using a pulldown to get your "0" then you may be shorting your stamp to ground.
    ·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Have Fun


    TR

    Post Edited (TechnoRobbo) : 11/26/2006 4:39:08 AM GMT
    141 x 148 - 6K
  • ltmhallltmhall Posts: 102
    edited 2006-11-26 14:38
    I have the same schematic built except I don't have the 220 ohm resistor connected. Could this be causing my problems.

    This is my code. I used a microswitch and connected C to ground
    and connected the NO pin to the 10 kohm.

    DO
    IF(IN15 = 0)THEN
    GOSUB BACK:
    GOSUB RIGHT:
    ELSE
    GOSUB FORWARD:
    ENDIF
    LOOP

    '
    [noparse][[/noparse]SUBROUTINE]

    FORWARD:
    PULSOUT 13, 850
    PULSOUT 11, 650
    PAUSE 20
    RETURN

    RIGHT:
    FOR pulsecount = 1 TO 20
    PULSOUT 13, 850
    PULSOUT 11, 850
    PAUSE 20
    NEXT
    RETURN

    BACK:
    FOR pulsecount= 1 TO 40
    PULSOUT 13, 650
    PULSOUT 11, 850
    PAUSE 20
    NEXT
    RETURN
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-11-26 15:08
    I always do switches as you see in the attached drawing.· It's good for HomeWork Board, BoE, N.O., N.C., toggle, any and all applications.
    345 x 334 - 13K
  • TechnoRobboTechnoRobbo Posts: 323
    edited 2006-11-26 15:53
    ltmhall·said...
    I have the same schematic built except I don't have the 220 ohm resistor connected. Could this be causing my problems.
    First of all -I called the resistor a pull-down - it's actually a pull-up resistor, sorry.
    It generates a high signal until you push the button which takes the pin low. PJ's shows a pull-down which keeps the circuit low until you push the button and brings the pin high.

    According to your code - you want to use my circuit and keep the pin high (pull-up) until you push the button.
    Either way it's just how you write the code·after you've wired it.
    Itmhall said...
    ·I used a microswitch and connected C to ground
    and connected the NO pin to the 10 kohm.
    What is the Vdd connected to, (I'm assuming and hoping·it's also connected to Pin15 through the resistor)?· The 220 ohm will offer protection to the stamp if the pin gets switched to an output if this happens you'll have a short to ground. (Unless you have a home work board then your covered.)
    Itmhall said...
    I have just connected two micro-switches to my robot.
    Did you connect them in parallel??? If they are in series one switch will cancel the other one out.
    attachment.php?attachmentid=44306
    You should have bench tested·the input sequence using DEBUG. How did that work?


    ·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Have Fun


    TR

    Post Edited (TechnoRobbo) : 11/26/2006 4:18:01 PM GMT
    141 x 148 - 3K
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-11-26 16:36
    I hasten to add that you need to Declare/Assign Pin15 as an Input somewhere at the beginning (i.e. INPUT 15.)· I think that PULSOUT automatically makes a Pin an Output, but using IF(IN15 = 0)THEN does not make the Pin an Input.
  • ltmhallltmhall Posts: 102
    edited 2006-11-26 17:52
    I'm using the BOE and I a'm not using vdd. I have 4 AA batteries in series, which I use to connect to both my servo motors. Currently I'm connecting both switches to that supply, but i'm planing on changing that in the future. The circuit seems
    to work fine but when it runs into an object the switches are pressed, and it if i move the object the robot collides into it, the
    switches are depressed and it performs the manuver code written.

    I'm not sure how to use the debug terminal to test it.
  • TechnoRobboTechnoRobbo Posts: 323
    edited 2006-11-26 20:08
    Could you post a diagram of how the switches are connected. Include all stamp connections and servos please.

    Try adding the lines in red to your code:

    INPUT 15 ' add this to save your stamp as PJ pointed out, I've screwed myself up before by not adding it.

    DO
    DEBUG HOME, IN15 ' use the terminal to monitor and·press the switches·to test your code
    IF(IN15 = 0)THEN
    GOSUB BACK:
    GOSUB RIGHT:
    ELSE
    GOSUB FORWARD:
    ENDIF
    LOOP


    You had me confused with press and depress - they mean the same thing.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Have Fun


    TR
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-11-26 20:16
    Just a quick thing...In the following lines, since there is no code/commands following the GOSUB no : (colon) is needed after the label.· The only time a line should end with a colon is if the line is a Label for a routine by itself, not when following a reference in a command.
    GOSUB BACK:
    GOSUB RIGHT:
    ELSE
    GOSUB FORWARD:
    
    

    Should be:

    GOSUB BACK
    GOSUB RIGHT
    ELSE
    GOSUB FORWARD
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • TechnoRobboTechnoRobbo Posts: 323
    edited 2006-11-26 22:33
    Oddly enough, I've observed that labels followed by colons·that don't start on column 1, and are·preceeded by a command, don't generate syntax errors and seem to be interpreted correctly .

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Have Fun


    TR

    Post Edited (TechnoRobbo) : 11/26/2006 11:33:54 PM GMT
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-11-27 04:48
    TR,
    ·
    ·· That is correct since in that context the colon is used to allow more than one command per line.· The following is an example of where you would use the colon when not after a label…I hope this helps.· Take care.
    LOW 0 : HIGH 1 : LOW 2 : HIGH 3
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
Sign In or Register to comment.