ECE476 Final Project

Embed Size (px)

Citation preview

  • 8/8/2019 ECE476 Final Project

    1/13

    ECE476 Final project (SP 2003)

    RC NSX special edition

    by Lam, Kwan Him (kl259) & Wong, Kim Fung (kw84)

    Introduction | High Level Design | Hardware design | Software design

    Results & Pictures | Conclusion | Programs Listing | Schematics | Cost & Parts | TasksSpecified | References

    Introduction:

    We like car and we like to build our own Atmel Mega32 MCU based radio-controlled NSX. Weset three goals in the initial project proposal and they are as the following:

    (1) Build a RC NSX with the same performance as the original car.

    (2) Add extra features such as headlights and brake

    lights.

    (3) Add distance IR sensor to avoid collision.

    Our objective is to build a RC car with all the circuitries including two H-bridges, a 433MHz

    transmitter and a receiver, a remote controller and Mega 32 prototype boards. We expect it toperform or even out-perform the stock NSX with better steer and speed handling and longeroperating range. We also want it to have some cool features such as distance sensor to avoidcollision and brake lights to blink when the speed is lowered.

    High level design:

    Rationale & project idea:

    We played RC car when we were small and now we are capable to build our own RC car and welike to make this hobby more interesting with some cool features that are hardly seen on the toymarket. With a limited $25 budget, it made this tasks to be more challenging but alsointeresting. We were very clear to set out preliminary design and very careful to order parts.

    Logical structure:

  • 8/8/2019 ECE476 Final Project

    2/13

    In this project, we use radio frequency to transmit and receive data and hence we implement thisdesign with a transmitter end part and receiver end part. The receiver end has plenty ofcircuitries and the transmitter is relatively simple to build. The detail of hardware design isexplained in next section. We were lucky enough to find a pair of cheap receiver and transmitterfrom www.radiotronix.com.

    Two H-bridges are built to in this project . One is used to control the DC motor for speed andanother is used to control the steering of another DC motor. We successfully had the steppermotor in the lab worked but we decided not to use it to provide variable turning angles for thesteering. It was because we were unable to find gears to fit into the NSX and hence unable totest and determine if the output torque was large enough to turn the car.

    Two prototype boards are built for the Mega32 MCUs. On the transmitter end, there is a 3-potslide for varies speed control. Interpretation of the potentiometer value is handled with ADC0 ofPort A. Four switches are used for left or right turn, headlights and bottom lights on/off and alast button for resetting the Mega32 MCU.

    Below is our schematic of high level design.

    Hardware/software tradeoffs:

    This project includes plenty of hardware circuitries and we spent roughly 80% of our work timeto develop, test and revise our hardware components and designs. Soldering of parts together isnot easy and they do break occasionally in so many different unexpected ways. This can wastetremendous of time when only one wire is loose. It is even more challenging when we would

  • 8/8/2019 ECE476 Final Project

    3/13

    like to fit all the circuitries into this small car. On the other hand, writing codes and designingalgorithms are relatively straightforward.

    We have a timeline that was nicely planned....

    Hardware design:

    Prototype board: Two boards are built and they are for transmitter and receiver end each. Thefundamental components that needed to make the board work is explained here but other pinconnection can be seen from the schematic on the appendix section below. Since both boards arepowered up by a 9V battery, voltage regulators are used for them to output a 5V to the Mega32MCUs.

    --LM7805 5V regulator pin1 is input, pin2 is ground, and pin3 is output. Input pin and ground

    are connected (bypassed) with a 0.1F capacitor. Output pin and ground are connected with a0.1F capacitor also. The capacitors should be put as close as possible to both voltage pin andground to provide a stable voltage.

    --Ground and output voltage pins are connected to pin 11 and 10 respectively to the Mega32MCUs. A 0.1F capacitor is put to bypass. Pin 32(AREF) is connected to 5V supply because ofanalog-to-digital conversion needed.

  • 8/8/2019 ECE476 Final Project

    4/13

    --Pin 12 and 13 are connected with 27pF capacitors to ground and pins are connected togetherwith a 16MHz crystal.

    The boards were tested with a program that blinks the LEDs on Port B every second (seeappendix A). With luck, the boards could work without bypassing the Vcc and ground.H

    owever, it does help to stabilize the system when a capacitor is added.

    Receiver & transmitter: Connection of receiver and transmitter are done according to thedatasheet from radiotronix. Again, capacitors are added to bypass the voltage input and ground.Antenna pin of receiver is bent 180 degree in order to receive data. Although they can send andreceive data up to 4800 baud rate, we only use half of its capability as we find that 2400 baudrate is relatively stable. For communicating between the two Mega32 MCUs, we use the UARTand when the specified registers were set, it works without any problem except conflicting withother groups when more than one group is working on it. Data pin of transmitter is connected to

    pin 15 (TXD) of transmitter end MCU while data pin of receiver is connected to pin 14 (RXD) ofreceiver end MCU.

    H-bridges: H-bridge is commonly used to drive DC motor in two directions. With limitedbudget, we decided to build H-bridge using the transistors and other parts available in labs.Components used in our H-bridge include two power NPN BJTs (TIP32C), two power PNPBJTs (TIP31C), four diodes (IN4001) which used to protect the transistors, and four 220resistors. To protect the H-bridge from possible wrong input from micro-controller (shorting thetransistors by attempting to drive the motor forward and reverse simultaneously), we insert

    additional logic circuitry, which consists of two NAND gates and three Inverters, to makeforward and reverse operation exclusively on. (But they can be off simultaneously) Since twoH-bridges are built (one for speed and one for steering), 74LS00N and 74LS04N, which providesfour NAND gates and six inverters, are perfect choice of the logic circuitry.

    Speed of DC motor can be controlled either by varying the currents passing through the motor orswitching the transistors on and off using Pulse Width Modulation. We chose PWM since itreduces both the power consumption and hardware complexity. Instead of using extra DAC toprovide proportional analog voltage, PWM waveforms can be easily generated, as it is one ofbuild in function of our micro-controllers.

    Stepper Motor: The H-bridge that is used for steering do not required any variation of currentor PWM since we cannot vary the turning angle using the original motor. Servo motor is thebest choice for this application but we decided to save the money for distance sensor. Weattempted to replace the role of servo motor with stepper motor, which is available in our lab andcapable of high precision control. The stepper motor can be easily controlled by activatingmagnets in a correct sequence. We had successfully controlled the stepper motor to turn

  • 8/8/2019 ECE476 Final Project

    5/13

    correctly using the micro-controller and transistor arrays (Current from micro-controller is toosmall to drive the stepper motor), but unfortunately we cannot solve the mechanical problem. Asa result, we build another H-bridge to drive the original motor to perform the steering.

    Software design:

    The micro-controller at the transmitter end performs three major tasks; converts the analog inputsignal generated by the potentiometer to digital signal, debounces three input buttons (left, right,light), and transit the encoded command using UART protocol.

    Analog digital conversion is one of the build in functions of the micro-controller. Eight bitaccuracy of ADC is used since only seven distinct levels of input are required. (three levelsforward, three levels reverse, one stop) Simple debounce state machine is used to debounce thethree input buttons. Both tasks are running continuously inside the while loop. The debounce

    instruction is performed when the program is waiting for the ADC result to save processtime.

    Since the receiver that we have contains automatic gain controller function, in order to operate itcorrectly, we have to either transmit the data continuously or sending some ones and zeros beforeeach true command. We decided to transmit the data continuously to simplify the software. Thisis accomplished using transmit complete interrupt at the transmitter end. In the transmitcomplete interrupt service routine, we send the next command by writing the UDR. The eight bitword command is encoded in the way that avoids running long consecutive ones and zeros. The8-bit command format is shown as below.

    --- lights --- directionsteering turn speed1 speed0

    At the receiver end, the micro-controller decodes the command, drives the car using control logicand PWM according to the command, and performs analog to digital conversion to the signalgenerated by the distance sensor. Since the analog input from sensor only updates every 33ms, aTimer0 interrupt is used schedule the conversion. In our program, Timer0 generates interrupt forevery 34ms and ADC starts at the interrupt service routine; but instead of waiting for theconversion to be completed in the ISR, polling of ADC complete flag is used in the while loop.Once the analog voltage from the sensor surpasses certain level as obstacle is detected, the PWMsignal turns to zero and the car stops. Update of command is established by polling the data

    receive complete flag. Once this flag is set, the data in UDR is copied and the command isupdated.

    We also use the software to imitate the real brake light. The brake light is on if the car is stoppedor a decrease of speed is detected. Decrease of speed can be detected by comparing the previousspeed value with current speed value. A simple count, which does not block any other function,is used to let the light be on for a period long enough to be visible to humans.

  • 8/8/2019 ECE476 Final Project

    6/13

    Results & Pictures:

    Picture 1 | Picture 2 | Picture 3 | Picture 4 | Picture 5 | Picture 6 |Picture 7

    We have a favorable result as we have met all our goals. The car runs as fast as the original oneand it is more interesting since there are variable speed, brake lights, headlights and distancesensor. It looks like a real car from pictures and it is especially cool at dark environment.

    The communication during start-up between receiver and transmitter do have some latencies andthe receiver end must be turned on before the transmitter end is on. In case of losing control dueto the wireless communication interference, we do have a reset button on the handler. This caneasily correct the communication problem by resetting the transmitter end MCU.

    There is no safety violation in this project and the car is even safer to play around with theenhanced feature - IR distance sensor. We encountered RF conflict with other groups and this

    issue is explained in the IEEE code of ethics (2) of the conclusion section.

    This is definitely a very interesting project and people can easily play around with it. No priordriving skill is necessary. However, user must be gentle with the handler since the parts are notsecurely enclosed. Violent behavior to the handler will not be tolerated and it will causeimmediately expelled from this exercise.

    Conclusion:

    The digital laboratory was our home for the past month and we had a very intensive schedule tooccupy the workstation that we used to work at. We started early and finished the project justfew days before the demonstration date. We managed to finish all three goals that we set for thisproject and it is amazing that we were ahead of our planned schedule. Generally, it was a funproject for us and we have met all our expectations. Our recommendation to the future groups isto set different goals for the project and start EARLY!

    Things tried and worked but not used...

  • 8/8/2019 ECE476 Final Project

    7/13

    We had also tried couple other features such as variable steer angles, siren sound and flashingblue and red police car lights. All these features work without problem. However, we decidednot to use them in this project because of mechanical, space and wiring problem. First, thecircuitry wiring was more than we expected and we can barely put the cover back on the NSX.As a result, it is impossible to wire more parts than what we currently have. Indeed, we tried to

    wire a speaker and we could not put the cover back. For the various steer angles, we wired andprogrammed a stepper motor and we successfully had it worked. However, we do not have thenecessary gears and chains. Hence, we do not use it.

    Next time...We would plan the circuitry more careful and do a better soldering job.We would like to put speaker to generate horn sound and this can make our NSX even moreinteresting and real.We would buy a long range IR sensor to provide a better safety range since our sensor can senseonly up to 30cm. Our car cannot stop automatically when it is running at full speed. (note: but itworks perfect when the speed is lower.)

    We would design a better controller on the transmitter end instead of using breadboard (althoughit is still nice) and we definitely want to fit the parts back into the original controller.

    Intellectual property considerations:

    In this project, all the designs are original thoughts. The hardware circuitries and codes weredesigned and written by ourselves. We believe that it will waste our time and will be very hardto follow other people hardware design or programs. As a result, we had a very intensive workon this project and started working on it very early.

    All the parts were either ordered by Professor Land or acquired from the digital laboratory. Nosample was got and no non-disclosure was signed.

    About patent opportunity, hmm.......maybe next time.

    IEEE Code of ethics considerations:

    2. to avoid real or perceived conflicts of interest whenever possible, and todisclose them to affected parties when they do exist;

    RF conflict: there were about 5-7 groups using 433MHz from radiotronix and we got a verynasty situation when groups were transmitting data. During the first three weeks of extendedlaboratory time, no RF conflict happened to us and we believed that it was because we workedon the wireless communication relatively early and other groups hadn't worked on that duringthose time. However, this changed within 7 days of project due date. Data received were veryunstable and our RC car behaved abnormally. In order to solve this conflict, we did walkthrough the entire laboratory to notice people that we would test our project with wireless

  • 8/8/2019 ECE476 Final Project

    8/13

    communication. We turned off the transmitter when we were not using it. When groups wantedto test their communication simultaneously, we allocated time slots such as every group testedtheir project for about 10 minutes each.

    4. to reject bribery in all its forms;

    There was no bribery in this final project. We didn't take any advantage of ordering parts withspecified retailer. Parts were ordered with following considerations: delivery time, price andavailability.

    7. to seek, accept, and offer honest criticism of technical work, to acknowledgeand correct errors, and to credit properly the contributions of others;

    H-bridge design was modified to add the inverters into it for safety reason. Prototype boardproblem was solved after bypassing voltage supply and ground. Wireless communication wascorrected for adding initial start-up bytes. This was the credit of Professor Land and we acceptedhis technical help and this helped us successfully to build our RC car.

    8. to treat fairly all persons regardless of such factors as race, religion, gender,disability, age, or national origin;

    Cornell is certainly a very diversified community. ECE department is even more diversifiedwith different races, nationality, gender and religion. We observed no discrimination in thisclass and people do respect individual differences.

    9. to avoid injuring others, their property, reputation, or employment by false ormalicious action;

    Basic laboratory safety rules were followed and there was always teaching assistant or Professorduring lab hours. The most dangerous equipments - soldering iron and voltage supply werecarefully used.

    Appendix A (Programs Listing):

    Test prototype board

    Test stepper motor

    Transmitter end MCU

    Receiver end MCU

  • 8/8/2019 ECE476 Final Project

    9/13

    Appendix B (schematics):

    H-bridge

    Transmitter & Transmitter end MCU

  • 8/8/2019 ECE476 Final Project

    10/13

    Receiver & Receiver end MCU

  • 8/8/2019 ECE476 Final Project

    11/13

    Appendix C (Cost & Parts):

    Radiotronix

    433MHz Receiver: RCR-433-RP $3.53 (quantity:1)

    433MHz Transmitter: RCT-433-AS $2.24 (quantity: 1)

    Acroname, Inc.

  • 8/8/2019 ECE476 Final Project

    12/13

    Sharp GP2D120 infrared ranger: R146-GP2D120 $13.5 (quantity: 1)

    All Electronics Corp.

    100K linear slide potentiometer: CAT# LSP-100K $1 (quantity: 3)

    Digi-Key Corporation

    Darlington transistor arrays: 296-1979-5-ND $1 (quantity:2)

    From Digital Lab or used part

    y RC NSXy IN4001 diodesy 74LS00Ny 74LS04Ny

    TIP31Cy TIP32Cy 150, 220, 10K, 100K resistorsy 0.1, 27pF capacitorsy 16MHz crystalsy LEDsy voltage regulator -7805y switches

    Total cost: $21.27

    Appendix D (Tasks Specified):

    Preliminary design & review: Lam and Wong

    H-bridges: Lam

    Prototype boards: Wong

    Infrared sensor: Lam and Wong

    Receiver & transmitter circuitry: Wong

    Receiver & transmitter programs: Lam

    Overall circuitries & Soldering: Lam and Wong

    Overall car polishing: Lam and Wong

  • 8/8/2019 ECE476 Final Project

    13/13

    System testing: Lam and Wong

    Documentation: Lam and Wong

    Appendix E (References):

    Cornell ECE 476 past projects: http://instruct1.cit.cornell.edu/courses/ee476/FinalProjects/

    DC motor for speed: www.mabuchi-motor.co.jp/english/cat_files/rc_260rasa.html

    Receiver: www.radiotronix.com/datasheets/rcr433rp.pdf

    Transmitter: www.radiotronix.com/datasheets/rct433as.pdf

    Sharp IR sensor: www.acroname.com//robotics/parts/R146-GP2D120.html

    Transistor arrays:http://rocky.digikey.com/WebLib/Texas%20Instruments/Web%20data/ULN2001A-4A,ULQ2003A-4A.pdf