Anda di halaman 1dari 16

American University of Beirut

Faculty of Engineering & Architecture


Mechanical Engineering

Line Following Car Project


Mechatronics

Submitted to: Dr. Daniel Asmar and Mr.Bassam Jalgha Date: Monday, November 21, 2011

Group Members:
Samer Bu Jawde-200902075 Charbel Azzi-201002385

Line Following Car

Table of Content
1. The Logic Design 2. The Infrareds Circuit 3. The Steering circuit 4. The Timers Circuit 5. The Car Hack Circuit 6. The Light and Fire Circuit 7. The Password Circuit 8. Appendix (Photos & Videos) P. 2 P. 3 P. 4 P. 5 P.6 P.8 P.9 P.11

Line Following Car

1. The Logic Design


The first step in building a car that follows the dark line track was to design the logic of the circuit that deals with every situation which might occur such as the drifting of the car away from the track. The best design that was found for this project and which led our car to follow the whole track in complete success was as follows: 1. Three infrareds were used. The middle one was used to keep the car in a straight motion. The left for steering left, and the right infrared for steering right. 2. The left and right infrareds were to be connected to a JK dual flip flop. This is one of the most basic and most important decisions made for the design. The dual flip flop was used in order to store the last value (or action) if the car drifted away or missed a corner so that it will be able to continue this action until it completely recovers (returns to the track). (this fact is shown clearly in the video) 3. The Flip Flop has two outputs Q and Q which are to be used as inputs to 2 AND-Gates. Two AND-Gates based on the following digital circuit; i. Following the current logic, 3 inputs are to be considered for designing the digital circuit of the car: one representing the middle infrared, the other two representing the left and right infrareds. ii. Considering the cases in which the car is to steer left or right, two cases of interests were found. The first is when the middle and the right infrared are off (not on the dark line) and the left infrared is ON, in this case the car must steer left. The second case is when the middle and the left infrared are off (not on the dark line) and the right infrared is ON, in this case the car must steer right. In all other cases no steering is required. The following logic table summarizes all the cases and the two outputs needed: Middle(M) 0 0 0 0 1 1 1 1 Left(L) 0 0 1 1 0 0 1 1 Right(R) 0 1 0 1 0 1 0 1 F1 0 1 0 0 0 0 0 0 F2 0 0 1 0 0 0 0 0

Here F1 consists of the case where the car has to steer right and the F2 represents the case were the car has to steer left 4. Applying the sum of products theory : F1=MLR and

Line Following Car F2=MLR So two AND-Gates each with 3 inputs-1 Output are needed. But the outputs of the Flip Flop Q and Q can deal with our two cases here, by connecting Q to L and Q to R we eventually obtain F1=MQQ=MQ and F2=M(Q)Q=MQQ=MQ. So the 2 cases are reduced to two AND-Gates with 2 inputs-1 output.

2. The Infrareds Circuit

Figure 1: Infrared Circuit As shown in figure 1, three infrareds were use, one emitter and one receiver (phototransitor) long with their corresponding voltage dividers. The power for the car this circuit was supplied by a 9V

Line Following Car


battery as shown, where a voltage regulator (L7805) was used to obtain 5V. In the bottom of the figure a separate voltage divider was built as a reference voltage which is equal to the difference between the voltage of the infrared when seeing the dark line and the voltage when they are away of it (the potentiometer is the change the value if any disturbance happened, in the lab this reference voltage was about 1.2V). Each Phototransistor output is connected to one input of an LM339 Comparator to be compared with the reference voltage and the output will be 5V if one the Infrareds is seeing the dark line and 0V if not. (Pull-up resistors are essential to obtain a 5V voltage output, here after large trials we found out the needed values of the Pull-up resistors shown in the figure). The three output wires shown are to be connected to the Flip-Flop of figure 2.

3. The Steering Circuit

Figure 2: Steering Circuit The two outputs pins of the comparator corresponding to the left and right infrareds are connected to J and K inputs of a JK flip flop as shown in Figure 2. The two outputs Q and Q are to be

