Go Down

Topic: Need to power small dc motor car for specific distance and stop (Read 4 times) previous topic - next topic

GrisGris

I am a middle school teacher writing on behalf of a group of students. I have a G&T class that has a task to power 5 small cars for a specific distance using different power sources and stop within an 18" square . No return, just go when switched on and stop on their own.
We have a small RC car and an Arduino for one of the cars.
We want to use the Arduino as a timer to send power to a relay to switch on the motor and switch it off after a specified time. We plan to test for run time / distance to hopefully get consistent results.
We have a very basic knowledge of programming but we have done a few blinking led sketches from a book.
Can someone please answer the following questions?
Is there a template that we can follow that will do this task?
What relay should we use?
Can we power the Arduino from the 2 AAA car batteries or should we use a 9v battery?
Is there a better way to do this with these components?
Thanks in advance
FT DI

Krodal

Do you have a Arduino Uno ?
That runs at 16MHz, and because of that it needs 5V.
The microcontroller ATmega328P on the Arduino Uno can run on 2 AAA batteries, but only with a lower clock speed.

The relay depends on how much current is switched.
A small cheap 5V relay would be probably be good enough.
You could also use a logical power mosfet or a (darlington) transistor.

To measure the distance, you would need to measure the rotation of an axis or a wheel. This can be done with a magnet and a hall sensor or optical. If you have it working it would be nice to stick a white dot to a wheel and try to measure it with the Arduino and a optical sensor.

JimboZA

#2
Feb 08, 2013, 06:16 pm Last Edit: Feb 08, 2013, 06:20 pm by JimboZA Reason: 1
Welcome.... usually it's the students asking for help  8)

Have a look at these tutorials: This one drives a motor with a transistor, and this one drives a relay. One day you can get fancy and have speed and direction control, like this!

I'm thinking for simplicity, use the transistor one.... You'll see from the pic that the transistor is switched by an Arduino digital pin via a resistor: that's really no different from the Arduino driving a LED. Don't leave out that diode.....

You can't power the Arduino from 2x AAAs, that's only 3V, so yes you could use a 9V PP3 on the barrel jack, and power the motor from the car battery.

Edit... You could use a delay in the code between switching on and off, adjusting the delay value as your experimenting dictates. Put the code in setup() not loop() so that it only runs once:

write a high to the digital pin
delay for x time, ie have motor running for x
write a low to the pin.

Or as Krodal says, get really fancy with distance measuring but I got the impression you'll home in on an "on-time" by trial and error?
Roy from ITCrowd: Have you tried turning it off an on again?
I'm on LinkedIn: http://www.linkedin.com/in/jimbrownza

AWOL

Quote
I have a G&T class

I'm guessing that's not "gin and tonic"?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Shpaget

Basically any relay will do since it appears it's quite a small DC motor. A transistor would most likely be sufficient as well.

However, I wouldn't rely on timing and guessing the run, but rather monitor it. A magnet on a wheel and a reed switch on the chassis will give you a signal for each rotation of the wheel (or, if you want even better precision, put multiple magnets). Multiply number of signals by the circumference of the wheel (or part of the circumference if you use multiple magnets) and you get the distance traveled more consistently than with timing (batteries deplete, motor runs more slowly, car doesn't cover the desired distance).

Go Up