Robotics and Embedded System

1,806 views
1,635 views

Published on

Robotics and Embedded System

Published in: Education, Technology, Business
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,806
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
46
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Robotics and Embedded System

  1. 1. 1. History of Robotics 77-100BC In 1901, between the islands of Crete and Kythera, a diver found the remnants of what might only be considered a mechanical computer. The device is a complex mix of gears which most likely calculated the position of the sun, moon or other celestial bodies. The device dates back 2000 years and is considered to be of Greek origin and was given the name “The Antikythera Device”. 1495 Leonardo da Vinci designed what may be the first humanoid robot though it cannot be confirmed if the design was actually ever produced. The robot was designed to sit up, wave its arms, and move its head via a flexible neck while opening and closing its jaw. 1921 The term “robot” was first used in a play called “R.U.R” or “Rossum's Universal Robots” by the Czech writer Karel Capek. The plot was simple: man creates a robot to replace him and then robot kills man. 1942 Isaac Asimov wrote the “Three Laws of Robotics”. A zeroth law was later added (law zero below). Law One: A robot may not injure a human (or humanity), or, through inaction, allow a human (or humanity) to come to harm. Law Two: A robot must obey orders given it by human beings, except where such orders would conflict with a higher order law. Law Three: A robot must protect its own existence as long as such protection does not conflict with a higher order law. Law Zero: A robot may not injure a human being, or, through inaction, allow a human being to come to harm, unless this would violate a higher order law. 1
  2. 2. 1951 Raymond Goertz designed the first tele-operated articulated arm for the Atomic Energy Commission. This is generally regarded as a major milestone in force feedback (haptic) technology. 1954 George Devol designed the first truly programmable robot and called it UNIMATE for "Universal Automation." 1957 History changed on October 4, 1957, when the Soviet Union successfully launched Sputnik I. The world's first autonomous, artificial satellite was 22.8 inches in diameter and weighed only 183.9 pounds. 1968 The first computer controlled walking machine was created by Mcgee and Frank at the University of South Carolina. 1975 Victor Schenman developed the Programmable Universal Manipulation Arm (Puma). It was widely used in industrial operations. 1979 The Stanford Cart crossed a chair-filled room without human assistance. The cart had a TV camera mounted on a rail which took pictures from multiple angles and relayed them to a computer. The computer analyzed the distance between the cart and the obstacles. 1996 Honda created the P2, which was the first major step in creating their ASIMO. The P2 was the first self-regulating, bipedal humanoid robot. 2
  3. 3. 1997 NASA's PathFinder landed on Mars. The wheeled robotic rover sent images and data about Mars back to Earth. 2002 Honda created the Advanced Step in Innovative Mobility (ASIMO). It is intended to be a personal assistant. It recognizes its owner's face, voice, and name. Can read email and is capable of streaming video from its camera to a PC. iRobot released the first generation of Roomba robotic vacuum cleaners. 2003 As part of their mission to explore Mars, NASA launched twin robotic rovers on June 10 and July 7, 2003 called Spirit and Sojourner. 2005 The Korean Institute of Science and Technology (KIST), created HUBO, and claims it is the smartest mobile robot in the world. This robot is linked to a computer via a highspeed wireless connection; the computer does all of the thinking for the robot. 3
  4. 4. 2. Robotics 2.1 Definition of Robotics: The branch of technology that deals with the design, construction, operation, and application of robots. 2.2 Types of Robots a. Manual Remote or Tele-operated: A manually tele-operated robot is totally under control of a driver with a joystick or other control device. These are of two types: i. Wired Robot ii. Wireless Robot b. Guarded Tele-operated: A guarded tele-op robot has the ability to sense and avoid obstacles but will otherwise navigate as driven, like a robot under manual teleoperated. c. Line-following robot: They might follow a visual line painted or embedded in the floor or ceiling or an electrical wire in the floor. d. Autonomously randomized robot: Autonomous robots with random motion basically bounce off walls, whether those walls are sensed e. Autonomously guided robot: Robot developers use ready-made autonomous bases and software to design robot applications quickly. An autonomously guided robot knows at least some information about where it is and how to reach various goals and or waypoints along the way. 2.3 Description of Wired Robot: Basic Requirements for Wired Robot Car • For BOT • • • Motors. Wheel Set Grip • For remote • DPDT switches. 4
  5. 5. • Circuit Board. • AC to DC converter Basic Diagram for Wired Robot Figure No. 1: Block Diagram of a Wired Robot Car General Constraints: Size Constraint (Generally 30x30x30 cm) Voltage Constraint (Generally 24V DC) Power Constraint Power Source: As the name says, power source provide the power to the robot. Power can be provided by: Rectifier o Transformer (Step Down) o Diode and Capacitor to Convert AC to DC Battery (for onboard operations of car) Adapter 5
  6. 6. Rectifier: Rectifier is the circuit which converts AC power to DC power. The block diagram of the rectifier circuit is shown in the fig. 2. It consists of a step down transformer (to convert 220V AC supply to 12 or 24V AC supply according to the requiirement), four diodes and a capacitor. Figure No 2: Block Diagram of Bridge Rectifier Working: The transformer used here is the center tapped step down transformer. So it can step down 220V AC to 12 or 24V AC. Lets say we are using 24V DC, so we‟ll take the supply from the +12 volt and -12 volt wires of the transformer, which ultimately makes a potential difference of 24V on the terminals. This 24V is then given to the bridge of four diodes. This bridge converts the AC supply to the pulsating DC. A capacitor of apropriate value is connected in paraller of this pulsating DC. Due to this, we‟ll get pure DC at the output. Advantages: 1. Easily available circuit.Cheaper. 6
  7. 7. Disadvantages: 1. Current weakens due to heating effect; 2. The circuit becomes bulky due to the use of transformer. Battery: The rectifier arrangement can be replaced by the Battery of required specification. The use of reduces the bulkiness of the circuit and thus removes the disadvantage that was in case of rectifier circuit. It also makes the system more flexible as it doesn‟t need any power plug (220V) for its operation. But the main disadvantage of using battery is that the battery losses its power with the time passage. So this kind of arrangement is avoided in case of long term operation. Adapter: In case, one needs to save time then but also need continues use of the robot. He/she can use an adapter of appropriate specification from the market. Remote: There are four basic requirements of a car. These are forward motion of the car, reverse motion of the car, turning left and turning right. As shown in the figure1, we‟ll use four motors for serving these functions, one on each tyre of the car. Now, forward and reverse motions can be achieved by turning all the motors in clockwise and anticlockwise direction respectively. The turning can be achieved by running one side of the wheels while the other side of the wheels are at rest. For example, if we want to turn the remote car in the left direction, then we need to stop the left motors and run the right side motors. For serving all these purposes, remote is necessary to control the robo car. The remote consists of two DPDT switches and the connections are made as shown below in the figure 3. 7
  8. 8. Figure No 3: Remote Connections Motor Connections: Four output wires from remote which is to solder on motor by ribbon wire strip are taken. Switch 1‟s output is connected to motor 1. Switch 2‟s output is connected to motor 2. Polarity of the motors should be checked by giving supply from the battery. Table 1 shows the required motor configurations for different operations Table No 1: Motor Configurations Movements Motor 1- Left Motor 2- Right Forward Clockwise Clockwise Backward Anticlockwise Anticlockwise Left Off Clockwise Right Clockwise Off 2.4 Description of Wireless Robot: There is limitation in wired robots that is its wire is suitable for short lengths only on land but can‟t used in air. This limitation is removed with the help of wireless robots. In this type of robots, the connection between remote 8
  9. 9. and bot is done wirelessly. For this purpose, we use a transmitter on remote side and a receiver on bot side. The generally used transmitter IC in wireless robots is HT12E and receiver IC used is HT12D. Other process for making the wireless bot and remote are same as to the wired robot. Wireless robots can be classified in three types based on different types of transmitter and receiver. These are as below: Radio Frequency (RF) Based GSM Based Bluetooth Based Here are some specifications of transmitter IC HT12E and receiver IC HT12D. Transmitter IC HT12E • HT12E has a transmission enable pin which is active low. • When a trigger signal is received on TE pin, the programmed addresses/data are transmitted together with the header bits via an RF or an infrared transmission medium. • HT12E begins a 4-word transmission cycle upon receipt of a transmission enable. Receiver IC HT12D • HT12D converts the serial input into parallel outputs. • It decodes the serial addresses and data received by, say, an RF receiver, into parallel data and sends them to output data pins. • The serial input data is compared with the local addresses three times continuously. 9
  10. 10. 3. EMBEDDED SYSTEM 3.1 Introduction:An embedded system is a computer system designed to perform one or a few dedicated functions often with real-time computing constraints. It is embedded as part of a complete device often including hardware and mechanical parts. By contrast, a generalpurpose computer, such as a personal computer (PC), is designed to be flexible and to meet a wide range of end-user needs. Embedded systems control many devices in common use today. Embedded systems are controlled by one or more main processing cores that is typically either a microcontroller or a digital signal processor (DSP). The key characteristic is however being dedicated to handle a particular task, which may require very powerful processors. Since the embedded system is dedicated to specific tasks, design engineers can optimize it reducing the size and cost of the product and increasing the reliability and performance. 3.2 Characteristics:1. Embedded systems are designed to do some specific task, rather than be a general-purpose computer for multiple tasks. Some also have real-time performance constraints that must be met, for reasons such as safety and usability; others may have low or no performance requirements, allowing the system hardware to be simplified to reduce costs. 2. Embedded systems are not always standalone devices. Many embedded systems consist of small, computerized parts within a larger device that serves a more general purpose. 3. The program instructions written for embedded systems are referred to as firmware, and are stored in read-only memory or Flash memory chips. They run with limited computer hardware resources: little memory, small or non-existent keyboard and/or screen. 10
  11. 11. 3.3 PERIPHERALS:Embedded Systems talk with the outside world via peripherals such as: Serial Communication Interfaces (SCI): RS-232, RS-422, RS-485 etc. Universal Serial Bus (USB). Multi Media Cards (SD Cards, Compact Flash etc). Networks: Ethernet, Controller Area Network, LAN Works, etc. Timers: PLL(s), Capture/Compare and Time Processing Units. Discrete IO: like as General Purpose Input/Output (GPIO). Analog to Digital/Digital to Analog (ADC/DAC). Debugging: JTAG, ISP, ICSP, BDM Port, BITP DP9 port. Figure No 4: Embedded System Embedded systems are controlled by one or more main processing cores that is typically either a microcontroller or a digital signal processor (DSP). The key characteristic is however being dedicated to handle a particular task, which may require very powerful processors. Since the embedded system is dedicated to specific tasks, design engineers can optimize it reducing the size and cost of the product and increasing the reliability and performance. 11
  12. 12. 4. Microcontroller AT89S52 Kit 4.1 Microcontroller Features: The AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller with 8K bytes of in-system programmable Flash memory. The device is manufactured using Atmel‟s high-density non-volatile memory technology and is compatible with the industry-standard 80C51 instruction set and pin-out. The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional non-volatile memory programmer. By combining a versatile 8-bit CPU with in-system programmable Flash on a monolithic chip, the Atmel AT89S52 is a powerful microcontroller which provides a highly-flexible and cost-effective solution to many embedded control applications. The AT89S52 provides the following standard features: 8K bytes of Flash; 256 bytes of RAM; 32 I/O lines; Watchdog Timer; Two data Pointers; Three 16-bit timer/counters; A six-vector two-level interrupt architecture; A full duplex serial port; On-chip oscillator; and Clock circuitry. In addition, the AT89S52 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port, and interrupt system to continue functioning. The Power-down mode saves the RAM con-tents but freezes the oscillator, disabling all other chip functions until the next interrupt or hardware reset. 12
  13. 13. Pin Description: The AT89S52 is a 40 Pin microcontroller. Pin description is shown in figure 5 below. Port 0 Port 0 is an 8-bit open drain bi-directional I/O port. As an output port, each pin can sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as high impedance inputs. Port 0 can also be configured to be the multiplexed low order address/data bus during accesses to external program and data memory. In this mode, P0 has internal pull ups. Port 0 also receives the code bytes during Flash programming and outputs the code bytes during program verification. External pull-ups are required during program verification. Port 1 Port 0 Port 3 Port 2 Figure No 5: Pin Description of Microcontroller Port 1 Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 1 output buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins, they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 1 pins 13
  14. 14. that are externally being pulled low will source current (IIL) because of the internal pullups. In addition, P1.0 and P1.1 can be configured to be the timer/counter 2 external count input (P1.0/T2) and the timer/counter 2 trigger input (P1.1/T2EX), respectively, as shown in the following table. Port 1 also receives the low-order address bytes during Flash programming and verification. Port 2 Port 2 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 2 output buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins, they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 2 pins that are externally being pulled low will source current (IIL) because of the internal pullups. Port 2 emits the high-order address byte during fetches from external program memory and during accesses to external data memory that uses 16-bit addresses (MOVX @DPTR). In this application, Port 2 uses strong internal pull-ups when emitting 1s. During accesses to external data memory that use 8-bit addresses (MOVX @ RI), Port 2 emits the contents of the P2 Special Function Register. Port 2 also receives the high-order address bits and some control signals during Flash programming and verification. Port 3 Port 3 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 3 output buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins, they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled low will source current (IIL) because of the pull-ups. Port 3 also serves the functions of various special features of the AT89C51, as shown in the following table. Port 3 also receives some control signals for Flash programming and verification. Pin Details RST Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device. 14
  15. 15. ALE/PROG Address Latch Enable is an output pulse for latching the low byte of the address during accesses to external memory. This pin is also the program pulse input (PROG) during Flash programming. In normal operation, ALE is emitted at a constant rate of 1/6 the oscillator frequency and may be used for external timing or clocking purposes. Note, however, that one ALE pulse is skipped during each access to external data memory. If desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With the bit set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit has no effect if the microcontroller is in external execution mode. PSEN Program Store Enable is the read strobe to external program memory. When the AT89C52 is executing code from external program memory, PSEN is activated twice each machine cycle, except that two PSEN activations are skipped during each access to external data memory. EA/VPP (External Access Enable) EA must be strapped to GND in order to enable the device to fetch code from external program memory locations starting at 0000H up to FFFFH. Note, however, that if lock bit 1 is programmed, EA will be internally latched on reset. EA should be strapped to VCC for internal program executions. This pin also receives the 12-volt programming enable voltage (VPP) during Flash programming when 12-volt programming is selected. 15
  16. 16. XTAL1 Input to the inverting oscillator amplifier and input to the internal clock operating circuit. XTAL2 Output from the inverting oscillator amplifier. VCC Supply voltage. GND Ground 4.2 Difference between Microcontroller & Microprocessors The term microprocessor and microcontroller have always been confused with each other. Both of them have been designed for real time application. They share many common features and at the same time they have significant differences. Both the IC‟s i.e., the microprocessor and microcontroller cannot be distinguished by looking at them. They are available in different version starting from 6 pin to as high as 80 to 100 pins or even higher depending on the features. These have following differences: Sr. 1. Microcontroller These have a CPU in addition with a Microprocessor These have only CPU inside them. fixed amount of RAM, ROM and other peripherals embedded on a single chip. 2. These uses inbuilt memory. Designer has to add RAM and ROM externally to make them functional. 3. These are designed for specific tasks These are designed for non-specific tasks such as automatic washing machine, such as desktop, laptop, smart-phones etc. microwave, keyboard, cars etc. 4. These need only small amount of They need comparatively larger amount of RAM, ROM, I/O ports because of resources. specific applications. 5. Clock speed is quite low (30-50MHz). Clock speed is quite high (1GHz or more). 16
  17. 17. 4.3 Components Used in Kit:The AT89S52 based Kit is shown in the figure 6 below. Figure No 6: AT89S52 Kit Some of the c components used in the kit are discussed below: Voltage Regulator: A voltage regulator is a device that maintains a relatively constant output voltage even though its input voltage may be highly variable. The 78xx is voltage regulator IC series. The xx in 78xx indicates the fixed output. Figure No 7: Voltage Regulator IC 17
  18. 18. Table No 2: Pin Configuration of Voltage Regulator IC Pin No Name 1. Input voltage (5V-18V) Input 2. Ground (0V) Ground 3. • Function Regulated output; 5V (4.8V-5.2V) Output Opto-couplers: An opto-isolator or opto-coupler is a device that uses a short optical transmission path to transfer a signal between elements of a circuit, while keeping them electrically isolated. An optocoupler is a combination of a light source and a photosensitive detector. The signal goes from an electrical signal to an optical signal back to an electrical signal; electrical contact along the path is broken. Figure No 8: Opto-Coupler Circuit Diagram A common implementation involves a LED and a phototransistor, separated so that light may travel across a barrier but electrical current may not. When an electrical signal is applied to the input of the opto-isolator, its LED lights, its light sensor then activates, and a corresponding electrical signal is generated at the output. With a photodiode as the detector, the output current is proportional to the amount of incident light supplied by the emitter. 18
  19. 19. 4N35 is an optocoupler integrated circuit in which an infrared emitter diode drives a phototransistor. They are also known as optoisolators since they separate two circuits optically. These are used to couple two circuits without any ohmic Figure No. 9: Opto-Coupler IC contact. They allow one of the circuits to switch another one while they are completely separate. The first circuit is connected to IR diode while the other circuit with the phototransistor. Seven Segment Display: A seven segment is generally available in ten pin package. While eight pins correspond to the eight LEDs, the remaining two pins (at middle) are common and internally shorted. These segments come in two configurations, namely, Common cathode (CC) and Common anode (CA). In CC configuration, the negative terminals of all LEDs are connected to the common pins. The common is connected to ground and a particular LED glows when its corresponding pin is given high. In CA arrangement, the common pin is given a high logic and the LED pins are given low to display a number. 19
  20. 20. Figure No 10: Seven Segment Display Liquid Crystal Display (LCD): LCD (Liquid Crystal Display) screen is an electronic display module and find a wide range of applications. A 16x2 LCD display is very basic module and is very commonly used in various devices and circuits. LCDs are economical. Easily programmable. A 16x2 LCD means it can display 16 characters per line and there are 2 such lines.This LCD has two registers, namely, Command and Data. The command register stores the command instructions given to the LCD. The data register stores the data to be displayed on the LCD. Figure No 11: Pin Configuration of LCD 20
  21. 21. Pin Configuration: The following table shows pin configuration of LCD Display Table No 3: Pin Configuration of LCD Display Pin No Function Name 1 Ground (0V) GND 2 Supply Voltage 5V(4.7V-5.3V) VCC 3 Contrast Adjustmrent; through a variable resistor VEE 4 Select command resistor when lowand data resistor when high RS 5 Low to write to the register; High to read from the register R/W 6 Sends data to data pins when a high to low pulse is given EN 7 DB0 8 DB1 9 DB2 10 DB3 11 8-bit data pins DB4 12 DB5 13 DB6 14 DB7 15 Backlight VCC (5V) Led+ 16 Backlight Ground (0V) Led- 21
  22. 22. 5. SOFTWARE USED The Keil 8051 Development Tools are designed to solve the complex problems facing embedded software developers. When starting a new project, simply select the microcontroller you use from the Device Database and the µVision IDE sets all compiler, assembler, linker, and memory options for you. Numerous example programs are included to help you get started with the most popular embedded 8051 devices. The Keil µVision Debugger accurately simulates on-chip peripherals (I²C, CAN, UART, SPI, Interrupts, I/O Ports, A/D Converter, D/A Converter, and PWM Modules) of your 8051 device. Simulation helps you understand hardware configurations and avoids time wasted on setup problems. Additionally, with simulation, you can write and test applications before target hardware is available. 5.1 Various Steps to Use the KEIL Complier: Open keil from the start menu. Select a new project from the project menu. Make a new folder in any drive. Name the project as abc and then click save. Right click on target, then options for the target, then choose the device, set the crystal frequency, click on the create hex file option to create hex file at the output. Then create a new file from the file menu and save it with the same name of project using extension .c or .asm. 22
  23. 23. Right clicks on the source group, then click on add files option to add the files and then click on close. 5.2 Programs Used in Kit: a. Program for name on LCD Display #include<at89x52.h> #define lcd_port P3 sbit lcd_rs=P2^5; sbit lcd_rw=P2^6; sbit lcd_en=P2^7; char name[15]="MECHANICAL"; char names[15]="JCDMCOE"; int i,k; #define HIGH 1 #define LOW 0 void controller_initialization(); void delay(unsigned int); void send_command_to_lcd(unsigned char); void send_data_to_lcd(unsigned char); void lcd_initialization(); void main() { controller_initialization(); 23
  24. 24. lcd_initialization(); } void controller_initialization() { P0=0xff; P1=0xff; P2=0xff; P3=0xff; } void delay(unsigned int x) { while(x--); } void send_command_to_lcd(unsigned char command) { lcd_rw=LOW; lcd_rs=LOW; lcd_port=command; delay(150); lcd_en=1; delay(5); 24
  25. 25. lcd_en=0; } void send_data_to_lcd(unsigned char character) { lcd_rw=LOW; lcd_rs=HIGH; lcd_port=character; delay(150); lcd_en=1; delay(5); lcd_en=0; } void lcd_initialization() { send_command_to_lcd(0x38); send_command_to_lcd(0x0c); send_command_to_lcd(0x06); for(k=0;k<16;k++) { send_command_to_lcd(0x01); send_command_to_lcd(0x80+k); 25
  26. 26. for(i=0;i<16;i++) { if (name[i]!=0) send_data_to_lcd(name[i]); if (name[i]==0) send_command_to_lcd(0xc0+k); } delay(600); send_command_to_lcd(0xc0+k); for(i=0;i<16;i++) { if (names[i]!=0) send_data_to_lcd(names[i]); } delay(6000); delay(6000); } } 26
  27. 27. b. Program for glow of LED #include<at89x52.h> #define led P1 void controller_initialization (); void main() { controller_initialization(); while(1) { led = 0xaa; } } void controller_initialization() { P0 = 0xff; P1 = 0xff; P2 = 0xff; P3 = 0xff; } 27
  28. 28. c. Program for glow of LED in sequence #include<at89x52.h> #define led P1 void controller_initialization(); void main() { controller_initialization(); while(1) { led = 0x3c; } } void controller_initialization() { P0 = 0xff; P1 = 0xff; P2 = 0xff; P3 = 0xff; } 28
  29. 29. d. Program for SSD #include<at89x52.h> sbit unit = P2^0; sbit tens = P2^1 ; sbit hundred = P2^2; sbit thousand = P2^3; #define ssd P1 #define low 0 #define high 1 void controller_initialization(); void main() { controller_initialization(); while(1) { unit = low; tens = low; hundred = low; thousand = low; ssd = 0x01; unit=high; 29
  30. 30. unit=low; ssd= 0x02; tens =high; tens = low; ssd = 0x03; hundred = high; hundred = low; ssd= 0x04; thousand = high; thousand = low; } } 30
  31. 31. e. Program for Mobile Keypad #include<at89x52.h> #define lcd_port P3 sbit lcd_rs=P2^5; sbit lcd_rw=P2^6; sbit lcd_en=P2^7; sbit row_1=P1^3; sbit row_2=P1^2; sbit row_3=P1^1; sbit row_4=P1^0; sbit col_1=P1^7; sbit col_2=P1^6; sbit col_3=P1^5; sbit col_4=P1^4; unsigned int number=0; bit flag=0; int key_number='x'; int kk=0; #define HIGH 1 #define LOW 0 #define ON 1 31
  32. 32. #define OFF 0 void controller_initialization(); void delay(unsigned int); void matrix_key_check(); void matrix_key_action(); void send_command_to_lcd(unsigned char); void send_data_to_lcd(unsigned char); void lcd_initialization(); void main() { controller_initialization(); lcd_initialization(); while(1) { matrix_key_check(); matrix_key_action(); } } void controller_initialization() { P0=0xff; 32
  33. 33. P1=0xff; P2=0xff; P3=0xff; } void delay(unsigned int x) { while(x--); } void send_command_to_lcd(unsigned char command) { lcd_rw=LOW; lcd_rs=LOW; lcd_port=command; delay(150); lcd_en=1; delay(5); lcd_en=0; } void send_data_to_lcd(unsigned char character) { lcd_rs=LOW; 33
  34. 34. lcd_rs=HIGH; lcd_port=character; delay(150); lcd_en=1; delay(5); lcd_en=0; } void lcd_initialization() { send_command_to_lcd(0x38); send_command_to_lcd(0x0c); send_command_to_lcd(0x06); send_command_to_lcd(0x01); } void matrix_key_check() { key_number='x'; col_1=1; col_2=1; col_3=1; col_4=1; 34
  35. 35. col_1=0; if(row_1==0) { key_number=1; } else if(row_2==0) { key_number=4; } else if(row_3==0) { key_number=7; } else if(row_4==0) { key_number=10; } col_1=1; col_2=0; if(row_1==0) { 35
  36. 36. key_number=2; } if(row_2==0) { key_number=5; } if(row_3==0) { key_number=8; } if(row_4==0) { key_number=0; } col_2=1; col_3=0; if(row_1==0) { key_number=3; } if(row_2==0) 36
  37. 37. { key_number=6; } if(row_3==0) { key_number=9; } if(row_4==0) { key_number=12; } col_3=1; if(key_number=='x') { flag=1; } delay(100); } void matrix_key_action() { if(key_number!='x') 37
  38. 38. if(((key_number==1)||(key_number==2)||(key_number==3)||(key_number==4)||(key_nu mber==5)||(key_number==6)||(key_number==7)||(key_number==8)||(key_number==9)||(k ey_number==0))&&(flag==1)) { flag=0; kk=key_number+48; send_data_to_lcd(kk); } if((key_number==10)&&(flag==1)) { flag=0; send_data_to_lcd('*'); } if((key_number==12)&&(flag==1)) { flag=0; send_data_to_lcd('#'); } } 38
  39. 39. 5.3 How to Debug the Program: After writing the code, click on file menu and select save. Click on project menu and rebuild all target files. In build window, it should report as „0 Error(s), 0 Warning(s)‟. Click on debug menu and select start/stop debug session. Click on peripherals, select I/O ports like as port 1. A new window will pop up, which represents the port and pins. Now to execute the program stepwise click on F10 key. Figure No 12: Debugging the Program To exit out click on debug menu and select start/stop debug session. 39
  40. 40. Bibliography 1. Data provided by our coordinators. 2. Wikipedia.com 3. HCL Report on Embedded System 4. Figures from the Futronics Report on Robotics. 40

×