Line Following Car


connected each one to one input of an AND-Gate (M74HC08B1) as demonstrated in the digital circuit design section (1K Pull-up resistors are used at the outputs of each flip flop and AND-Gate). The other two inputs (pin 6 and 4 of the AND-Gate), is the inverted value of the middle infrared (M) so as shown in the figure a transistor was used as an inverter where pin 5 of the comparator of figure 1 is the connected to the gate in order to invert that coming value. The two outputs from the AND-Gate are the left and right steering orders to be connected to the H-Bridge, while the Pin13Clock is the clock of the flip flop that has to be given a square wave input from figure 3. Sample Trial: When the middle and right infrareds are not on the line(are low) , while the left one is on the line, the outputs of the comparator will be low for pins 4 and 5 and high for pin 10. Then the low value of pin 5 will be inverted to high in the inverter and sent to pins 6 and 4 of the AND-Gate. For the flip flop J=1 and K=0 so Q=1 and Q=0, then pin 7 of the AND-Gate is high and pin 5 is low hence a left steering order will be given.

4. The Timers Circuit

Figure 3: Timers Circuit Figures 3 shows the circuit of two 555Timers that are both used in the Astable Mode . The First one is dedicated for the flip flop clock in order to obtain a PWM that triggers it at it decreasing edge. The

Line Following Car


combination of a C1=0.01Mf and the two resistors R2=1K and R3=10K were enough to give the clock the needed PWM in order to function (note that Vcc pin 8 is 5V here). The second timer is the one that changes the duty cycle of the cars motor. Two 1MOhm potentiometers were used along a C3=0.01Mf: by manipulating the two pots we can control the speed of the motor (note that at pin 3 a Pull-up resistor was optional to used). Also note that the supply of the motor timer was not 5V but it was an order given from the car remote controller and the password output as shown in figure 4.

5. The Car Hacked Circuit

Figure 4: Car Hacked Circuit Instead of building our H-Bridge circuit using the L298, which is straight forward, we decided to Hack the car built-in circuit. After studying carefully all the car circuit (which is one of the coolest things is this project), the best way to hack the cars H-Bridge was by cutting the left and right pins of the microcontroller and connect to them their corresponding output pins from the AND-Gate of figure 3 (as shown in figure 4). By hacking the car circuit we came up with an extra feature that allows to control the

Line Following Car


ON-OFF of the car. By taking the two forward and reverse pins of the microcontroller (without cutting them off) and connect them respectively to the J and K pins of a JK fip flop then connecting only the output Q to one input of an AND-Gate while the other input is the password output, we were able to give the order for the car to start and stop it whenever the reverse button is pressed. The output of the AND-Gate is the Vcc to the motor timer in figure 3. Also an another 9V battery was dedicated to supply only the car circuit because the H-Bride needed high power consumption alone. Sample trial: When the insert password is correct the car wont start unless the forward button were pressed and then directly released. So J=1 and K=0 at the moment the forward button of the remote control is pressed ie Q=1 and when it is released J=K=0 but Q is saved as Q=1 so the output of the ANDGate is high and the motor timer will have its Vcc to start the motor of the car. This case remains as is until the forward button is pressed and directly released which causes J=0 and K=1 ie Q=0 then J=K=0 at the release moment which stores the value of Q=0 and stops the car. Note that this feature worked extremely in an accurate manner but due to power consumption issues required by the steering motor.

Line Following Car

6. The Light and Fire Circuit

Figure 5: Light and Fire Circuit

As shown in Figure 5, A voltage divider of 1K along with three resistors in series (sum of them is 1.69K) were used to obtain the right calibrated (reference)voltage for the photoresistance and the RTD sensor. Also 2 identical voltage dividers form the photoresistance and RTD circuit. The output of the photoresistance is to be compared with the reference voltage in order to detect light and when this comparison is positive(no light exists) a 5V will be transferred to a LED that will light. For the RTD it functioned in an opposite way, thats why the reference voltage is the positive one here. When this difference becomes positive(voltage across the RTD decreases less than the reference voltage indicating an increase in temperature) a buzzer will be turned ON as a fire alarm.

