corresponding color for that routine: green if the door is
open; red if it is closed.
Caveats
Servos and optical limits switches both come with their
own caveats. Servos tend to twitch when powered up and
so there is often some small amount of movement.
Normally, this wouldn’t be such a concern. However, if your
door is already at its limit and a power-on twitch tries to
move it past that, you can put stress on the mechanical
parts. Fortunately, hobby servos don’t tend to have a lot of
torque.
Optical limit switches seem like a fancy way of solving
an issue without any moving parts to wear out, but I did run
into something to be aware of. While filming the video of
the door on the demo opening and closing, an interesting
thing happened. The door tried to open past the limit switch
and fractured the laser-cut frame before the fishing line
broke, relieving stress on the door. What happened was that
the bright lights I use when recording video washed out the
phototransistors on the limit switches, causing them to think
the beam had never been broken.
One thing to try is to tweak the phototransistor circuit
so that more light is required and to shield the LED and
phototransistor from ambient light so that only a direct
beam from the LED would saturate the phototransistor. In
many projects, this would work. When using translucent
materials, however, this may not work as well.
For added safety, you can also change the
opened/closed state of things by making it so that the
phototransistor is blocked when the door is in transition
and saturated at the limit points. That way, if one or both
of the sensors gets washed out for some reason, the door
can be set not to move. This also includes the possibility of
using a single optical limit switch for both positions in some
applications.
Final Thoughts
If you need more torque or speed, a servo may not be
your best option. Likewise, if light is an issue, an optical
limit switch may not be the best solution for you. Using two
buttons was for both completeness and simplicity. The code
and hardware could easily be designed to work with just
one button or none, but rather receive the command from
some other part of your code or a flag variable.
We’ll be discussing other options for limit switches in
the next two parts. My website will have a video of this
project in action, as well as some examples for the Propeller
chip and variations of the example code. You can also email
me with any questions you may (see Resources). SV
Parts List
(1) Board of Education Full Kit USB (#28803)
(1) Li-Ion Power Pack Full Kit (#28989)
(1) Parallax Continuous Rotation Servo (#900-00008)
(1) Bi-Color T1-3/4 LED (#350-00005)
( 2) Infrared T1-3/4 LED (#350-00003)
( 2) 850NM T1-3/4 Phototransistor (#350-00029)
(1) 220 ohm 1/4W 5% Carbon Film Resistor (#150-02210)
( 2) 1K 1/4W 5% Carbon Film Resistor (#150-01020)
( 4) 10K 1/4W 5% Carbon Film Resistor (#150-01030)
( 2) N.O. Pushbuttons (could use #400-00002)
For the finest in robots,
parts, and services, go to
www.servomagazine.
com and click on
Robo-Links.
;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-;;;-;;;;
;; ;;;;;;;;;;;;
46 SERVO 09.2016