This year i have been set the task to design and build an automated car for my final year dissertation.
i am aware that there is another doing this project and i have viewed his page and decided its a good idea to up date this page, then use it to write the final 10k word report that has to go with it.
New parts added at the bottom of page
i am using an 3 stage analoge style speed control that came with the RC car, as the name suggests it has 3 speed stages fast, faster and too fast, i have thought about stepping it down but looks more work than it should be.
Stering works fine and wrote a bit of code to siplyfi the turning prosess:
void left (void) {
turn.write(1);
}
void right (void) {
turn.write(0);
} just have to call left(); or right();, there is a bit of a whine from the servo but im sure this wont matter as it did it before with the remote reciver still attached.
the sensors (SRF05's - the only thing thats lying around Mbed's Lab) and the code i have implemented, does detect if an object in front and behind and are able to detect as close as 5cm, but it is only front and rear and is unable to accuratly judge the space beteen objects for the car to safly pass through.
this was add as even with the detection sensors it would just cut the poer to the motor, then it just free wheels till it either stops in time or hits somthing, the dc moto shorts the motor saftly to allow a much faster stopping time.

the car will look in front till it finds somthing in its path, if there is enough room to continue forward and turn (distance fount after lots of trial and error) it will other wise it will check the same for behind, with this im assuming that there will always be space to atlest start to reverse due to it comming from that direction.




using a QRD1114 uv diode and photo transistor combi, i have been able to detect when a point (marked out by refelctive tape) on the wheel.
by using the time it takes for 1 full rotation of the wheel i can calculate distance travelled in a set time and from that i can calculate the speed and distace.
for this im using the inturpt and timer function to execute the function every time the pin has a rising edge (this means if its stopped then the sensor is still active the function wont be stuck in its self)
the timer will count the diffrence between 2 rising edges and calculate the speed, also with each rising edge the total rotations travelled will go up by 1 this is then multiplied by the circumference of the wheel.
Problems: no detection for loss of traction :- this is in the human element of driving
General Description "The QRD1114 reflective sensor consists of an infrared emitting diode and an NPN silicon photodarlington mounted side by side in a black plastic housing. The on-axis radiation of the emitter and the on-axis response of the detector are both perpendicular to the face of the QRD1114. The photodarlington responds to radiation emitted from the diode only when a reflective object or surface is in the field of view of the detector."
i want the sensor to mesure the time between each pulse and add the total distance travelled,
to do this i am using the IntruptIn and the timer function, when the senstor detects a high pulse it will activate the intrupt function below:
int count,begin,end;
int single_spin;
const int wheel = 257 //in mm
int = Tdist=0;
void trigger()
{
end = timer.read_us();
count = count + 1; // accumulate distance
begin = timer.read_us();
single_spin = end - begin; //time for 1 spin in us
Tdist = wheel * count; //o/p in mm for now
}
int main() {
timer.start();
w.rise(&trigger);
while(1) {
//Main Program here
}
} or something close to it, the output will be in mm but i will be scaling that to a real car tire at get a scale distance, Also this will give the speed of the car for each spin, it might be an idea to do som digital filtering and grab an averadge to get an aprox speed.
this will all eventualy be displayed on a screen on the car as well as being recorded to either an SD card or on board memory
test prog v1.0 car_wheel_sens
i have updated the speed sensor to use on board data logging, it shows how many turns the wheel has made and time it took for that 1 complete turn. it is all outputted to a .csv file where i can calculate the the speed and the total distance travelled.
#include "mbed.h"
#include "Servo.h"
DigitalOut myled(LED1);
DigitalOut myled2(LED2);
InterruptIn w(p16);
Timer timer;
LocalFileSystem local("local");
Servo serv (p21);
int count,begin,end;
int single_spin;
const int wheel = 257; //in mm
int Tdist=0;
int i =0;
void trigger() {
FILE *fp = fopen("/local/out.csv", "a");
count = count + 1;
begin = timer.read_ms();
single_spin = begin - end;
myled2 = !myled2;
fprintf(fp, "%d, %d\n", count, single_spin);
end = timer.read_ms();
fclose(fp);
}
int main() {
timer.start();
w.rise(&trigger);
while (count < 5 ) // set this so it dont keep smashing in to walls !
{
serv.write(0.3);
myled = !myled;
wait(0.1);
}
serv.write(0.5);
}
V1.1 car_wheel_sens
having the write to file in the trigger i know is bad but i need it to record the data for each turn. if do not it would only then point to another function (which I may end up doing) but the problem with that if i get more that 1 trigger pulse it will compromise the data saved.
the next parts to implement will be:
theres quite a bit there to work on i have more to do but i will add them as i come across them.
NB: full scaled speed is 71mph or actual speed is 7.1Mph or 3.2mps --- this was first test may be innacurate!
V1.0 Car_1
V2.0 Car_2
Please log in to post a comment.
Shorting the 7.2v to ground is a very bad Idea and I bet you battery is heating up and you may have already ruined it. That short is creating very high currents along the parallel path next to the motor. I'm guessing you're probably using a NiCad type RC car battery which is probably only around 1000 mAh capacity which would explain why the juice is running out so quick.
You may want to use your switch or maybe BJT Transistor in series with the motor instead of a parallel short, which is what you currently show in your motor brake diagram. You would still be cutting the power to the motor without shorting your voltage to ground therefore no more high currents along that path and blowing up anymore batteries.
Hope this helps.
Aaron