Im new here, new to arduino, but not new to electrical. I am taking engineering in college and one of the projects is to make an automated car that will accelerate quickly towards a wall and stop for the wall. This can’t be remote controlled and must be completely automated. There will also be an egg protruding 2cm from the front that can’t be broken.
I have been reading a few books about Arduino and the programming and I think I am on the right track. I have an Arduino Uno my brother hooked me up with. I just want to make sure I’m on the right track.
I was thinking of ordering a motor shield, the Tamiya dual motor from Spark fun with the wheels. Also a ultrasonic sensor. I understand basic programming of LED’s and stuff but haven’t yet figured out how to set up the input for the ultrasonic sensor.
DC Motor runs when Arduino is powered on.
Car is held and released on the floor once timer begins.
The car accelerates towards the wall.
Ultrasound sensor detects a distance of maybe 1ft.
Arduino shuts off voltage to motor (maybe help brake the motor by pulsing voltage in the reverse polarity?? is that possible)
Any advice or related projects would be useful to me. Even let me know if I am missing something that I would need to order that I may have overlooked. Thank you in advance.
You concept appears sound but you’ll want to look at the various ultrasound sensors and make sure the update rate and min detection distance are suitable. You may want to “track” the distance to the wall before you get to your braking point so that you don’t miss it between readings.
Motor controllers will often have a “brake” function that works by removing the power and shorting the motor terminals together.
I was aware that the motor shields had a brake, but you now make it clear to me how it works - thanks. However my thoughts are if its worth going with the motor shield over a mosfet for that reason alone. I can’t imagine how effective that braking would be
That last link has the motor only turning one way. You won’t be able to put the motor in reverse. You need transistors (bjt) or mosfets in an H-bridge setup tot redirect the current through the motor. Most if not all motor shields have it integrated into a chip.
A-CleverUsername:
However my thoughts are if its worth going with the motor shield over a mosfet for that reason alone. I can’t imagine how effective that braking would be
As Valen said then you only have motor on and speed control, no reverse function. Now maybe you don't need that for your project, but that doesn't mean e-braking is foregone. It's easy to use the available driver ICs to do braking w/o a reverse function. Adding another FET to a simple FET circuit could do e-braking.
Consider the simple N-channel FET circuit, which switches the motor - lead to ground. That same lead could be switched to Vcc, via another FET, to achieve braking.
As to how effective that might be, or even if it’s needed in your case … only you can say. But do an experiment and feel the difference in trying to turn a motor when its terminals are open vs shorted for yourself.
I made some progress with the project. I was able to energize the TIP120 transistor through Arduino’s Pin 11. Thus effectively switching ground on a seperate circuit that powers a DC motor via 8.4v battery. Then I hooked up the LV-MaxSonar-EZ (MB1010) to the arduino’s A0, 5v and GND. I was able to convert to inches through serial (CoolTerm). I also found a code that averages 60 readings to be more consistent. I am happy with how everything works, but I can’t figure out how to integrate both codes so that the output to the transistor is energized only when the averaged values > 24 inches. I usually can find these things on Google, but i’m having a hard time with this; I have almost 20 pages bookmarked with no definite answer lol. Every sketch I tried the motor just runs definitely. Here are the sketches:
I have it figured out. I used the sketch below and I figured out my “inchesAway” value was way too low. It doesn’t get the average of the readings, but I guess the reading is so quick it doesnt appear to affect the operation of the DC motor. How would I wire another transistor to short the motor terminals together for dynamic braking? I am using the same wiring as shown on this website: http://www.instructables.com/id/Use-Ard … trol-moto/
int sonarPin = 0; //pin connected to analog out on maxsonar sensor
int TIP120Pin = 8; // specifies the pin connected to TIP120 from Arduino
int inchesAway; // inches away from the maxsonar sensor
void setup() {
pinMode(TIP120Pin, OUTPUT);
//Serial.begin(9600); // starts serial communication, used for debugging or seeing the values
}
void loop() {
inchesAway = analogRead(sonarPin) /2;
// reads the maxsonar sensor and divides the value by 2
// approximate distance in inches
//Serial.print(inchesAway); // prints the sensor information from the maxsonar to the serial monitor
Basically you’ve got 1/2 of an H bridge, connected to one of the motors leads. That gives you brake and run functions. Use a driver IC and you can get an off/coast function as well.
That is stuff I haven’t yet thought to explore, thank you for the information. The car is built and functions decently. I need to either play with the location of the sensor or play with the programming. It seems inconsistent with wall detection (stopping when nothing is in front of it and turning on and off). This thing moves very quick. I used solarbotix 224:1 motor/wheel combo and modified the gears so it turns 14:1. I supplied 8v to it and I have to run after it before it possibly smashes into something.
I probably wont incorporate the H-bridge because I already soldered the components to a protoshield. The car will be timed how fast it travels down the track, I think the speed it currently has and the time needed for the car to slow on it’s own won’t impact my score much. For my first project i’d call this a success and I am left with components to build a robot in the future.