Hobby servo control using discrete components (without Stamp)
Greetings!
I'm working on a little project and I'd like to get some help from some of the electronics gurus out there - I'm certainly not one.
The project is this: I wish to actuate a hobby servo motor (unmodified, i.e. no continuous rotation) using the output of a comparator. The comparator senses the light level from a photocell and, upon sensing light, would then start sending PWM pulses from a 555 timer to the servo, commanding it to a certain position and holding it there. Once the light level drops back to dark, the servo would return to its original position.
Now, obviously this is a piece of cake using a Stamp, but for various reasons I wish to use discrete components if it's feasible.
Here's what I have breadboarded so far:
I have set up the photocell circuit using a quad comparator (LM339) and two photocells, each set to turn on an LED when the photocell sees light. When the photocell goes dark, the LEDs go off. This circuit works great.
I have set up a PWM circuit using an 555 chip to drive the servo motor, which, for the purposes of making sure I could get the circuit to work, is modified for continuous rotation. The circuit has a potentiometer to control the direction of the servo, and that seems to be working correctly.
Now, my questions:
(1) How can I get the output of the comparator to trigger the 555 to start sending pulses to the servo?
(2) How do I tell the 555 circuit to only send pulses for a certain amount of time (actually, it's more a question of wishing to only rotate the servo arm 90 degrees)?
(3) How can I get the 555 circuit to return the servo arm to the original position?
I tried hooking up the output of one comp channel to the +5 V of the 555 chip, thinking that when the comp turns on the LED, I could just tap off of that output and plug that into the +5 V of the 555 chip to "turn it on", but that didn't work - I suspect the output from the comp is less than 5 V but I'm not sure.
I'm sure there's a more elegant way to do this using discrete components, but as I said, I'm pretty new to electronics...
Thanks in advance for any help and/or suggestions.
Regards,
Jeff
I'm working on a little project and I'd like to get some help from some of the electronics gurus out there - I'm certainly not one.
The project is this: I wish to actuate a hobby servo motor (unmodified, i.e. no continuous rotation) using the output of a comparator. The comparator senses the light level from a photocell and, upon sensing light, would then start sending PWM pulses from a 555 timer to the servo, commanding it to a certain position and holding it there. Once the light level drops back to dark, the servo would return to its original position.
Now, obviously this is a piece of cake using a Stamp, but for various reasons I wish to use discrete components if it's feasible.
Here's what I have breadboarded so far:
I have set up the photocell circuit using a quad comparator (LM339) and two photocells, each set to turn on an LED when the photocell sees light. When the photocell goes dark, the LEDs go off. This circuit works great.
I have set up a PWM circuit using an 555 chip to drive the servo motor, which, for the purposes of making sure I could get the circuit to work, is modified for continuous rotation. The circuit has a potentiometer to control the direction of the servo, and that seems to be working correctly.
Now, my questions:
(1) How can I get the output of the comparator to trigger the 555 to start sending pulses to the servo?
(2) How do I tell the 555 circuit to only send pulses for a certain amount of time (actually, it's more a question of wishing to only rotate the servo arm 90 degrees)?
(3) How can I get the 555 circuit to return the servo arm to the original position?
I tried hooking up the output of one comp channel to the +5 V of the 555 chip, thinking that when the comp turns on the LED, I could just tap off of that output and plug that into the +5 V of the 555 chip to "turn it on", but that didn't work - I suspect the output from the comp is less than 5 V but I'm not sure.
I'm sure there's a more elegant way to do this using discrete components, but as I said, I'm pretty new to electronics...
Thanks in advance for any help and/or suggestions.
Regards,
Jeff
Comments
crgwbr
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
NerdMaster
For
Life
You will probably need 3 - 555 timers and some discrete logic to make this work right. You need one timer in monostable mode producing a pulse for one servo position when triggered and a second timer in monostable mode producing a pulse for the second servo position when triggered. The outputs of these two timers are or'd together to control the servo. A 3rd timer is in astable mode producing a stream of pulses, approximately one every 20ms. The comparator output and its complement are and'ed with the astable output and connected to the monostable triggers.
Note: You could use the 558 quad timer version with one each used for the monostables and the other two used to create an astable multivibrator. Two quad-NOR gates would take care of all the discrete logic needs (for complementing the 339 output, and'ing with the astable to act as triggers for the monostables, then or'ing the monostable outputs together). That's 4 DIPs and some passive components for timing.
Personally, I'd rather use a BS1. It could measure the light level directly using a photo-resistor and the POT statement, do all the logic, and control the servo using PULSOUT. If you wanted to be able to adjust the servo positions, you could add two additional variable resistors, one for each position, and the BS1 would read their values periodically to set the servo positions.
An SX would certainly be cheaper, particularly with the proto-boards available.
Cost isn't really the reason for the discrete approach. I do own and use an SX for learning and experimenting, and based on your comments I'd say that's what I'll go with. I'm helping a youngster out with a project and, so as not to make it look like she had obvious help from an adult, I was thinking that using discrete components might look a little more "garage" than a nice compact microcontroller. Then again, how many 11 year olds have discrete parts lying around and know how to assemble them into something useful...Hell, I'm 35 and can't do that!
Mike G, thanks for the detailed components list - I think I follow your explanation, and I'm curious to see if I could eventually get that to work, just as a thought experiment.
In addition to your replies, I have collected lots of Stamp documentation over the last couple of years, so I think I have enough information to make this work.
While browsing the Parallax site, I saw the OEM versions - I'd probably want to go with an assembled version, although I can solder reasonably well. Can those be used with standard prototyping boards, assuming it's powered up properly? Allanlane5, you mentioned an SX board for $10 - surely there's more to it than that (components, setup, etc.)? Could you point me to what you're referring to?
I appreciate all your help.
Regards,
Jeff
http://www.parallax.com/detail.asp?product_id=45302
If you've used SX products before, this should be a nice board+processor for you.
Oh, I just looked again, and you may need to purchase a TTL crystal can, or a 50 Mhz resonator for it.
Thanks for all the responses and for steering me in the right direction.
Regards,
Jeff
I think we're gonna tweak it a little and try it out in the backyard.
Thanks again for all the suggestions and help.
well done - 'inventor' !! The first of many I am sure...
Regards,
Quattro
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'Necessity is the mother of invention'