Welcome to the second installment of q+=a, The Electronic Replicant’s new question-and-answer feature. As nobody has actually submitted a question yet, I’m going to consult my referral logs again.
Q. How can I control a 120VAC motor with a BASIC stamp?
A . This should not be too difficult if all you need to do is turn the motor on and off. Now, it is important to remember that I am not an electronic engineer, nor do I play one on television. I am also not an electrician, with which one really ought to consider consulting before trying to build anything that interfaces directly with wall current. The following ought to work, but it could just as easily electrocute you, catch fire, or otherwise malfunction. You’re probably better off buying an X-10 module.
Still there? You are obviously an individual of unswayable fortitude, or perhaps you have simply fallen asleep at the keyboard. In either case, what you’ll need is something along these lines:
This is quite similar to the motor controllers I mentioned last time. A pulse from the BASIC Stamp (or other microcontroller, or your PC, or whatever else) causes the LED side of the optocoupler to emit light and thus trigger the phototransistor side of the optocoupler. The transistor energizes the relay coil, creating a magnetic field which closes the contacts, allowing AC to flow from the plug to the socket, thus powering your motor, Christmas lights, fan, pump, or whatever.
A nice thing about this circuit is that the optocoupler will protect the Stamp or PC from destruction by high voltage if the relay happens to short, which is not likely, but it could happen if the current flowing through the contacts is much higher than what the relay is rated for. That could also lead to the relay melting and/or bursting into flame, which is just not a good thing. Of course, the optocoupler is really effective only if the PC and relay are on separate power supplies.
That concludes this installment of q+=a. If you’ve got a question you’d like answered, or if you think my answers are utterly and completely useless, or both, or neither, please leave a comment at the prompt.