PDA

View Full Version : Please help with my Motor control with IR motion sensor project



Ulsterhound
02-01-2010, 04:26 AM
Hello All,

I am new to microcontrollers and my new Basic Stamp.

I would like to use my basic stamp to start a motor using an IR sensor to monitor motion. This would start a motor that rotates something. When the rotating object rotates enough I would like it to stop by activating a button. This would then reverse the rotation and hen it has returned to it's starting position it would stop again because it activates another button. Then repeat the process again.

What components should I buy and how do you suggest I program this? Thank you much.

Ulsterhound

Mike Green
02-01-2010, 05:02 AM
Download "What's a Microcontroller?", "Robotics with the BoeBot", and the "BASIC Stamp Syntax and Reference Manual" from Parallax's Downloads area. The first will teach you (if you do the exercises) to program the Stamp. The second will teach you how servo motors operate and how to get them to work with a Stamp. The last will provide a reference for Stamp Basic. Parallax sells IR LEDs and both IR phototransistors and IR detectors (for modulated IR like that in remote controls). As is true for many Parallax products, the documentation and sample code have links on the Parallax webstore page for the product. You'll need some kind of motor. A continuous motion servo motor might do what you want and is simple to interface to a Stamp and simple to use. The Robotics tutorial goes into detail on that. Another tutorial, "IR Remote for the BoeBot Robot", goes into detail on the use of IR LEDs and IR detectors.

I would suggest you first try to describe what you want in more detail before trying to buy components unless you want to experiment first.

Spiral_72
02-02-2010, 11:41 PM
Your project description was a little vague, but as a guess the components would go something like:

Radio Shack:
Breadboard - $10 (you can reuse for many projects)
Jumper wire kit - $6 (you can reuse for many projects)
Parallax IR detector - (My Radio Shack sells this Parallax part)
several small momentary pushbuttons
9V battery and connector or 4xAA pack or?

Any Hobby shop with radio control stuff:
Standard size servo (Hitec, Futaba, Airtronics, JR, whatever) will usually give you roughly 180 degrees of movement. Some are only 90 degrees though. It's easy to control right from your stamp and has a built in position sensor so you always(?) know where it's at.

If you need more than 180 degrees, a continuous rotation servo from Parallax is your best bet, but returning to home position will take a little thought especially if you expect to run it multiple revolutions.





Make sure you read the book linked if you are a complete beginner. Let us know, there's a lot of people willing to help.

Ulsterhound
02-03-2010, 09:23 AM
Thanks to both of you for the replies. If it would help I will try and describe the project in more detail.

I am basically making something similar to a skee ball game where you throw a ball through a hole and that triggers a reward if you make it.

The reward is what the project is for, it is simply a sign on a small piece of 1/8 inch thick extruded PVC that rotates 90-120 degrees, stops for a short amount of time (5 seconds), then rotates back down and awaits another ball passing through the hole.

So I figured I could use an IR emitter and detector as the trigger to start the sequence, when a ball (made of low density foam) blocks the IR signal that would start the rotation of the reward sign. When the sign has rotated the 90-120 degrees or so it would hit a button and that would stop the rotation. After a 5 second count, then the sign would rotate back down 90-120 degrees. The motion would stop again when the sign triggers another button. The process would repeat when triggered again. I would also like it so that the sequence would not try to start again if the IR signal is broken while the rotation sequence is running.

Any other suggestions on components, assembly, and coding would be greatly appreciated.

Spiral_72
02-03-2010, 09:32 PM
Hey, sounds like fun. Just so you know you can make sounds with the stamp as well. Look under the FREQOUT commend in the manual. There's a schematic in the description of how to hook up a speaker. I programmed mine to play a couple tunes and make siren noises, and some other really annoying sounds :)

It sounds like the typical standard 180 degree servo will work. I wouldn't use the Parallax motion detector though. A simple IR Tx/Rx would do just fine. If you gut an old serial mouse it should give you the parts you need. IR transmitter and IR phototransistor that will pretty much hook right to the input pin of your stamp.

http://www.seattlerobotics.org/encoder/200311/johnson/Mousebot.html



I don't think anyone will write the code for you, but start small. Read the book, write a program to count 1-10, then DEBUG the state of a switch on the screen (On/Off), then drive an LED or eight, then get your servo running. Build everything in little sections, get each running properly and put em' together.

Let us know about any more questions!