User:Mmuhlbock/enes100/Robotcar

''This is designed for a person working on a project for 4 weeks as part of a 3 credit class. Please copy this form to your user page. Then delete everything in italics when filling out this form.''

Write problem/project Goal
Our goal for this project is to take a Power Wheel toy car and give it some sort of autonomous functions ie. enable it to navigate through a hallway or follow a laid out path or follow a certain objects. The first steps to this project will include finding a power wheel that we can modify. Once we acquire the power wheel we will need to determine how we can rig the steering so that it can be controlled solely on commands given by an Arduino Chip or some other type of remote input.

My First Task
My first task will be to research what makes power wheels go. From how exactly the steering works to if the throttle is a variable control or if it is more of an on off switch. Also what kind of breaking system is used in the power wheel. lastly how much power could we use from the battery to power a motor that can actuate the steering wheel for us.

Summary of actual work over first weekend
The engineering department has decided to buy a brand new power wheel I am not aware of the model or type yet so my research parameters are very broad and i am just now trying to get a decent feel for the general layout of a power wheel in general from the electrical layout to the way the steering actually works.

Week1 Narrative
My first place to start to research was to see if anyone anywhere as attempted and documented any autonomy done to a power wheel.

I ended up finding a whole forum dedicated solely to modifying Power Wheels this could prove to be a very useful reference/idea hub for our future endeavors on this project. here is the link to the forum [|Modified Power Wheel Forum]

This[|This] build in particular has some components that we could use such as the wasy he controled the steering with a servo motor. Although this project inparticular he is going the RC poute and we want to go more the autonomous route with our "robot" car.

My Second Task
Hopefully the Power wheel arrives this week so we can start some kind of hands on work with the different systems involved with the power wheel. If not continue further work on the steering motor and mounting system and learn more about how we can use the Arduino to help actually regulate power to the different components that we need to add.

Summary of actual work over second weekend
Bought a power window motor off of craigslist this motor was chosen due to the ability to move in both directions and also typically has a pretty good amount of torque. The motor was handed off to Derek who further tested and mounted it so testing could be easier. Now I'm trying to figure out how to create a code that can work the Arduino using the Sparkfun Monster Motosheild but I wont be able to actively test due to not having the Monter Motosheild on hand.

Week2 Narrative
After bringing in the motor to class we started to test the motors functionality and torque. While testing the motor in order to get a good idea of the torque output of the motor we tried to physically resist the motors movement and it ended up being quite difficult to stop it from moving. So we figure that if the Power wheel manufacturer expects a child to turn the steering wheel and it is difficult for one of us to stop the motor from moving the this motor should have an adequate amount of torque to turn the steering wheel.

Next we brainstormed how we actually want the motor to actuate the steering wheel initially we thought of using an arm the comes off of the steering wheel but the we decided to that we should directly mount the motor to the front of the steering wheel so now we need to come up with a way to go about that.

Over the weekend I was tasked with researching how to get the Arduino and the Monster Motosheild to talk to the motor. Since I didn't have either one on me I couldn't experiment too much but I found some example code on spark funs website. I Don't actually have the Arduino on me so couldn't do much actual coding so ive been relegated to research. below is some basic info on the Monster Motosheild programing

Use the motorGo(uint8_t motor, uint8_t direct, uint8_t pwm) function to get motors going in either CW, CCW, BRAKEVCC, or BRAKEGND. Use motorOff(int motor) to turn a specific motor off. The motor variable in each function should be either a 0 or a 1. pwm in the motorGo function should be a value between 0 and 255. */
 * 1) define BRAKEVCC 0
 * 2) define CW  1
 * 3) define CCW 2
 * 4) define BRAKEGND 3
 * 5) define CS_THRESHOLD 100

/* VNH2SP30 pin definitions xxx[0] controls '1' outputs xxx[1] controls '2' outputs */ 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)

The controls vary from time to run the motor to which direction the motor is spinning.

My Third task
Take info learned about the Monster Motosheild and transfer it into usable code to power the steering motor.

Summary of actual work over third weekend
This week the Power wheel came in so we got a general sense of the size a scope of the thing. We measured how many degrees in either direction the steering wheel needs to be turned in either direction and we also measure the turning radius of the car itself. We also received a sonic proximity sensor that we hooked up to the Arduino and had it display the distance of the nearest object was on the serial monitor.