Line Following Car

7. The Password Circuit


Component Functionality in Circuit Regulates the voltage from 12V to5V 5V regulator Buzz when password is incorrect Buzzer Led Buttons LDR JK FlipFlop Capacitor Green Led is on when password is correct. Orange Led is on for incorrect password Produce a semi-sequence and form the password combination The Light Dependent Resistor forms part of the combination. When one places his thumb upon it , it causes power to reach certain buttons and so only then can they be used Saves the previous input thus allows a button to be put on then off Helps regulate the 5V required

Other components include: AND gates, inverters, resistors, and comparator

Further Explanation for the circuit: -So how does the circuit operate? As stated earlier, it is semi-sequential in the senses that the first button (located to your left in the image) must be pressed for the power to reach the second button. Then the second button should be pushed down. For the third button to be on, the first and second buttons should be on, and ones thumb should be on the LDR. -But what is it about the LDR? The LDR is sensitive to light, in other words its resistance and thus the voltage upon it varies with light, so when one puts his thumb on the LDR he is controlling the voltage. The output of the LDR is connected to the comparator. This voltage is compared by the reference set to the comparator. Depending on the comparison the output will be either zero or 5V. Thus this particular combination will allow the third bottom to be on. -Then what? When button 3 is on it controls the op-amp. In other words, when it is pressed it will connect zero to the clock and 5V to the clear. Here one must note that J is connected to 5V and K is connected to ground. And so in such setup, the output of the flip-flop is 5V. Careful! Ones thumb should remain on the LDR.

Line Following Car


Then we repress again the third button, so it is off; however, the output remains high. After that we should press the fourth button to turn it on. Finally, we press the enter key (the lonely button a the top) thus achieving the correct sequence which could be represented as: Button 1 2 3 4 Q flip-flop LDR 5 Condition on on off on on/high Thumb on LDR Enter Key

10

Thus the green led will light, and in case the password was incorrect the orange led along with the buzzer will be on. A schematic of the circuit is shown below. Please note that though the schematic reflects the main concepts of the circuit, it is not accurately constructed as was on the breadboard due to differences in the program Eagle and what was actually done, yet again, we are quite certain that the function and concepts remain the same.

Figure 6: Password Circuit

Line Following Car

11

8. Appendix (Photos and Videos)

Photo 1: Line Following Car

Photo 2: Infrareds Circuit

Line Following Car

12

Photo 3: Steering Circuit (see Figure 2) and The Hack remote control circuit (see Figure 4) (Note that one of the flip flops has its legs cut off because as said before due to power issues we disconnected this flip flop and its corresponding AND-Gate legs from the car hacked circuit)

Photo 4: Timers circuit

Line Following Car

13

Photo 5: Car Hacked Circuit

Photo 6: Light and Fire Circuit

Line Following Car

14

Photo 7: Password Circuit

Videos were taken and they include:


1-live demonstration for the password circuit on breadboard 2-explanation on how the circuit functions with a slight glance on how to have your own small and cool lab. FINALLY AND MOST IMPORTANTLY ALL OUR WORK IS ON THE BLOG SO THAT WE SHARE OUR WORK WITH ANYONE INTERESTED, SO YOU CAN CHECK IT OUT http://www.youtube.com/watch?v=reJ20jB7n0o http://www.youtube.com/watch?v=Zoe-WDOp-_k&feature=related Remaining Glitches/additional features: 1-Though we perforated the board, the password did not function properly. We found out several problems and fixed most of them. So we will be working to finalize this 2-Also, we shall properly connect our car to our password. We are considering using the similar concept as the one used for the flip flop. After the password is written correctly, the output of a flip-flip saves a high output and thus the user can remove his thumb and put off all the buttons. 3-Hopefully, more features will be added eventually.

Line Following Car

15

Anda mungkin juga menyukai