Professional Documents
Culture Documents
CHAPTER -1 INTRODUCTION
Solar tracking system is to utilize the maximum power from the sun. Now a day we are in heavy need to use the solar power as in the coming days everything we use might depend on this kind of systems.
1.1
INTRODUCTION Solar energy refers to the utilization of the radiant energy from the Sun. Solar power is
used interchangeably with solar energy, but refers more specifically to the conversion of sunlight into electricity by photovoltaic, concentrating solar thermal devices, or by an experimental technology such as a solar chimney or solar pond.Solar panels are Photovoltaic cells which gives voltage directly if you place them in sun light. Here if you change the position of panels the power output will vary. Means, direct sunrays on solar panel can give good output otherwise there might be decrease in the value of their outputs. So we have to track the path where the maximum power will attain. Solar panel devices are of two types that collect energy from the sun. One is solar photovoltaic modules which use solar cells to convert light from the sun into electricity and the other is solar thermal collector which converts the suns energy to heat water or another fluid such as oil or antifreeze. In this project we are using the photovoltaic type.The solar panel gives the voltage directly to the microcontroller through ADC. This solar panel should be fixed on the stepper motor shaft so that it can easily rotate 180 degrees. The microcontroller controls the stepper motor to rotate in desired direction. In order to attain maximum power output the microcontroller accesses the solar panel direction continuously, which is on the shaft of stepper motor. If maximum output attains it waits for the solar panel to acquire energy from the sun and gives the output voltage to the microcontroller. If the output of the solar panel is going to reduce, it again starts checking for the maximum output path. This is a cyclic process.
1.2. OBJECTIVE
The main aim of our project is to make the panel to rotate according to the sun direction from morning to evening automatically so that the panel grabs the solar energy to maximum extent possible throughout the day. This method of power generation is simple and is taken from natural resource. This need only maximum sunlight to generate power. This project helps for power generation by setting the equipment to get maximum sunlight automatically. This system is tracking for maximum intensity of light. When there is decrease in intensity of light, this system automatically changes its direction to get maximum intensity of light.
CHAPTER-2 PROPOSAL
2.1 BLOCK DIAGRAM
TRANSFORMER RATING
In our example above we were taking 0.5A out of the V sec of 10V. The VA required is 10 X 0.5A = 5VA. This is a small PCB mount transformer available in Australia and probably elsewhere. This would be an absolute minimum and if you anticipated drawing the maximum current all the time then go to a higher VA rating. The two capacitors in the primary side are small value types and if you don't know precisely and I mean precisely what you are doing then OMIT them. Their loss won't cause you heartache or terrible problems.
CONSTRUCTION
The whole project MUST be enclosed in a suitable box. The main switch (preferably double pole) must be rated at 240V or 120V at the current rating. All exposed parts within the box MUST be fully insulated, preferably with heat shrink tubing. 4.1 RECTIFIERS In-order to work with any components basic requirement is power supply. In this section there is a requirement of two different voltage levels. Those are 1) 5V DC power supply. 2) 9V DC power supply. Now the aim is to design the power supply section which converts 230V AC in to 5V DC. Since 230V AC is too high to reduce it to directly 5V DC, therefore we need a Step-down transformer that reduces the line voltage to certain voltage that will help us to convert it in to a 5V DC. Considering the efficiency factor of the bridge rectifier, we came to a conclusion to choose a transformer, whose secondary voltage is 3 to 4 V higher than the required voltage i.e. 5V. For this application 0-9V transformers is used, since it is easily available in the market. Page | 7 Gandhiji institute of science and technology
SOLAR TRACKING SYSTEM The output of the transformer is 9V AC; it feed to rectifier that converts AC to pulsating DC. As we all know that there are 3 kind of rectifiers that is 1) half wave 2) Full wave and 3) Bridge rectifier Here we short listed to use Bridge rectifier, because half wave rectifier has we less in efficiency. Even though the efficiency of full wave and bridge rectifier are the same, since there is no requirement for any negative voltage for our application, we gone with bridge rectifier. Since the output voltage of the rectifier is pulsating DC, in order to convert it into pure DC we use a high value (1000UF/1500UF) of capacitor in parallel that acts as a filter. The most easy way to regulate this voltage is by using a 7805 voltage regulator, whose output voltage is constant 5V DC irrespective of any fluctuation in line Volts.
REGULATORS
Voltage regulator
A voltage regulator is a piece of equipment designed for the maintenance of a constant level of voltage. Several types of voltage regulators exist and each have their own advantages and disadvantages. Most voltage regulators work by using an internal fixed voltage as a reference to be compared to the voltage being put out.
Cost
The costs of the different types of regulators are based on general usage. The actual cost of each type, but especially the first three types listed here, will vary depending upon the individual model as well as the quality of parts and workmanship. A higher quality series pass regulator, for example, might cost more than a lower quality step down series switch regulator.
Fig.2.4 Pin Diagram of Regulator Pin No 1 2 3 Function Input voltage (5V-18V) Ground (0V) Regulated output; 5V (4.8V-5.2V) Table 2.1 Pin Description Of Regulator Name Input Ground Output
FILTER Overview
Fig.2.5 Output of Filter As we have already seen, the rectifier circuitry takes the initial ac sine wave from the transformer or other source and converts it to pulsating dc. A full-wave rectifier will produce the waveform shown to the right, while a half-wave rectifier will pass only every other half-cycle to its output. This may be good enough for a basic battery charger, although some types of rechargeable batteries still won't like it. In any case, it is nowhere near good enough for most electronic circuitry. We need a way to smooth out the pulsations and provide a much "cleaner" dc power source for the load circuit.
SOLAR TRACKING SYSTEM To accomplish this, we need to use a circuit called a filter. In general terms, a filter is any circuit that will remove some parts of a signal or power source, while allowing other parts to continue on without significant hindrance. In a power supply, the filter must remove or drastically reduce the ac variations while still making the desired dc available to the load circuitry. Filter circuits aren't generally very complex, but there are several variations. Any given filter may involve capacitors, inductors, and/or resistors in some combination. Each such combination has both advantages and disadvantages, and its own range of practical application. We will examine a number of common filter circuits on this page. A Single Capacitor
Fig.2.6 Full wave Rectifier If we place a capacitor at the output of the full-wave rectifier as shown to the left, the capacitor will charge to the peak voltage each half-cycle, and then will discharge more slowly through the load while the rectified voltage drops back to zero before beginning the next half-cycle. Thus, the capacitor helps to fill in the gaps between the peaks, as shown in red in the first figure to the righ.Although we have used straight lines for simplicity, the decay is actually the normal exponential decay of any capacitor discharging through a load resistor. The extent to which the capacitor voltage drops depends on the capacitance of the capacitor and the amount of current drawn by the load; these two factors effectively form the RC time constant for voltage decay.
Fig.2.7 Output Of Full wave Rectifier Page | 11 Gandhiji institute of science and technology
SOLAR TRACKING SYSTEM As a result, the actual voltage output from this combination never drops to zero, but rather takes the shape shown in the second figure to the right. The blue portion of the waveform corresponds to the portion of the input cycle where the rectifier provides current to the load, while the red portion shows when the capacitor provides current to the load. As you can see, the output voltage, while not pure dc, has much less variation (or ripple, as it is called) than the unfiltered output of the rectifier. A half-wave rectifier with a capacitor filter will
only recharge the capacitor on every other peak shown here, so the capacitor will discharge considerably more between input pulses. Nevertheless, if the output voltage from the filter can be kept high enough at all times, the capacitor filter is sufficient for many kinds of loads, when followed by a suitable regulator circuit.
RC Filters:
Fig.2.8 RC Filter In order to reduce the ripple still more without losing too much of the dc output, we need to extend the filter circuit a bit. The circuit to the right shows one way to do this. This circuit does cause some dc loss in the resistor, but if the required load current is low, this is an acceptable loss. To see how this circuit reduces ripple voltage more than it reduces the dc output voltage, consider a load circuit that draws 10 mA at 20 volts dc. We'll use 100 f capacitors and a 100 resistor in the filter. For dc, the capacitors are effectively open circuits. Therefore any dc losses will be in that 100 resistor. For a load current of 10 mA (0.01 A), the resistor will drop
100 0.01 = 1 volt. Therefore, the dc output from the rectifier must be 21 volts, and the dc loss in the filter resistor amounts to 1/21, or about 4.76% of the rectifier output. This is generally quite acceptable. On the other hand, the ripple voltage (in the USA) exists mostly at a frequency of 120 Hz (there are higher-frequency components, but they will be attenuated even more than the 120 Hz component). At this frequency, each capacitor has a reactance of about 13.26 . Thus R and C2 Page | 12 Gandhiji institute of science and technology
SOLAR TRACKING SYSTEM form a voltage divider that reduces the ripple to about 13% of what came from the rectifier. Therefore, for a dc loss of less than 5%, we have attenuated the ripple by almost 87%. This is a substantial amount of ripple reduction, although it doesn't remove the ripple entirely. If the amount of ripple is still too much for the particular load circuit, additional filtering or a regulator circuit will be required.
LC Filters
Fig.2.9 LC Filter While the RC filter shown above helps to reduce the ripple voltage, it introduces excessive resistive losses when the load current is significant. To reduce the ripple even more without a lot of dc resistance, we can replace the resistor with an inductor as shown in the circuit diagram. In this circuit, the two capacitors store energy as before, and attempt to maintain a constant output voltage between input peaks from the rectifier. At the same time, the inductor stores energy in its magnetic field, and releases energy as needed in its attempt to maintain a constant current through itself. This provides yet another factor that attempts to smooth out the ripple voltage. In some cases, C1 is omitted from this
filter circuit. The result is a lower dc output voltage, but improved ripple removal. The choice is a trade-off, and must be made according to the specific requirements in each individual case. For dc, the inductance has only the resistance of the wire that comprises the coil, which amounts to a few ohms. Meanwhile, the capacitors still operate as open circuits at dc, so they do not reduce the dc output voltage. However, at the basic ripple frequency of 120 Hz, a 10 Henry inductance has a reactance of: XL = 2 fL = 7540 at the same time, a 100 f capacitor at the
same ripple frequency has a reactance of: XC = 1/2 fc = 13.26ohms. Thus, L and C2 form a voltage divider that drastically reduces the ripple component (to less than 0.2%) while leaving the desired dc output nearly alone. This configuration may provide sufficiently pure dc for some applications, without the need for any following regulator at all. The drawback of this approach is that a 10 Henry inductor is as large as some power transformers, with a heavy iron core. It takes up a lot of space and is relatively expensive. This is Page | 13 Gandhiji institute of science and technology
SOLAR TRACKING SYSTEM why the RC filter circuit may be preferred to the LC filter, provided the ripple reduction is sufficient and the power loss in the resistor is not excessive.
MICROPROCESSOR VS MICROCONTROLLER
Microprocessor
CPU is stand-alone, RAM, ROM, I/O, timer are separate Designer can decide on the amount of ROM, RAM and I/O ports. expensive versatility general-purpose
Microcontroller:
CPU, RAM, ROM, I/O and timer are all on a single chip fix amount of on-chip ROM, RAM, I/O ports for applications in which cost, power and space are critical single-purpose
SELECTION OF MICROCONTROLLER
As we know that there so many types of micro controller families that are available in the market. Those are 1) 8051 Family 2) AVR microcontroller Family 3) PIC microcontroller Family 4) ARM Family Basic 8051 family is enough for our application; hence we are not concentrating on higher end controller families. In order to fulfill our application basic that is AT89C51 controller is enough. But still we selected AT89S52 controller because of inbuilt ISP (in system programmer) option. There are minimum six requirements for proper operation of microcontroller. Those are: 1) power supply section 2) pull-ups for ports (it is must for PORT 0) 3) Reset circuit 4) Crystal circuit\
SOLAR TRACKING SYSTEM 5) ISP circuit (for program dumping) 6) EA/VPP pin is connected to Vcc. PORT0 is open collector thats why we are using pull-up resistor which makes PORT0 as an I/O port. Reset circuit is used to reset the microcontroller. Crystal circuit is used for the microcontroller for timing pluses. In this project we are not using external memory thats why EA/VPP pin in the microcontroller is connected to Vcc that indicates internal memory is used for this appli
MICROCONTROLLER 89S52
FEATURES
8K Bytes of In-System Reprogrammable Flash Memory Endurance: 1,000 Write/Erase Cycles Fully Static Operation: 0 Hz to 24 MHz 256 x 8-bit Internal RAM 32 Programmable I/O Lines Three 16-bit Timer/Counters Eight Interrupt Sources Programmable Serial Channel Low-power Idle and Power-down Modes
DESCRIPTION
The AT89C52 is a low-power, high-performance CMOS 8-bit microcomputer with 8Kbytes of Flash programmable and erasable read only memory (PEROM). The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89C52 is a powerful microcomputer, which provides a highly flexible and costeffective solution to many embedded control applications
PIN DESCRIPTION
VCC - Supply voltage. GND - Ground.
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 highimpedance 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 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. In addition, P1.0 and P1.1 Page | 17 Gandhiji institute of science and technology
SOLAR TRACKING SYSTEM 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.
PORT PIN ALTERNATE FUNCTIONS P1.0 T2 (external count input to Timer/Counter 2), clock-out P1.1 T2EX (Timer/Counter 2 capture/reload trigger and direction control 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 (I IL) 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 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 uses 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 (I IL) because of the pull-ups. Port 3 also serves the functions of various special features of the AT89C51. Port 3 also receives some control signals for Flash programming and verification.
RST:
Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device.
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. 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 pro-gram memory locations starting at 0000H up to FFFFH. However, 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 12V programming enable voltage (VPP) during Flash programming when 12V programming is selected.
XTAL1:
Input to the inverting oscillator amplifier and input to the internal clock operating circuit.
XTAL2:
It is an output from the inverting oscillator amplifier.
EXTERNAL INTERRUPTS INTERRUPT CONTROL ON-CHIP ROM FOR PROGRAM CODE ONCHIP RAM
TIMER/CO UNTER
TIMER 1 TIMER 0
COUNTER INPUTS
CPU
OSC
BUS CONTROL
4 I/O PORTS
SERIAL PORT
P0 P1 P2 P3
Tx
Rx
IDLE MODE
In idle mode, the CPU puts itself to sleep while all the on-chip peripherals remain active. The mode is invoked by software. The content of the on-chip RAM and all the special functions registers remain unchanged during this mode. The idle mode can be terminated by any enabled interrupt or by a hardware reset. It should be noted that when idle is terminated by a hardware reset, the device normally resumes program execution, from where it left off, up to two machine cycles before the internal reset algorithm takes control. On-chip hardware inhibits access to internal RAM in this event, but access to the port pins is not inhibited. To eliminate the possibility of an unexpected write to a port pin when Idle is terminated by reset, the instruction following the one that invokes Idle should not be one that writes to a port pin or to external memory.
Fig.2.12 Oscillator
CONNECTIONS OF DRIVER
In this application driver is used to increase the strength of signals .The 2nd and 7th pins of this IC are connected to the PORT1.0 and PORT1.1 of Microcontroller. The 10th and 15th pin of this IC are connected to the PORT1.2 and PORT1.3 of Microcontroller.
L293D
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 solenoids, 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.
FEATURES
Supply Voltage from 4.5 V to 3.5v Separate Input-Logic Supply Internal ESD Protection Thermal Shutdown High-Noise-Immunity Inputs
SOLAR TRACKING SYSTEM Functional Replacements for SGS L293 and SGS L293D Output Current 1 A per Channel (600 MA for L293D) Peak Output Current 2 A per Channel (1.2 A for L293D) Output Clamp Diodes for Inductive Transient Suppression (L293D)
PIN DIAGRAM
motor will move in the opposite direction. One can easily experiment with DC motor. For example, small fans used in any mother boards to cool the CPU are run by DC motors. By connecting their leads to the + and voltage source, the DC motor moves .While a stepper motor moves in steps of 1 to 50degrees,the DC motor moves continuously. In a stepper motor, if we know the starting position we can easily count the number of steps the motor has moved and calculate the final position of the motor. This is not possible in a DC motor. The maximum speed of a DC motor is indicated in rpm and is given in the data sheet. The DC motor has two rpms: no load and loaded. The manufacturers data sheet gives the no -load rpm.the no-load rpm can be from a few thousand to tens of thousands. The rpm is reduced when moving a load and it decreases as the load is increased. For example, a drill turning a screw has a much lower rpm Page | 26 Gandhiji institute of science and technology
SOLAR TRACKING SYSTEM speed then when it is in the no-load situation.DC motors also have voltage and current ratings. The nominal voltage is the voltage for that motor under normal conditions, and can be from 1 to 150v, depending on the motor. As we increase the voltage, the rpm goes up. The current rating is the current consumption when the nominal voltage is applied with no load, and can be from 25mA to a few amps. As the load increases, the rpm is decreased, unless the current or voltage provided to the motor is increased, which in turn increases the torque. With a fixed voltage, as the load increases, the current (power) consumption of a DC motor is increased. If we overload the motor it will stall, and that can damage the motor due to the heat generated by high current consumption. INTRODUCTION TO MOTORS A motor is a machine which converts energy into rotating motion. The dictionary definition of motor is broader than that but when engineers and mechanics talk about motors they are almost always talking about rotating motion. There are different names for devices which convert energy into other types of motion. A DC motor is a motor that uses direct electrical current (DC) as the source of its energy. An AC motor is a motor that uses alternating electrical current (AC) as the source of its energy. AC current is the type of electricity provided by household wall outlets. DC current is the type of electricity provided by batteries. A gear motor is a motor with an attached set of gears driving a secondary drive shaft. Practical motor designs result in motors that spin too fast for most uses. As a result, almost all gear sets are used to "gear down" the motor. The geared down drive shaft spins slower than the direct motor drive shaft. The geared down drive shaft also spins "harder". Motor speed is generally measured in revolutions per minute (RPM). Rotating force is called torque and for hobby motors is generally measured in inch-ounces or centimeter-grams. For now, just remember that the higher the number the harder the motor turns. Gearing down a motor reduces its RPM (speed) but increases its torque. Gears are generally contained within a housing that protects the gears from interference and which provides a bearing surface for the various gear shafts and drive shafts. The term gear box generally refers to the entire system of gears, shafts, bearings and housing. When you apply energy to a motor it spins as fast and hard as its design allows for that energy level and output load. If you increase the energy supply it spins faster and harder. If Page | 27 Gandhiji institute of science and technology
SOLAR TRACKING SYSTEM you attach a load the motor will slow down. If you continue increasing the load it slows ever more until the motors capability to work is exceeded. When the extreme load causes the motor to stop it is said to be stalled. Reducing the load causes the motor spin faster. If you entirely remove the load the motor is said to be "free running" and operates at its maximum speed for that input energy level. Electric motors both ac and dc motors, come in many shapes and sizes. Some are standardized electric motors for general-purpose applications. Other electric motors are intended for specific tasks. In any case, electric motors should be selected to satisfy the dynamic requirements of the machines on which they are applied without exceeding rated electric motor temperature. Thus, the first and most important step in electric motor selection is determining load characteristics -- torque and speed versus time. Electric motor selection is also based on mission goals, power available, and cost. An electric motor uses electrical energy to produce mechanical energy. The reverse process for using mechanical energy to produce electrical energy is accomplished by a generator or dynamo. Electric motors are found in household appliances such as fans, refrigerators, washing machines, pool pumps, floor vacuums, and fan-forced ovens. They are also found in many other devices such as computer equipment, in its disk drives, printers, and fans; and in some sound and video playing and recording equipment as DVD/CD players and recorders, tape players and recorders, and record players. Electric motors are also found in several kinds of toys such as some kinds of vehicles and robotic toys. The classic division of electric motors has been that of direct current (DC) type vs. Alternating Current (AC) types. This is more a de facto convention, rather than a rigid distinction. For example, many classic DC motors run on AC power, these motors being referred to as universal motors.
AC (Shaded Pole)
Induction
slips
from Fans
Uni/Poly-phase AC
AC
slips
from
(split-phase capacitor)
Appliances
Uni/Poly-phase AC
AC Synchronous
Uni/Poly-phase AC
Stepper DC
Precision
Multiphase DC
Brushless motor
DC
electric
lifespan maintenance
High
initial
cost
Requires a controller
Brushed motor
DC
electric
initial speed
maintenance
exercisers
Direct (PWM)
(Fig) 2.3 Types of motors 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. Two important performance parameters of DC motors are the motor constants, Kv and Km. Contents [hide] 1 Brush 2 Brushless 3 Uncommitted 4 Connection types 4.1 Series connection 4.2 Shunt connection Page | 29 Gandhiji institute of science and technology
SOLAR TRACKING SYSTEM 4.3 Compound connection 5 See also 6 External links 7 References
SOLAR TRACKING SYSTEM Other types of DC motors require no commutation. Homopolar motor A homopolar motor has a magnetic field along the axis of rotation and an electric current that at some point is not parallel to the magnetic field. The name homopolar refers to the absence of polarity change. Homopolar motors necessarily have a single-turn coil, which limits them to very low voltages. This has restricted the practical application of this type of motor. Ball bearing motor A ball bearing motor is an unusual electric motor that consists of two ball bearing-type bearings, with the inner races mounted on a common conductive shaft, and the outer races connected to a high current, low voltage power supply. An alternative construction fits the outer races inside a metal tube, while the inner races are mounted on a shaft with a nonconductive section (e.g. two sleeves on an insulating rod). This method has the advantage that the tube will act as a flywheel. The direction of rotation is determined by the initial spin which is usually required to get it going. [Edit]Connection types See also: Excitation (magnetic) There are three types of connections used for DC electric motors: series, shunt and compound. These types of connections configure how the motor's field and armature windings are connected. The type of connection is significant because it determines the characteristics of the motor and is selected for speed/torque requirements of the load. [1] [Edit]Series connection A series DC motor connects the armature and field windings in series with a common D.C. power source. This motor has poor speed regulation since its speed varies approximately inversely to load. However, a series DC motor has very high starting torque and is commonly used for starting high inertia loads, such as trains, elevators or hoists.[2] With no mechanical load on the series motor, the current is low, the magnetic field produced by the field winding is weak, and so the armature must turn faster to produce sufficient counter-EMF to balance the supply voltage (and internal voltage drops). For some types of motor, the speed may be higher than can be safely sustained by the motor. In a no-load condition, the motor may increase its speed until the motor mechanically destroys itself. This is called a runaway condition. The speed/torque characteristic is also useful in applications such as dragline excavators, where the digging tool moves rapidly when unloaded but slowly when carrying a heavy load. Page | 31 Gandhiji institute of science and technology
SOLAR TRACKING SYSTEM Series motors called "universal motors" can be used on alternating current. Since the armature voltage and the field direction reverse at (substantially) the same time, torque continues to be produced in the same direction. Since the speed is not related to the line frequency, universal motors can develop higher-than-synchronous speeds, making them lighter than induction motors of the same rated mechanical output. This is a valuable characteristic for hand-held power tools. Universal motors for commercial power frequency are usually small, not more than about 1 kW output. However, much larger universal motors were used, fed by special low-frequency traction power networks to avoid problems with commutation under heavy and varying loads. [Edit]Shunt connection A shunt DC motor connects the armature and field windings in parallel or shunt with a common D.C. power source. This type of motor has good speed regulation even as the load varies, but does not have as high of starting torque as a series DC motor.[3] It is typically used for industrial, adjustable speed applications, such as machine tools, winding/unwinding machines and tensionless. [Edit]Compound connection A compound DC motor connects the armature and fields windings in a shunt and a series combination to give it characteristics of both a shunt and a series DC motor.[4] This motor is used when both a high starting torque and good speed regulation is needed. The motor can be connected in two arrangements: cumulatively or differentially. Cumulative compound motors connect the series field to aid the shunt field, which provides higher starting torque but less speed regulation. Differential compound DC motors have good speed regulation and are typically operated at constant speed. They are commonly used in elevators, air compressors, conveyors and punch presses.
Fig.2.18 dc motor
Solar (photovoltaic) panels convert energy in the form of light from the sun into electrical energy. Between 4 and 22 percent of the energy falling on a panel is actually converted to usable electrical energy. The rest is reflected or turned into heat. These panels should not be confused with those used for solar water heating, which simply use the sun's energy to heat water directly.
A solar cell or photovoltaic cell is a device that converts solar energy into electricity by the photovoltaic effect. Photovoltaic is the field of technology and research related to the application of solar cells as solar energy. Sometimes the term solar cell is reserved for devices intended specifically to capture energy from sunlight, while the term photovoltaic cell is used when the source is unspecified.
As in the simple LED circuit, The effect is a form of electroluminescence where incoherent and narrow-spectrum light is emitted from the p-n junction. LEDs are widely used as indicator lights on electronic devices and increasingly in higher power applications such as flashlights and area lighting. An LED is usually a small area (less than 1 mm2) light source, often with optics added to the chip to shape its radiation pattern and assist in reflection. The color of the emitted light depends on the composition and condition of the semi conducting material used, and can be infrared, visible, or ultraviolet. Besides lighting, interesting applications include using UV-LEDs for sterilization of water and disinfection of devices, and as a grow light to enhance photosynthesis in plants.
COLOR CODING:
Potential Difference 1.6 V 1.8 V to 2.1 V 2.2 V 2.4 V 2.6 V 3.0 V to 3.5 V 3.0 V to 3.5 V 3.5V
White Ultraviolet
Fig.2.4 color coding of led Page | 35 Gandhiji institute of science and technology
SOLAR TRACKING SYSTEM (Close-up of a typical LED in its case showing the internal structure)
ADVANTAGES LEDs have many advantages over other technologies like lasers. As compared to laser diodes or IR sources LEDs are conventional incandescent lamps. For one thing, they don't have a filament that will burn out, so they last much longer. Additionally, their small plastic bulb makes them a lot more durable. They also fit more easily into modern electronic circuits. The main advantage is efficiency. In conventional incandescent bulbs, the lightproduction process involves generating a lot of heat (the filament must be warmed). Unless you're using the lamp as a heater, because a huge portion of the available electricity isn't going toward producing visible light. LEDs generate very little heat. A much higher percentage of the electrical power is going directly for generating light, which cuts down the electricity demands considerably. LEDs offer advantages such as low cost and long service life. Moreover LEDs have very low power consumption and are easy to maintain.
DISADVANTAGES LEDs performance largely depends on the ambient temperature of the operating environment. LEDs must be supplied with the correct current. LEDs do not approximate a "point source" of light, so cannot be used in applications needing a highly collimated beam. But the disadvantages are quite negligible as the negative properties of LEDs do not apply and the advantages far exceed the limitations.
Miniature
These are mostly single-die LEDs used as indicators, and they come in various sizes from 2 mm to 8 mm, through-hole and surface mount packages. They usually do not use a separate heat sink.[83] Typical current ratings ranges from around 1 am to above 20 am. The small size sets a natural upper boundary on power consumption due to heat caused by the high current density and need for a heat sink. Common package shapes include round, with a domed or flat top, rectangular with a flat top (as used in bar-graph displays), and triangular or square with a flat top. The encapsulation may also be clear or tinted to improve contrast and viewing angle. There are three main categories of miniature single die LEDs: Low-current typically rated for 2 am at around 2 V (approximately 4 maw consumption). Standard 20 am LEDs at around 2 V (approximately 40 maw) for red, orange, yellow, and green, and 20 am at 45 V (approximately 100 maw) for blue, violet, and white. Ultra-high-output 20 am at approximately 2 V or 45 V, designed for viewing in direct sunlight. Five- and twelve-volt LEDs are ordinary miniature LEDs that incorporate a suitable series resistor for direct connection to a 5 V or 12 V supply.
Mid-range
Medium-power LEDs are often through-hole-mounted and used when an output of a few lumen is needed. They sometimes have the diode mounted to four leads (two cathode leads, two anode leads) for better heat conduction and carry an integrated lens. An example of this is the Super flux package, from Philips Luciles. These LEDs are most commonly used in light panels, emergency lighting, and automotive tail-lights. Due to the larger amount of metal in the LED, they are able to handle higher currents (around 100 m A). The higher current allows for the higher light output required for tail-lights and emergency lighting.
High-power
High-power LEDs (HPLED) can be driven at currents from hundreds of am to more than an ampere, compared with the tens of am for other LEDs. Some can emit over a thousand lumens.[84][85] Since overheating is destructive, the HPLEDs must be mounted on a heat sink to allow for heat dissipation. If the heat from a HPLED is not removed, the device will fail in seconds. One HPLED can often replace an incandescent bulb in a flashlight, or be set in an array to form a powerful LED lamp. Some well-known HPLEDs in this category are the Luciles Rebel Led, Orem Opt Semiconductors Golden Dragon, and Cree X-lamp. As of September 2009, some HPLEDs manufactured by Cree Inc. now exceed 105 lm/W [86] (e.g. the Lamp XP-G LED chip emitting Cool White light) and are being sold in lamps intended to replace incandescent, halogen, and even fluorescent lights, as LEDs grow more cost competitive. LEDs have been developed by Seoul Semiconductor that can operate on AC power without the need for a DC converter. For each half-cycle, part of the LED emits light and part is dark, and this is reversed during the next half-cycle. The efficacy of this type of HPLED is typically 40 lm/W.[87] A large number of LED elements in series may be able to operate directly from line voltage. In 2009, Seoul Semiconductor released a high DC voltage LED capable of being driven from AC power with a simple controlling circuit. The low-power dissipation of these LEDs affords them more flexibility than the original AC LED design.[88]
10K PULLUP
10K PULLUP
R8 R7 R6 R5 R4 R3 R2 R1 C
C R1 R2 R3 R4 R5 R6 R7 R8
VCC VCC 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 (T2) P1.0 (T2 EX) P1.1 P1.2 P1.3 P1.4 (MOSI) P1.5 (MISO) P1.6 (SCK) P1.7 RST VCC P0.0/AD0 P0.1/AD1 P0.2/AD2 P0.3/AD3 P0.4/AD4 P0.5/AD5 P0.6/AD6 P0.7/AD7 EA/VPP 40 39 38 37 36 35 34 33 32 31 30
9 8 7 6 5 4 3 2 1
1 2 3 4 5 6 7 8 9
4.7K
CLK(MCP3201) DOUT(MCP3201) CS(MCP3201) FROM ISP FROM ISP FROM ISP RST
XTAL2 XTAL1
(RXD) P3.0 (TXD) P3.1 ALE/PROG (INT0) P3.2 (INT1) P3.3 PSEN (T0) P3.4 P2.7/A15 (T1) P3.5 (WR) P3.6 P2.6/A14 P2.5/A13 (RD) P3.7 P2.4/A12 XTAL2 P2.3/A11 P2.2/A10 XTAL1 P2.1/A9 GND P2.0/A8
GND
GND
LCD
GND
9 8 7 6 5 4 3 2 1
2 2 1 SOLARPANEL 3 4
AT89S52
10K PULLUP
GND
MCP3201
LCD DISPLAY
7805 REG
VIN VOUT
C R1 R2 R3 R4 R5 R6 R7 R8
VCC = 5V 3 220 ohm 104pf LED
STEPPER MOTOR
P2.7 P2.6 P2.5 P2.4
1 2 3 4 5 6 7 8 1B 2B 3B 4B 5B 6B 7B GND 1C 2C 3C 4C 5C 6C 7C COM 16 15 14 13 12 11 10 9 1 2 3
TRANSFORMER
GND 2
33pf
(9V,1 AMP)
1000uf /35V
VCC
VCC GND
SWITCH
33 pf C
10 uf/63V
RST R
1 3 5 7 9 VCC
I S P
2 4 6 8 10
8.2K
GND Size Document Number Wednesday , February 04, 2009 Sheet 1 of 1 Rev
GND
RESET
AT89S52 ISP
AT89S52 CRYSTAL
Date:
DESIGNING In order to fulfill this application there are few steps that has been performed i.e.
1) Designing the power supply for the entire circuitry. 2) Selection of microcontroller that suits our application. 3) Selection of ADC.
Complete studies of all the above points are useful to develop this project.
As we know that there so many types of micro controller families that are available in the market. Those are
1) 8051 Family 2) AVR microcontroller Family 3) PIC microcontroller Family 4) ARM Family
Basic 8051 family is enough for our application; hence we are not concentrating on higher end controller families.
In order to fulfill our application basic that is AT89C51 controller is enough. But still we selected AT89S52 controller because of inbuilt ISP (in system programmer) option.
There are minimum six requirements for proper operation of microcontroller. Those are: Page | 40 Gandhiji institute of science and technology
SOLAR TRACKING SYSTEM 3) power supply section 4) pull-ups for ports (it is must for PORT0) 5) Reset circuit 6) Crystal circuit 7) ISP circuit (for program dumping) 8) EA/VPP pin is connected to Vcc. PORT0 is open collector thats why we are using pull-up resistor which makes PORT0 as an I/O port. Reset circuit is used to reset the microcontroller. Crystal circuit is used for the microcontroller for timing pluses. In this project we are not using external memory thats why EA/VPP pin in the microcontroller is connected to Vcc that indicates internal memory is used for this application.
Driver is used increase the strength of signal. In this application we are using stepper motor to rotate the solar panel .So to drive the stepper motor we have to increase the strength of signal. In the market so many ICs are available I selected ULN 2003 which is inbuilt 7 NPN transistors .And the working voltage of this IC is 5 volts which is same as microcontroller working voltage .And in my board I no need to design any other power supply section thats why I selected this IC in my project.
Here in this project I selected SPI protocol based MCP3201 ADC. In this project ADC is used to convert analog voltage sent by the solar panel to digital voltage. We can use parallel ADC (ADC 0804) but we need more pins to interface that, so to reduce port pins we can use MCP3201, but to read the data from MCP3201 we can use SPI protocol.
Microcontroller has 4 ports and every port has 8 pins We are connecting all external components to this ports only .LCD is connected to the PORT zero and ULN2003 is connected to PORT two and MCP 3201 which is acting as ADC is connected to the P1.0 and P1.1 and P1.2 .
CONNECTIONS OF ADC
In this application ADC is used to convert from analog voltage to digital voltage .The output of solar panel is connected to 2nd (input) pin of this IC .The output pins 7th, 6th, 5th are connected to P1.0, P1.1, and P1.2 of controller
CONNECTIONS OF DRIVER IC (ULN 2003) ULN 2003 has 16 pins in this 1st pin is connected to 2.7 pin and 2nd pin is connected to 2.6 and 3rd pin is connected to 2.5 and 4th pin is connected to 2.4 pin of the microcontroller. And 8th pin is connected to ground 9th to Vcc and 13th to 16th pins are connected to the stepper motor. And other pins are not connected.
Stepper motor has 6 wires all this are connected to the ULN 2003 .In these two wires are connected to Vcc and other wires are connected to the 13th to 16th pin of the ULN 2003.
Whenever the power up we are written application program to rotate the solar panel till 360 degrees step by step to find maximum intensity .In this project we are using stepper motor to rotate the solar panel .In this application we are using 12 steps to rotate the solar panel 360 degrees .we can measure the intensity per each step in form of voltage levels .So we can measure 12 voltage levels for 12 steps .Solar panel gives the intensity in the form of voltage and this voltage gives to ADC, the ADC converts the analog voltage to digital voltage and this value is given to the controller. After measuring all voltage values then we can find maximum value it means there is maximum intensity .So we can place the solar panel where is the maximum intensity.
After a particular time again we can rotate the solar panel step by step till 360 degrees, then we can measure the voltage levels per each step and we can find the maximum intensity value in the form of voltage. According the voltage value we can place the solar panel at particular position. We can repeat this process.
4.3 Applications
1. Can be used for small & medium scale power generations 2. For power generation at remote places where power lines are not accessible. 3 For domestic backup power systems.
CHAPTER 5
FUTURE SCOPE
Solar energy refers to the utilization of the radiant energy from the Sun. Solar power is used interchangeably with solar energy, but refers more specifically to the conversion of sunlight into electricity by photovoltaic, concentrating solar thermal devices, or by an experimental technology such as a solar chimney or solar pond.Solar panels are Photovoltaic cells which gives voltage directly if you place them in sun light. Here if you change the position of panels the power output will vary. Means, direct sunrays on solar panel can give good output otherwise there might be decrease in the value of their outputs. So we have to track the path where the maximum power will attain. Solar panel devices are of two types that collect energy from the sun. One is solar photovoltaic modules which use solar cells to convert light from the sun into electricity and the other is solar thermal collector which converts the suns energy to heat water or another fluid such as oil or antifreeze. In this project we are using the photovoltaic type.The solar panel gives the voltage directly to the microcontroller through ADC. This solar panel should be fixed on the stepper motor shaft so that it can easily rotate 180 degrees. The microcontroller controls the stepper motor to rotate in desired direction. In order to attain maximum power output the microcontroller accesses the solar panel direction continuously, which is on the shaft of stepper motor. By using real time clock we can adjust the panel directions according to the sun angle without using manpower
CHAPTER 6 Conclusion
A solar tracking system, comprising: a first set of solar heat gain transducers that produce respective first electrical output signals to drive a reversible first motor for changing a vertical angle of a solar collector; a second set of solar heat gain transducers that produce respective second electrical output signals to drive a reversible second motor for changing a horizontal angle of the solar collector; each of the transducers having a thermistor in thermal contact with a thermal mass, wherein the thermal mass comprises a mass of conducting material to elevate in temperature while illuminated by the sun, and wherein the thermistor senses the temperature of the thermal mass and produces a corresponding one of the electrical output signals proportional to the temperature; and each of the transducers having the thermistor and the thermal mass contained in a solar energy collecting and heat insulating enclosure that is solar energy transparent.
CHAPTER 7 REFERENCE
TEXT BOOKS REFERED
1. The 8051 Microcontroller and Embedded Systems by Muhammad Ali Mazidi and Janice Gillispie Mazidi, Pearson Education. 2. 8051 Microcontroller Architecture, programming and application by KENNETH JAYALA
3. ATMEL 89s52 Data sheets 4. Hand book for Digital ICs from Analogic Devices
WEBSITES VIEWED
www.atmel.com www.beyondlogic.org www.dallassemiconductors.com www.maxim-ic.com www.alldatasheets.com www.howstuffworks.com
APPENDIX A
A.1 INTRODUCTION TO EMBEDDED SYSTEMS
Embedded systems are electronic devices that incorporate microprocessors with in their implementations. The main purposes of the microprocessors are to simplify the system design and provide flexibility. Having a microprocessor in the device helps in removing the bugs, making modifications, or adding new features are only matter of rewriting the software that controls the device. Or in other words embedded computer systems are electronic systems that include a microcomputer to perform a specific dedicated application. The computer is hidden inside these products. Embedded systems are ubiquitous. Every week millions of tiny computer chips come pouring out of factories finding their way into our everyday products. Embedded systems are self-contained programs that are embedded within a piece of hardware. Whereas a regular computer has many different applications and software that can be applied to various tasks, embedded systems are usually set to a specific task that cannot be altered without physically manipulating the circuitry. Another way to think of an embedded system is as a computer system that is created with optimal efficiency, thereby allowing it to complete specific functions as quickly as possible. Embedded systems designers usually have a significant grasp of hardware technologies. They use specific programming languages and software to develop embedded systems and manipulate the equipment. When searching online, companies offer embedded systems development kits and other embedded systems tools for use by engineers and businesses. Embedded systems technologies are usually fairly expensive due to the necessary development time and built in efficiencies, but they are also highly valued in specific industries. Smaller businesses may wish to hire a consultant to determine what sort of embedded systems will add value to their organization. A.1.1 CHARACTERISTICS Two major areas of differences are cost and power consumption. Since many embedded systems are produced in tens of thousands to millions of units range, reducing cost is a major concern. Embedded systems often use a (relatively) slow processor and small memory size to minimize costs. The slowness is not just clock speed. The whole architecture of the computer is often intentionally simplified to lower costs. For example, embedded systems often use peripherals controlled by synchronous serial interfaces, which are ten to hundreds of times slower than comparable peripherals used in PCs. Programs on an embedded system often run with real-time constraints with limited hardware resources: often there is no disk drive, operating system, keyboard or screen. A flash drive may replace rotating media, and a small keypad and LCD screen may be used instead of a PC's keyboard and screen. Page | 48 Gandhiji institute of science and technology
SOLAR TRACKING SYSTEM Firmware is the name for software that is embedded in hardware devices, e.g. in one or more ROM/Flash memory IC chips. Embedded systems are routinely expected to maintain 100% reliability while running continuously for long periods, sometimes measured in years. Firmware is usually developed and tested too much harsher requirements than is general-purpose software, which can usually be easily restarted if a problem occurs. A.1.2 PLATFORM There are many different CPU architectures used in embedded designs. This in contrast to the desktop computer market which is limited to just a few competing architectures mainly the Intel/AMD x86 and the Apple/Motorola/IBM Power PCs which are used in the Apple Macintosh. One common configuration for embedded systems is the system on a chip, an application-specific integrated circuit, for which the CPU was purchased as intellectual property to add to the IC's design. A.1.3 TOOLS Like a typical computer programmer, embedded system designers use compilers, assemblers and debuggers to develop an embedded system. Those software tools can come from several sources: Software companies that specialize in the embedded market Ported from the GNU software development tools. Sometimes, development tools for a personal computer can be used if the embedded processor is a close relative to a common PC processor. Embedded system designers also use a few software tools rarely used by typical computer programmers. Some designers keep a utility program to turn data files into code, so that they can include any kind of data in a program. Most designers also have utility programs to add a checksum or CRC to a program, so it can check its program data before executing it. A.1.4 OPERATING SYSTEM
They often have no operating system, or a specialized embedded operating system (often a realtime operating system), or the programmer is assigned to port one of these to the new system. A.1.5 DEBUGGING
Debugging is usually performed with an in-circuit emulator, or some type of debugger that can interrupt the micro controllers internal microcode. The microcode interrupt lets the debugger operate in hardware in which only the CPU works. The CPU-based debugger can be used to test and debug the electronics of the computer from the viewpoint of the CPU. Developers should insist on debugging which shows the high-level language, with breakpoints and single stepping, because these features are widely available. Also, developers should write and use simple logging facilities to debug sequences of real-time events. PC or mainframe programmers first encountering this sort of programming often become confused about design priorities and acceptable methods. Mentoring, code-reviews and ego less programming are recommended. Page | 49 Gandhiji institute of science and technology
SOLAR TRACKING SYSTEM One major disadvantage of this system is that it does not guarantee a time to respond to any particular hardware event. Careful coding can easily assure that nothing disables interrupts for long. Thus interrupt code can run at very precise timings. Another major weakness of this system is that it can become complex to add new features. Algorithms that take a long time to run must be carefully broken down so only a little piece gets done each time through the main loop. This system's strength is its simplicity, and on small pieces of software the loop is usually so fast that nobody cares that it is not predictable. Another advantage is that this system guarantees that the software will run. There is no mysterious operating system to blame for bad behavior.
CPU, RAM, ROM, I/O and timer are all on a single chip fix amount of on-chip ROM, RAM, I/O ports for applications in which cost, power and space are critical
APPENDIX B
Many companies provide the 8051 assembler, some of them provide shareware version of their product on the Web, Kiel is one of them. We can download them from their Websites. However, the size of code for these shareware versions is limited and we have to consider which assembler is suitable for our application.
B.1 KIEL U VISION2 This is an IDE (Integrated Development Environment) that helps you write, compile, and debug embedded programs. It encapsulates the following components: . . . . . A project manager A make facility Tool configuration Editor A powerful debugger To get start here are some several example programs
Select Project - Rebuild all target files or Build target. UVision2 compiles, assembles,
SOLAR TRACKING SYSTEM . . Select a directory and enter the name of the project file. Select Project - Select Device and select an 8051, 251, or C16x/ST10 device from the Device . . . Database Create source files to add to the project. Select Project - Targets, Groups, and Files. Add/Files, select Source Group1, and add the source files to the project. . Select Project - Options and set the tool options. Note when you select the target device from the Device Database all-special options are set automatically. You only need to configure the memory map of your target hardware. Default memory model settings are optimal for most.
. .
Select Debug - Start/Stop Debug Session. Use the Step toolbar buttons to single-step through your program. You may enter G, main in the Output Window to execute to the main C function.
. .
Open the Serial Window using the Serial #1 button on the toolbar. Debug your program using standard options like Step, Go, Break, and so on.
The following limitations apply to the evaluation versions of the C51, C251, or C166 tool chains. C51 Evaluation Software Limitations:
The compiler, assembler, linker, and debugger are limited to 2 Kbytes of object code but source Code may be any size. Programs that generate more than 2 Kbytes of object code will not compile, assemble, or link the startup code generated includes LJMP's and Page | 55
SOLAR TRACKING SYSTEM cannot be used in single-chip devices supporting Less than 2 Kbytes of program space like the Philips 750/751/752. . . . . The debugger supports files that are 2 Kbytes and smaller. Programs begin at offset 0x0800 and cannot be programmed into single-chip devices. No hardware support is available for multiple DPTR registers. No support is available for user libraries or floating-point arithmetic.
. . .
The u vision2 debugger provides complete simulation for the CPU and on chip peripherals of most embedded devices. To discover which peripherals of a device are supported, in u vision2. Select the Simulated Peripherals item from the Help menu. You may also use the web-based device database. We are constantly adding new devices and simulation support for on-chip peripherals so be sure to check Device Database often.
APPENDIX C
C.1 CODE
#include <reg52.h> #include<lcd.h> #include<intrins.h> #define DELAY _nop_(); sbit sbit sbit sbit CLK = DOUT= DIN = CS = P2^5; P2^4; P2^3; P2^2;
sbit m1=P2^0; sbit m2=P2^1; sbit s1 = P2^6; sbit s2 = P2^7; sbit pin = P1^0; float adc_convert (void); void float_lcd(float f); unsigned char byte_write_read(unsigned char); void select_channel(void); float t; unsigned int i,j,range=0; unsigned char channel,A,C; void stop() { m1=m2=0; } void left() { m1=0; m2=1; } void right() { m1=1; m2=0; } void TEMP() { t=0; i=0; channel=i; t=t+adc_convert(); t=t*1; }
float adc_convert (void) { // variables declaration unsigned char byte0,byte1,byte2; int i; float val; CLK=0; CS=1; CS=0; select_channel(); byte0=byte_write_read(A); byte1=byte_write_read(C); byte2=byte_write_read(0x00); CS=1; i=(byte1&0x0f); i=((i<<8)|byte2); val=(i*4.096)/4096; return val; } unsigned char byte_write_read (unsigned char a) { unsigned char c=0,mask=0x80; do { CLK=1; //delay_us(500); delay_ms(1); if(a&mask) DIN=1; else DIN=0; CLK=0; //delay_us(500); delay_ms(1); if(DOUT==1) c|=mask;