Engineering Projects/Robot car/Howard Community College/Fall2012/p3-501 CMLA
Problem Statement
[edit | edit source]Design a system that enables the Robot car to follow two paths, each separately, a figure eight and a ten meter square path
Team Members
[edit | edit source]Summary
[edit | edit source]For this Project our goal was to create a system that we could attach to the power wheel that would enable it to drive on a desired path. In the beginning we decided to make it a 10 meter square path and a figure eight path. We started off with the motor that was used during the first project cycle, a power window motor out of a Honda CR-V, This motor was to be attached to the steering wheel to actuate it left and right. This part of the system took up most of our time. We had to figure out how we would actually attach the motor to the steering wheel and also the programming of the Arduino. The Arduino was mated with a monster moto shield in order to deal with the 12 volts required to power the motor. Using these together we came up with a code that could tell the motor which direction to go in, how we wanted it to stop, and how fast we wanted it to rotate. Then we added a section that is at the beginning of the code that centers the motor before running any other commands. Once this was all done we mounted the motor to the car using a frame that we built and some brackets and zip ties. Although we got this setup working with a power source from the wall we couldn't get a 12v remote power supply so we could actually test the car outside. We ended at a solid point and it is clear where the next team can pick this project up at.
Poster
[edit | edit source]Story
[edit | edit source]Week 1
[edit | edit source]12 Nov 2012
[edit | edit source]We began work on the project today.
After some discussion on exactly which direction we were going to take the project it was decided that we would dig up the old steering assembly and program it steer a specific path. One path would be a rectangle shape and the other would be a figure 8.
The first work we commenced on was to time the steering motor from lock to lock going in both directions. To conduct this test we wired the system so it could easily be turned on, turned off, connected, and disconnected. This is necessary to keep consistency in the test. We did this with the addition of a breaker switch on the power wires and alligator clips that hook onto the breaker on the motor wires.
After four tests in both directions using Marks stopwatch it was found that the average times were 2.5 seconds rotating right, and 2.7 seconds rotating left from lock to lock. However in this there is still some room for error because of differences in Marks reaction time on the stopwatch and the connection quality of our breaker switch.
14 Nov 2012
[edit | edit source]Our goal today was to connect the Arduino to the motor with a Monster Moto Shield and begin testing codes.
The first work was to make our wiring system modular with Arduino as the existing wires are to large to fit into the Moto Shield ports.
1. Two wires were found that already had connectors on them. These wires were stripped and connected to the alligator clips on the motor. Shrink wrap was added to the new connectors so that they could be positioned next to each other and not arc.
2. A harness was found that had smaller wires which could be inserted into the Arduino on the power side. This harness provided a brake point so now half of the harness can just be left on the Moto Shield. This harness also has an extra connector built in and it is just the right size to directly connect to the motor connectors for when we want to jump the Arduino portion of the circuit. The other half of the harness was attached to the breaker switch using connectors and screws.
After that we moved to testing. Mark then uploaded the code that had been used in the first robot car project. However when we flipped the breaker switch the motor did not move and a screeching sound was heard. We tried many things to diagnose this:
- Code is bad
- Monstor Moto Shield is bad
- Wiring is bad
- Wiring is hooked up incorrectly
- An Arduino Motor Shield must be used instead
- Pins not fully seated into Arduino
The only one of these which we did not try was getting another Monster Motor Shield due to time. All other avenues were tested though and none fixed our issue.
16 Nov 2012
[edit | edit source]Today we met to continue work on the steering arm wiring and software. After consulting with Professor Forester we learned that an Arduino Motor shield simply could not handle the power so that option was out. He also suggested that we get a smaller DC motor for testing. It was also suggested that our Monster Motor Shield may be bad. So we got a new Moto Shield.
Lucas found another smaller DC motor and Chris confirmed its operation.
We got another Moto Shield. Immediately we began to see results. We had the motor moving, but only in one direction. After reading the code for a bit it was found that for clockwise, and counter clockwise the Moto shield was sending power to diffrent ports. A bread board was put together sending power from the positive both to one side of the motor and both negative sides to the other side of the motor. This setup was found to work and we moved on to testing the steering motor.
Connecting to the Steering motor was a success and now we have the Arduino controlling the Steering motor. While doing this two things were observed:
- The motor heats up over prolonged use. This is not much of a concern now because the motor is operating constantly, when it is mounted on the car it will only operate when car has to turn.
- The timing difference between left and right is negligible when the system is operating with the Arduino. It could have a long term effect on the cars vector however for now it is not a concern as it can be calibrated out when the system is mounted to the car.
We have began moving into tweaking the code to make the motor do different things. Namely controlling the timing from left to right and making the motor travel different distances left and right. The system responded predictably to altering the timing in the code.
Week2
[edit | edit source]19 Nov 2012
[edit | edit source]The team did not have that much time to work with today and we knew we might not see each other until after Thanksgiving. So with this knowledge we decided to split the team into individual tasks: mounting (steering assembly to car), software, and electronics packaging. Lucas took mounting, Mark took software, and Chris took packaging.
21 Nov 2012
[edit | edit source]Todaythe primary objective was to refine our general code into a code that does what we want. What we want is for the motor to go a certain direction stop then turn back in the opposite direction so the motor could be used to turn a steering wheel one way then turn it back the other to re-straighten the wheel so the car could travel in a straight path once again.This is the part of th code that was changed it can be found in the void loop section of the code as it is meant to be run over and over because our desired path is a square.
motorGo(0,BRAKEGND , 1023);
motorGo(1, BRAKEGND, 1023);
delay(2500);
motorGo(0, CW, 1023);
motorGo(1, CCW, 1023);
delay(100);
motorGo(0,BRAKEGND , 1023);
motorGo(1, BRAKEGND, 1023);
delay(1000);
motorGo(0, CCW, 1023);
motorGo(1, CW, 1023);
delay(100);
motorGo(0,BRAKEGND , 1023);
motorGo(1, BRAKEGND, 1023);
delay(2500);
Now this code will have the car travel for 5 seconds in a straight line turn on the motor for 1/10th of a second then stops there for one second the turns back in the opposite direction for another 1/10th of a second to get the motor back in the centered direction then it stops moving for five seconds and this is when the is able to travel in a straight path.
All this testing was done on a small DC motor because Lucas needed the actual motor to make some modifications to it so the time intervasls are very short for the turns so they would be more visible. A video of this is posted in the video section of this page.
24 Nov 2012
[edit | edit source]Chris purchased an electronics box to put the Arduino inside of. Mark was called to bring the Arduino over and the next day the Arduino was fit to its new box and ready to be mounted to the cars steering assembly. The only part of the packaging that is missing at this point is the battery power supply that will be sourced from adafruit.com and should be received in about a week.
Week 3
[edit | edit source]26 Nov 2012
[edit | edit source]Today we worked on getting some data about the cars speed and turning circle so that Mark could put some starting commands into the Arduino.
We took the car outside and found a light weight person to drive it. We measured the patio tiles to 24 inches and used a stopwatch to determine speed. After several tests and with two different drivers it was found that the weight of the driver could have a great effect on the speed of the car. We tried using a long pipe to depress the gas pedal however the acceleration was to sudden and it was very hard to keep up with the sudden jump when the accelerator was pressed. This would cause the car to jump and then stop until I caught up, making time recording inaccurate.
We found a large heavy motor that we could drop on the accelerator pedal. This was good because it represented a closer estimate of the weight that would actually be in the robot car when it is finished.
the speed of the car was calculated to be 3.8 feet per second or 2.6 miles per hour in low gear.
We also attempted to measure the turning radius based on similar tests. This proved very challenging as we would have to calculate not only the turning radius of the car, but how long it would take the steering motor to turn the wheel and then return to straight while the car is moving. We decided it would be best to wait until we are testing the whole system assembled and make adjustments from there.
28 Nov 2012
[edit | edit source]Today was spent adjusting the code so there were defined variables at the beginning of the sketch so when changing the values of the variable you wouldn't have to go through the code and find all the values you need to change. Below is the definition section of the code that was added
#define LE 1370
#define RI 1350
#define ST 3000
#define PA 2500
#define SP 1023
- The LE value is the amount of time the motor will run left
- The RI value is the amount of time the motor will run right
- The ST value is the amount of time the motor will remain in the centered position therefore driving the car in a straight line
- The PA value is the amount of time the motor will stop in the middle of a turn before driving the motor back in the opposite direction to make the car straighten out again
- The SP value is the speed the motor is running at
Also a centering function was made so that whenever the Arduino is reset the motor would find the desired starting point for the motor. This was done by adding a section of code to the setup function. The logic behind it is, it takes the motor about 2.7 seconds to travel to each extreme of the gear on the motor so wrote a function that would drive the motor 2.7 seconds in the clockwise direction and then 1.35 secs in the counter clockwise direction. So that no matter what point the motor starts at its gonna go 2.7 sec clockwise and then its gonna hit a physical stop on the gear then it is programed to go half way back and that is the center point this value was found through trial and error i first thought it would be 1.35 sec but it ended up being 1.41 sec. This is all shown in a video below along with the motor running the normal turning function afterwards. below is exactly what it looks like in the code aswell.
motorGo(0,BRAKEGND , SP);
motorGo(1, BRAKEGND, SP);
delay(2000);
motorGo(0, CW, SP);
motorGo(1, CCW, SP);
delay(1900);
motorGo(0,BRAKEGND , SP);
motorGo(1, BRAKEGND, SP);
delay(1000);
motorGo(0, CCW, SP);
motorGo(1, CW, SP);
delay(1410);
There is a video of the motor running off this code ing the video section.
30 Nov 2012
[edit | edit source]The bracket system was worked on for the steering motor. The goal was to get this part of the job knocked out so that we could get to building and testing ASAP.
Starting from the base and working up one part at a time dimensions were determined for each part and a plan was put together for how to assemble the steering bracket. Once this was complete the rough blueprints were put together into the instructions that are posted under tutorials.
Also with the basic mock up that was done the position of the motor on the motor plate portion of the bracket was determined and the motor has been screwed down with wood screws and washers directly to where it will have to be when the system is assembled.
Week 4
[edit | edit source]3 Dec 2012
[edit | edit source]We started to assemble to frame that will help hold the motor on the steering wheel. Our design for this frame can be found in the tutorials section. Using half inch plywood we framed out a rectangular box that could be attached to the cars modular platform with a couple of heavy duty brackets that we bought. Pictures can be found of this in the picture section below.
5 Dec 2012
[edit | edit source]Today we fully mounted the motor to the steering wheel using a series of brackets and zip ties. We also used some neoprene foam so as to not damage the cars steering wheel. We then tested to see how well the motor turned the steering wheel. You can definately tell that it rotates the wheel slower than when its not mounted to the wheel. This just means we will have to further adjust the timing in the code.
We also created a pretty cheap but effective way of acctuating the power pedal. We used the framing peice that we added to for the motor mount as a back plate and we wedged a peice of wood in between the two. So one end is pushing up against the frame and the other is push in the gas pedal. And as an emergency relaese there is a loose peice of wood laying perpendicularly under the stick pushing the gas pedal that just needs a light kick to disengage the throttle. This is shown in the video Here
7 Dec 2012
[edit | edit source]Today we were actually going to test the car outside running our steering motor off of a universal 12 volt battrery. We took took it to Battery Plus, a battery specialty store to see if they could charge it for us they that that the battery hed obviously been sitting around for a long time so theyre charging machine didnt even recognise it. so we were unable to obtain a way to power our steering motor remotely. This will be added to the next steps section.
Some work was still accomplished though. The electrical box and the 9V battery box were mounted to the steering bracket and some of the wires were attached. The car was 100% ready to receive a 12V battery and begin vehicle testing.
Videos
[edit | edit source]- Trottle Mechinism
- Motor Turning Wheel
- Close Up of Wheel Turning
- Motor Centering then caring Out Square path
- DC Motor Testing
Decision List
[edit | edit source]
Materials List
[edit | edit source]- Arduino Duelamenove
- Monstet Moto Shield
- 12 volt Power supply
- Wires, connectors, shrink wrap
- Breaker Switch
- Disconnectable wire harness
- Wall charger power source
- 12 volt power Window Motor
- Battery case
- Electronics case
- 1/2" Ply plywood
- Wood Screws
- Washers
- Zip Ties
- Brackets
Software List
[edit | edit source]Arduino 1.01
Tutorials
[edit | edit source]Steering Motor Mount Assembly
[edit | edit source]
Final Code
[edit | edit source]This code runs the motor using a Monster Moto Shield. It will run a centering program every time the Arduino is reset then it will proceed to turn the motor in a clockwise direction then turn back counter clockwise to center then pause for 6 seconds then repeat the turn. Also all the delay values are defined at the top of the code so they can be changed in one easy place.
#define BRAKEVCC 0
#define CW 1
#define CCW 2
#define BRAKEGND 3
#define CS_THRESHOLD 100
#define LE 1370
#define RI 1350
#define ST 3000
#define PA 2500
#define SP 1023
int inApin[2] = {7, 4}; // INA: Clockwise input
int inBpin[2] = {8, 9}; // INB: Counter-clockwise input
int pwmpin[2] = {5, 6}; // PWM input
int cspin[2] = {2, 3}; // CS: Current sense ANALOG input
int enpin[2] = {0, 1}; // EN: Status of switches output (Analog pin)
int statpin = 13;
void setup()
{
Serial.begin(9600);
pinMode(statpin, OUTPUT);
// Initialize digital pins as outputs
for (int i=0; i<2; i++)
{
pinMode(inApin[i], OUTPUT);
pinMode(inBpin[i], OUTPUT);
pinMode(pwmpin[i], OUTPUT);
}
// Initialize braked
for (int i=0; i<2; i++)
{
digitalWrite(inApin[i], LOW);
digitalWrite(inBpin[i], LOW);
}
// motorGo(0, CW, SP);
// motorGo(1, CCW, SP);
motorGo(0,BRAKEGND , SP);
motorGo(1, BRAKEGND, SP);
delay(2000);
motorGo(0, CW, SP);
motorGo(1, CCW, SP);
delay(1900);
motorGo(0,BRAKEGND , SP);
motorGo(1, BRAKEGND, SP);
delay(1000);
motorGo(0, CCW, SP);
motorGo(1, CW, SP);
delay(1410);
}
void loop()
{
motorGo(0,BRAKEGND , SP);
motorGo(1, BRAKEGND, SP);
delay(ST);
motorGo(0, CW, SP);
motorGo(1, CCW, SP);
delay(RI);
motorGo(0,BRAKEGND , SP);
motorGo(1, BRAKEGND, SP);
delay(PA);
motorGo(0, CCW, SP);
motorGo(1, CW, SP);
delay(LE);
motorGo(0,BRAKEGND , SP);
motorGo(1, BRAKEGND, SP);
delay(ST);
if ((analogRead(cspin[0]) < CS_THRESHOLD) && (analogRead(cspin[1]) < CS_THRESHOLD))
digitalWrite(statpin, HIGH);
}
void motorOff(int motor)
{
// Initialize braked
for (int i=0; i<2; i++)
{
digitalWrite(inApin[i], LOW);
digitalWrite(inBpin[i], LOW);
}
analogWrite(pwmpin[motor], 0);
}
/* motorGo() will set a motor going in a specific direction
the motor will continue going in that direction, at that speed
until told to do otherwise.
motor: this should be either 0 or 1, will selet which of the two
motors to be controlled
direct: Should be between 0 and 3, with the following result
0: Brake to VCC
1: Clockwise
2: CounterClockwise
3: Brake to GND
pwm: should be a value between ? and 1023, higher the number, the faster
it'll go
*/
void motorGo(uint8_t motor, uint8_t direct, uint8_t pwm)
{
if (motor <= 1)
{
if (direct <=4)
{
// Set inA[motor]
if (direct <=1)
digitalWrite(inApin[motor], HIGH);
else
digitalWrite(inApin[motor], LOW);
// Set inB[motor]
if ((direct==0)||(direct==2))
digitalWrite(inBpin[motor], HIGH);
else
digitalWrite(inBpin[motor], LOW);
analogWrite(pwmpin[motor], pwm);
}
}
}
Next Steps
[edit | edit source]Where we ended this project is we have the motor fully mounted to the car we have a working motor that actuates the steering wheel left and right for desired amounts of time using and Arduino mated with a Monster Moto Shield. The next steps to be completed will be to get the steering motor and the Arduino running off of remote power sources so you can take the car and have it drive outside. Once that is complete it's a matter of refining the code, specifically the delay amounts, so you actually get the car driving in a desired path. Also you could come up with a more solid way of actuating the gas pedal, as ours wasn't the best but it worked well for us.
Future Group
[edit | edit source]Looks like a great project, hopefully me and my teammates can take over this project and continue where it was left off.
Other Cooler Future Group
[edit | edit source]already have some cool ideas for how it will autonomously drive, but don't think it is there yet.