Unformatted text preview:

EE40 Final Project 1 Smart Car Name SID 1 Name SID 2 Introduction The final project is to create an intelligent vehicle better known as a robot You will be provided with a chassis motorized base which has breadboard space for you to build circuits and a microcontroller As in lab 6 you will be writing the program that tells the robot what to do but you will also build the interface circuits that enable the microcontroller to control the robot s actions Like an actual engineering job you will plan the design of your circuits and gain the approval of your boss your GSI before actually building your circuits Power Source Because a robot must move around and availability of short cables we can t use the plug power that we usually do in the lab This means we need to use batteries to power everything on the robot Since motors consume a lot more power than the microcontroller using separate batteries for the motors and the microcontroller lets us use bigger batteries and higher voltages for the motors without damaging the microcontroller Be extra careful to never short out the motor batteries They have no output off setting and no current limit and will happily try to melt any wires breadboard rows ICs or tools you short their terminals with Measure the resistance of the motor Now based on this resistance value along with the voltage that the battery can supply and the energy mA hour that the battery provides find out how long would you expect the motor batteries to be able to continuously power the two motors if they don t spin 1pt Motor Resistance Battery Voltage Battery Energy Stand by Time Motor Driver if we run the motors from a separate power source we can t connect the microcontroller directly to the motors so an interface is required We will be using a classic motor interface design called an H bridge which can be bought as a single IC for convenience It lets us run a motor in either direction easily Figure 1 A basic Hbridge IC using MOSFETs DC motors like the ones we use have a sort of polarization If the polarity of the applied voltage is flipped they will rotate in the opposite direction An H bridge is a convenient way of producing this polarity flip By turning on one transistor on each side we can make the motor voltage Vm positive or negative Can you see a problem with this simple design that can arise if we aren t careful with inputs 1pt We can avoid this problem by using a purpose built motor driver chip that uses the same general design but prevents problematic inputs from being possible in the first place We are using the SN754410 which contains four sides of an Hbridge on a single chip Each input on the chip controls whether the corresponding output is connected to Vcc or ground The major problem we have with the SN754410 is that it cannot take its inputs directly from the microcontroller If you look at its data sheet you will see that its minimum allowed input voltage is larger than the maximum voltage that the microcontroller can put out Figure 2 Pinout and function of the SN754410 This problem can be solved by translating the 3V signals produced by the microcontroller into higher voltage signals The motor batteries provide 4 8V which is a sufficiently high voltage for this purpose There are a variety of circuits capable of achieving this in this lab we will use op amps We could build an amplifier but that is actually more complicated than we need Remember that an op amp magnifies the difference between its inputs until its output reaches its supply voltage Can you use this property to design a simple circuit to convert a 0 3V digital signal into a 0 4 8V digital signal without using any feedback Be sure to include some tolerance for inputs that aren t exactly zero This circuit is called a comparator 2pt Now put it all together Draw a schematic of one entire motor driving circuit starting with two microcontroller pins 0 to 3 volt range remember and ending with a motor This will form half of your robot s motion system Be sure to connect every pin on the half of the SN754410 you re using You ll be using LMC6482 dual op amp chips for your operational amplifier needs 1pt Figure 3 Pinout of the LMC6482 Get approval of your circuit from your GSI then get the parts and build the circuit on your robot s breadboard Control Software Having the hardware we need is nice Now for the software To start off let s have the robot only move forward move backward or stand still Port 10 s pins are in a convenient place on the microcontroller board so we ll use them to drive the motors To do this we need to both set up the pins we need as outputs and create functions to move the robot around The following code configures Port 10 pins 0 through 3 as outputs P10OUT BIT0 BIT1 BIT2 BIT3 P10 0 3 low P10SEL 0x00 All of port 10 set up for digital I O P10DIR BIT0 BIT1 BIT2 BIT3 configure P10 0 as output Now create functions you can use to move the robot around All these functions need to do is move the motors in the right directions your main function can decide what to do after that Don t forget the motors might already be moving void forward 1pt void backward 1pt void left 1pt void right 1pt A stop function would probably also be useful Now that you can program your robot to move around have it do something neat move back and forth spin around whatever you like You may find it useful to add the old delay function to your code and use it to control the length of time that the robot moves in a given direction void delay unsigned int n while n 0 n Once you ve put together a routine for your robot show it to the GSI Sensing We now have a fairly basic motorized vehicle However this is not much of a robot it has no ability to observe the world and react We will add this ability with the pair of switches on the front First we need to add the code that enables the microcontroller to detect the state of the switches If they are connected to pins 6 and 7 of Port 10 that code is P10OUT BIT6 BIT7 set P10 6 7 high P10DIR BIT6 BIT7 P10 6 7 set as outputs P10REN BIT6 BIT7 activate pull up resistors for P10 6 7 Now the state of the switch on pin 6 for example can be used to make decisions We can choose between two options as shown below if P10IN BIT6 is P10 6 low is the switch pressed switch is pressed do the stuff in these curly braces else optional switch is released do the stuff in these braces instead A fairly simple …


View Full Document

Berkeley ELENG 40 - EE40 Final Project

Documents in this Course
Lecture 3

Lecture 3

73 pages

Lecture 1

Lecture 1

84 pages

Guide 4

Guide 4

8 pages

Diodes

Diodes

7 pages

Quiz

Quiz

9 pages

Load more
Loading Unlocking...
Login

Join to view EE40 Final Project and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view EE40 Final Project and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?