Week3 Narrative
We received the Power wheel this week so we began to evaluate key data points that we need that pertain to the steering system. First we measured how much the steering wheel turns in either direction and we found that the maximum amount the steering wheel turns is 45 degrees in either direction. Then we measure how much our motor turns in either direction starting from a pre-determined position in the middle of the motor. We found that it turns about 60 degrees in either direction. This presented a problem for us as we do not want the motor to over turn the steering wheel and have it potentially break something. The first suggestion made was to address the problem in coding but that was deemed to risky. We decided to use a physical method to stop the motors motion at 45 degrees of motion in either direction Chris is taking care of this. The next thing we did was hook the sonic proximity sensor we bought and we hooked that up to an Arduino we found some sample code that enabled us to display the distance of the nearest object on the serial monitor. After we did this we found out that the sensor is good out to 200cm then after that it cant pick anything up. So then we had to determine if this was an adequate distance for the power wheel to have enough space to react and turn with out hitting the wall or something else so we measured what the turning radius of the car was and we got roughly 230cm and that is if the car starts to turn instantly not accounting for reaction time and time for the motor to actually turn the wheel. So this bring up another problem of how to get the car to actually get around a turn if the car can only sense 200cm in front of it.

My Fourth task
The final week we are going to come up with a code that can take the data the proximity sensor is collecting and turn that into the actual motor turning one way or the other. We will test is by making a mock up of the set up and then walking in front of the sensor and the theoretically this will trigger the motor to turn away from the object. We also want to fit some sort of clamps to or motor so that it wont be permanently affixed to the steering wheel and can be easily taken off and on with out any major surgery to the car.

Summary of actual work over fourth weekend
Tried to use what I learned from two different sketches I found one being a program that reads distance using a proximity sensor the other an example sketch on how to control a DC motor with the monster moto shield

Week4 Narrative
Studied two different sketches got both of the to work with the hardware I have one being a sketch that uses the proximity sensor to display distance of the nearest object in the serial monitor. This was successfully changed to what we need and it is shown below.


 * 1) define trigPin 12
 * 2) define echoPin 13

void setup { Serial.begin (9600); pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); }

void loop { int duration, distance; digitalWrite(trigPin, HIGH); delayMicroseconds(1000); digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH); distance = (duration/2) / 29.1; if (distance >= 250 || distance <= 0){ Serial.println("Out of range"); } else { Serial.print(distance); Serial.println(" cm"); } delay(500);}}

The next sketch was found on the sparkfun website the creators of the Monster moto shield link found [| HERE]. iI tried to uses this code and what it ended up doing was moving the motor back and forth on 1/2 second intervals. Using the set up pictured to the right the black wire being the 12v plug in power supply and the blue/grey wires being the wires that go to the motor. From this program I learned about the motorgo function so i ended up trying to combine the two using if else statements. What I was trying to make happen was for the sensor to read the distance of the nearest object and once it came into a certain distance have the motor turn on for half a second and then delay for 1 second then turn back to the original position after about 3 hours of working with it I wasnt getting any where with constant error messages that kept hampering my code. I will post the code that i eventually gave up on so a future team can either fix it or learn from my mistakes.


 * 1) define trigPin 12
 * 2) define echoPin 13
 * 3) define BRAKEVCC 0
 * 4) define CW  1
 * 5) define CCW 2
 * 6) define BRAKEGND 3
 * 7) define CS_THRESHOLD 100

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 = 11; void setup { Serial.begin (9600); pinMode(trigpin, OUTPUT); pinMode(echoPin, INPUT); pinMode(statpin, OUTPUT); for (int i=0; i<2; i++)

}

void loop { int duration, distance,pos=0,i; digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH); distance = (duration/2) / 29.1; Serial.print(distance); Serial.println(" cm"); if(distance<5) { motorGo(0, CW, 1023); motorGo(1, CCW, 1023); delay(500);

motorGo(1, CCW, 1023); motorGo(0, CW, 1023); delay(500); } else{ write(0); } delay(100);

}

IMPORTANT NOTE FOR FUTURE TEAMS: IF YOU WANT TO USE THE CODE POSTED ABOVE COPY AND PASTE IT FROM THE EDIT PAGE.