1.1 Problem: Chapter-1 Project Background
1.1 Problem: Chapter-1 Project Background
1.1 PROBLEM
Generally remote operated robots are made which have a low range of signals for operating them and in hospitals patients forget to take medications and a problem occurs to their health. If any obstacles are there in between the path of the robot then a problem occurred in motion of the robot. So we want to make such a robot that can be used for helping the patients by recalling them to take medicines and can carry their medicines. It should detect obstacles in path and can be operated by a remote location.
A real-time clock counts seconds, minutes, hours, date of the month, month, day of the week, and year with leap year compensation valid up to 2100. I can set the time and I can program the robot in such a way that the robot can perform the work based on the real-time clock. The voice recorder APR9600 is used to record voice and it can be played back whenever voice assistance is needed. The robot is controlled from a remote location using a dual tone multi-frequency decoding technique. If any obstacle comes in the pathway of the robot it is detected using the ldr sensor and appropriate decision is made. The robots motion is controlled by two stepper motors incorporated at the base. The driver circuits for these motors are controlled with an AT89C52. All the aforementioned applications are implemented in the robot using the microcontroller AT89C51. The robots motion is controlled by two stepper motors incorporated at the base. The driver circuits for these motors are controlled with an AT89C51. In the first two applications, the distance and direction of the destination is accepted as input through the user friendly keyboard, and multiplexed 7-segment display system. The arm structure is controlled by a relay circuit.
4
In the third application, the distance and direction are pre-programmed in the microcontroller AT89C51. We record all the information about the organization in the voice recorder APR9600 and are played back whenever voice assistance is needed. In the fourth application, a real-time clock count seconds, minutes, hours, date of the month, month, day of the week, and year with leap year compensation valid up to 2100. We can set the time and we can program the robot in such a way that the robot can perform the work based on the real-time clock. In the fifth application, the robot is controlled from a remote location using a dual tone multifrequency decoding technique. If any obstacle comes in the pathway of the robot it is detected using the photoelectric sensors and appropriate decision is made. Because it is a general purpose robot with facilities like: Pick and Place arm, DTMF decoding techniques, Real time clock, Obstacles sensor.
in random access mode. The duration of each voice is 7.5 seconds. We use these two voice recorder IC's in visitor guiding mode and patient guiding mode to play the voices stored. In the upper nibble pin P2.4 is connected to a photoelectric sensor through an opto-coupler IC MCT2E which senses the obstacles in front of the robot. When the sensor senses the object it gives logic one to the controller. The pin P2.5 is connected to a buzzer. The pins P2.6 and P2.7 are connected to the base of transistor BC547. The collector of transistor BC547 is connected to the DC motor of the arm via relay which is used as a switching element for arm. When the microcontroller outs a 0V in the port pin P2.6 and +5V in the port pin P2.7 the arm comes out. When the microcontroller outs a +5V in the port pin P2.6 and 0V in the port pin P2.7 the arm moves inside. In PORT3 the pins P3.3-P3.6 are connected to push to on switches which are used for giving input such as directions, distance and time to the robot. The port pins P3.2 and P3.7 are connected to the SDA and SCL pins of the real time clock IC DS1307 respectively. The microcontroller communicates with DS1307 through I2C logic. We read the time from the real time clock and we can set the time in the patient guiding mode.
4.1.2 DESCRIPTION
The AT89C51 is a low-power, high-performance CMOS 8-bit microcomputer with 4K bytes of Flash programmable and erasable read only memory (PEROM). The device is manufactured using Atmels high-density non-volatile memory technology and is compatible with the industrystandard MCS-51 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 Flash on a monolithic chip, the Atmel AT89C51 is a powerful microcomputer which provides a highly-flexible and cost-effective solution to many embedded control applications.
In addition, the AT89C51 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 contents but freezes the oscillator disabling all other chip functions until the next hardware reset.
10
(iv) 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 that are externally being pulled low will source current (IIL) because of the internal pull ups. Port 1 also receives the low-order address bytes during Flash programming and verification.
(v) 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 pull ups. Port 2 emits the high-order address byte during fetches from external program memory and during accesses to external data memory that use 16-bit addresses (MOVX @ DPTR). In this application, it 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 highorder address bits and some control signals during Flash programming and verification.
11
(vi) 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 listed
PORT PIN P3.0 P3.1 P3.2 P3.3 P3.4 P3.5 P3.6 P3.7
ALTERNATE FUNCTIONS RXD (serial input port) TXD (serial output port) INT0 (external interrupt 0) INT1 (external interrupt 1) T0 (timer 0 external input) T1 (timer 1 external input) WR (external data memory write strobe) RD (external data memory read strobe)
Port 3 also receives some control signals for Flash programming and verification.
(vii) RST Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device.
(viii) ALE/PROG Address Latch Enable 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
12
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.
(ix) PSEN Program Store Enable is the read strobe to external program memory. When the AT89C51 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.
(x) 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. 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, for parts that require 12-volt VPP. (xi) XTAL1 Input to the inverting oscillator amplifier and input to the internal clock operating circuit. (xii) XTAL2 Output from the inverting oscillator amplifier.
13
14
4.2.3 DESCRIPTION
The Device is a monolithic integrated high voltage, high current four channel driver designed to accept standard DTL or TTL logic levels and drive inductive loads (such as relays 15olenoids, DC and stepping motors) and switching power transistors. To simplify use as two bridges each pair of channels is equipped with an enable input. A separate supply input is provided for the logic, allowing operation at a lower voltage and internal clamp diodes are included. This device is suitable for use in switching applications at frequencies up to 5 kHz. The L293D is assembled in a 16 lead plastic package which has 4 center pins connected together and used for heat sinking.
15
4.3.2 FEATURES
1. Real-Time Clock (RTC) Counts Seconds, Minutes, Hours, Date of the Month, Month, Day of the week, and Year with Leap-Year Compensation Valid Up to 2100 . 2. 56-Byte, Battery-Backed, General-Purpose RAM with Unlimited Writes . 3. I2C Serial Interface . 4. Programmable Square-Wave Output Signal .
16
5. Automatic Power-Fail Detect and Switch Circuitry. 6. Consumes Less than 500nA in Battery-Backup Mode with Oscillator Running . 7. Optional Industrial Temperature Range: -40C to +85C . 8. Available in 8-Pin Plastic DIP or SO
17
18
3. GND Ground 4. SDA Serial Data Input / Output. SDA is the data input/output for the I2C serial interface. The SDA pin is open drain and requires an external pull up resistor. The pull up voltage can be up to 5.5V regardless of the voltage on VCC. 5. SCL Serial Clock Input. SCL is the clock input for the I2C interface and is used to synchronize data movement on the serial interface. The pullup voltage can be up to 5.5V regardless of the voltage on VCC. 6. SQW/OUT Square Wave/Output Driver. When enabled, the SQWE bit set to 1, the SQW/OUT pin outputs one of four square-wave frequencies (1Hz, 4kHz, 8kHz, 32kHz). The SQW/OUT pin is open drain and requires an external pullup resistor. SQW/OUT operates with either VCC or VBAT applied. The pullup voltage can be up to 5.5V regardless of the voltage on VCC. If not used, this pin can be left floating. 7. VCC Primary Power Supply. When voltage is applied within normal limits, the device is fully accessible and data can be written and read. When a backup supply is connected to the device and VCC is below VTP, read and writes are inhibited. However, the timekeeping function continues unaffected by the lower input voltage.
tolerance system. When VCC falls below VBAT, the device switches into a low-current batterybackup mode. Upon power-up, the device switches from battery to VCC when VCC is greater than VBAT +0.2V and recognizes inputs when VCC is greater than 1.25 x VBAT. The block diagram in Figure 1 shows the main elements of the serial RTC.
this bit is set to 1, the oscillator is disabled. When cleared to 0, the oscillator is enabled. On first application of power to the device the time and date registers are typically reset to 01/01/00 01 00:00:00 (MM/DD/YY DOW HH:MM:SS). The CH bit in the seconds register will be set to a 1. The clock can be halted whenever the timekeeping functions are not required, which minimizes current (IBATDR). The DS1307 can be run in either 12-hour or 24-hour mode. Bit 6 of the hours register is defined as the 12-hour or 24-hour mode-select bit. When high, the 12-hour mode is selected. In the 12hour mode, bit 5 is the AM/PM bit with logic high being PM. In the 24-hour mode, bit 5 is the second 10-hour bit (20 to 23 hours). The hours value must be re-entered whenever the 12/24hour mode bit is changed. When reading or writing the time and date registers, secondary (user) buffers are used to prevent errors when the internal registers update. When reading the time and date registers, the user buffers are synchronized to the internal registers on any I2C START. The time information is read from these secondary registers while the clock continues to run. This eliminates the need to re-read the registers in case the internal registers update during a read. The divider chain is reset whenever the seconds register is written. Write transfers occur on the I2C acknowledge from the DS1307. Once the divider chain is reset, to avoid rollover issues, the remaining time and date registers must be written within one second.
21
The DS1307 can operate in the following two modes: (1.) SLAVE RECEIVER MODE (WRITE MODE) Serial data and clock are received through SDA and SCL. After each byte is received an acknowledge bit is transmitted. START and STOP conditions are recognized as the beginning and end of a serial transfer. Hardware performs address recognition after reception of the slave address and direction bit (see Figure 4). The slave address byte is the first byte received after the master generates the START condition. The slave address byte contains the 7-bit DS1307 address, which is 1101000, followed by the direction bit (R/W), which for a write is 0. After receiving and decoding the slave address byte, the DS1307 outputs an acknowledge on SDA. After the DS1307 acknowledges the slave address + write bit, the master transmits a word address to the DS1307. This sets the register pointer on the DS1307, with the DS1307 acknowledging the transfer. The master can then transmit zero or more bytes of data with the DS1307 acknowledging each byte received. The register pointer automatically increments after each data byte are written. The master will generate a STOP condition to terminate the data write. (2.)SLAVE TRANSMITTER MODE (READ MODE) The first byte is received and handled as in the slave receiver mode. However, in this mode, the direction bit will indicate that the transfer direction is reversed. The DS1307 transmits serial data on SDA while the serial clock is input on SCL. START and STOP conditions are recognized as the beginning and end of a serial transfer (see Figure 5). The slave address byte is the first byte received after the START condition is generated by the master. The slave address byte contains the 7-bit DS1307 address, which is 1101000, followed by the direction bit (R/W), which is 1 for a read. After receiving and decoding the slave address the DS1307 outputs an acknowledge on SDA. The DS1307 then begins to transmit data starting with the register address pointed to by the register pointer. If the register pointer is not written to before the initiation of a read mode the first address that is read is the last one stored in the register pointer. The register pointer automatically increments after each byte are read. The DS1307 must receive a Not Acknowledge to end a read.
22
4.4 DC MOTOR
A DC motor is an electric motor that runs on direct current (DC) electricity. DC motors were used to run machinery, often eliminating the need for a local steam engine or internal combustion engine. DC motors can operate directly from rechargeable batteries, providing the motive power for the first electric vehicles. Today DC motors are still found in applications as small as toys and disk drives, or in large sizes to operate steel rolling mills and paper machines. Modern DC motors are nearly always operated in conjunction with power electronic devices. The DC motor is a machine that transforms electric energy into mechanical energy in form of rotation. Its movement is produced by the physical behaviour of electromagnetism. DC motors have inductors inside, which produce the magnetic field used to generate movement.
Electromagnet
An electromagnet, which is a piece of iron wrapped with a wire coil that has voltage applied in its terminals. If two fixed magnets are added in both sides of this electromagnet, the repulsive and attractive forces will produce a torque
Torque
23
Then, there are two problems to solve: feeding the current to the rotating electromagnet without the wires getting twisted, and changing the direction of the current at the appropriate time. Both of these problems are solved using two devices: a split-ring commentator, and a pair of brushes.
Brushed Motor
As it can be seen, the commutator has two segments which are connected to each terminal of the electromagnet, besides the two arrows are the brushes which apply electric current to the rotary electromagnet. In real DC motors it can be found three slots instead of two and two brushes. This way, as the electromagnet is moving its polarity is changing and the shaft may keep rotating. Even if it is simple and sounds that it will work great there are some issues which make these motors energy inefficient and mechanically unstable, the principal problem is due to the timing between each polarity inversion. Since polarity in the electromagnet is changed mechanically, at some velocities polarity is changing too soon, which result in reverse impulses and sometimes in changing too late, generating instantaneous stops in rotation. Whatever the case, these issues produce current peaks and mechanical instability.
24
DC motors have only two terminals. If you apply a voltage to these terminals the motor will run, if you invert the terminals position the motor will change its direction. If the motor is running and you suddenly disconnect both terminals the motor will keep rotating but slowing down until stopping. Finally if the motor is running and you suddenly short-circuit both terminals the motor will stop. So there is not a third wire to control a DC motor, but knowing the previous behaviours it can be designed a way to control it, and the solution is an H-bridge. Look at the last evolution of the DC Motor above, you can observe that there are four gates and a motor connected between them. This is the simplest H-bridge, where the four gates represent for transistors. By manipulating these gates and connecting the upper and lower terminals to a voltage supply, you can control the motor in all the behaviours as below. H-Bridge States
25
26
27
28
4.7 CAPACITOR
A capacitor
to store energy in an electric field. The forms of practical capacitors vary widely, but all contain at least two electrical conductors separated by a dielectric(insulator); for example, one common construction consists of metal foils separated by a thin layer of insulating film. Capacitors are widely used as parts of electrical circuits in many common electrical devices. When there is a potential difference (voltage) across the conductors, a static electric field develops across the dielectric, causing positive charge to collect on one plate and negative charge on the other plate. Energy is stored in the electrostatic field. An ideal capacitor is characterized by a single constant value, capacitance, measured in farads. This is the ratio of the electric charge on each conductor to the potential difference between them.
29
With proper heat sink these LM78xx types can handle even more than 1A current. They also have Thermal overload protection, Short circuit protection. If your design exceeds 0.1A current you may chose regulator LM7805 with smaller packages and lower maximum current up to 0.1A. They come in three main types of packages SO-8, SOT89 and TO-92
30
This frequency is commonly used to keep track of time (as in quartz wristwatches), to provide a stable clock signal for digital integrated circuits, and to stabilize frequencies for radio transmitters and receivers. The most common type of piezoelectric resonator used is the quartz crystal, so oscillator circuits designed around them became known as "crystal oscillators." Quartz crystals are manufactured for frequencies from a few tens of kilohertz to tens of megahertz. More than two billion (2109) crystals are manufactured annually. Most are used for consumer devices such as wristwatches, clocks, radios, computers, and cell phones. Quartz crystals are also found inside test and measurement equipment, such as counters, signal generators, and oscilloscopes.
4.10 DIODE
The 1N4007 series (or 1N4000 series) is a family of popular 1.0 amp general purpose silicon rectifier diodes commonly used in AC adapters for common household appliances. Blocking voltage varies from 50 to 1000 volts. This diode is made in an axial-lead DO-41 plastic package.
The 1N5400 series is a similarly popular series for higher current applications, up to 3 A. These diodes come in the larger DO-201 axial package. These are fairly low-speed rectifier diodes, being inefficient for square waves of more than 15 kHz. The series was second sourced by many manufacturers. The 1N4000 series were in the
31
Motorola Silicon Rectifier Handbook in 1966, as replacements for 1N2609 through 1N2617. The 1N5400 series were announced in Electrical Design News in 1968, along with the now lesser known 1.5-ampere 1N5391 series. These devices are widely used and recommended. The table below shows the maximum repetitive reverse blocking voltages of each of the members of the 1N4000 and 1N5400 series
4.11 LED
A light-emitting diode (LED) is a semiconductor device that emits visible light when an electric current passes through it. The light is not particularly bright, but in most LEDs it is monochromatic, occurring at a single wavelength. The output from an LED can range from red (at a wavelength of approximately 700 nanometres) to blue-violet (about 400 nanometres). Some LEDs emit infrared (IR) energy (830 nanometres or longer); such a device is known as an infrared-emitting diode (IRED). An LED or IRED consists of two elements of processed material called P-type semiconductors and N-type semiconductors. These two elements are placed in direct contact, forming a region called the P-N junction. In this respect, the LED or IRED
32
resembles most other diode types, but there are important differences. The LED or IRED has a transparent package, allowing visible or IR energy to pass through. Also, the LED or IRED has a large PN-junction area whose shape is tailored to the application.
4.12 RESISTOR
A resistor is an electrical component that limits or regulates the flow of electrical current in an electronic circuit. Resistors can also be used to provide a specific voltage for an active device such as a transistor. All other factors being equal, in a direct-current (DC) circuit, the current through a resistor is inversely proportional to its resistance and directly proportional to the voltage across it. This is the well-known Ohm's Law. In alternating-current (AC) circuits, this rule also applies as long as the resistor does not contain inductance or capacitance. Resistors can be fabricated in a variety of ways. The most common type in electronic devices and systems is the carbon-composition resistor. Finger annulated carbon (graphite) is mixed with
33
clay and hardened. The resistance depends on the proportion of carbon to clay; the higher this ratio, the lower the resistance. Another type of resistor is made from winding Nichrome or similar wire on an insulating form. This component, called a wire wound resistor, is able to handle higher currents than a carboncomposition resistor of the same physical size. However, because the wire is wound into a coil, the component acts as an inductors as well as exhibiting resistance. This does not affect performance in DC circuits, but can have an adverse effect in AC circuits because inductance renders the device sensitive to changes in output.
Whether or not a material obeys Ohm's law, its resistance can be described in terms of its bulk resistivity. The resistivity, and thus the resistance, is temperature dependent. Over sizable ranges
34
of temperature, this temperature dependence can be predicted from a temperature coefficient of resistance.
The factor in the resistance which takes into account the nature of the material is the resistivity. Although it is temperature dependent, it can be used at a given temperature to calculate the resistance of a wire of given geometry. The inverse of resistivity is called conductivity. There are contexts where the use of conductivity is more convenient. Electrical conductivity () = 1/
4.13 RELAY
The electromagnetic relay consists of a multi-turn coil, wound on an iron core, to form an electromagnet. When the coil is energized, by passing current through it, the core becomes
35
temporarily magnetized. The magnetized core attracts the iron armature. The armature is pivoted which causes it to operate one or more sets of contacts. When the coil is de-energized the armature and contacts are released. The coil can be energized from a low power source such as a transistor while the contacts can switch high powers such as the mains supply. The relay can also be situated remotely from the control source. Relays can generate a very high voltage across the coil when switched off. This can damage other components in the circuit. To prevent this diode is connected across the coil. As there are always some chances of high voltage spikes back from the switching circuit i.e. heater so an opt coupler/isolator MCT2e is used. It provides and electrical isolation between the microcontroller and the heater. MCT2e is a 6-pin IC with a combination of optical transmitter LED and an optical receiver as phototransistor. Microcontroller is connected to pin no 2 of MCT2e through a 470-ohm resistor. Pin no.1 is given +5V supply and pin no.4 is grounded. To handle the current drawn by the heater a power transistor BC-369 is used as a current driver. Pin no.5 of optocoupler is connected to the base of transistor. It takes all its output to VCC and activates the heater through relay circuit. The electromagnetic relay consists of a multi-turn coil, wound on an iron core, to form an electromagnet. When the coil is energized, by passing current through it, the core becomes temporarily magnetized. The magnetized core attracts the iron armature. The armature is pivoted which causes it to operate one or more sets of contacts. When the coil is de-energized the armature and contacts are released. Relay has five points. Out of the 2 operating points one is permanently connected to the ground and the other point is connected to the collector side of the power transistor. When VCC reaches the collector side i.e. signal is given to the operating points the coil gets magnetized and attracts the iron armature. The iron plate moves from normally connected (NC) position to normally open (NO) position. Thus the heater gets the phase signal and is ON. To remove the base leakage voltage when no signal is present a 470-ohm resistance is used.
36
4.14BUZZER
A buzzer or beeper is an audio signaling device, which may be mechanical, electromechanical, or piezoelectric. Typical uses of buzzers and beepers include alarm devices, timers and confirmation of user input such as a mouse click or keystroke. A joy buzzer is an example of a purely mechanical buzzer. Early devices were based on an electromechanical system identical to an electric bell without the metal gong. Similarly, a relay may be connected to interrupt its own actuating current, causing the contacts to buzz. Often these units were anchored to a wall or ceiling to use it as a sounding board. The word "buzzer" comes from the rasping noise that electromechanical buzzers made
37
38