microswitch mounting help
ltmhall
Posts: 102
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.
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
Other wise look at this diagram for help.
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
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
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.
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.) Did you connect them in parallel??? If they are in series one switch will cancel the other one out.
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
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.
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
Should be:
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Have Fun
TR
Post Edited (TechnoRobbo) : 11/26/2006 11:33:54 PM GMT
·
·· 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.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support