Trace:
Differences
This shows you the differences between the selected revision and the current version of the page.
group1:group1start 2008/12/12 03:47 | group1:group1start 2008/12/12 09:53 current | ||
---|---|---|---|
Line 63: | Line 63: | ||
- | ==== 2.2 Modulating Circuit ==== | + | ==== 2.2 Modulated Frequency Generator Circuit (MFGC) ==== |
+ | The MFGC is the sub circuit which effectively modulates the infrared light to be received by the receiver. It was interpreted at first that the receiver could comprehend a constant flow of 38kHz modulated light, however upon further examination of its specifications sheet, it was observed that the light needed to exist within an envelope frequency that was high for the equivalent time of anywhere between 10 and 70 pulses of 38kHz light, and low for a minimum of time of 10 pulses of the same light. The modulated input that needed to be produced can be observed in the previous figure. | ||
+ | |||
+ | The ultimate responsibility of the MFGC is to modulate the light to produce a similar output as observed above. To accomplish this, the use of two 555-timer astable multivibrator circuits was necessary. An astable multivibrator oscillates between two stable states; in this case these was a positive voltage of about +6.5V and a voltage of 0V. The +6.5 comes from the option to use four AA batteries to power the circuit, each with a voltage of +1.5V. See below for the MFGC schematic. | ||
+ | |||
+ | |||
+ | {{:group1:oscillator_circuit_diagram.jpg|}} | ||
+ | |||
+ | As observed above, the first stage of the MFGC creates the envelope frequency required by the IR receiver as mentioned above. The carrier frequency of 38kHz is created by the second stage of the amplifier. The frequency output of each of the stages is determined by the resistor combinations R1 and R2 for the first stage, and R3 and R4 for the second stage. R5, present on the second stage, is responsible for trimming the rise and fall time of the 38kHz output, so that it creates steeper rise and fall times, essentially making the square wave more square-shaped and less slanted. For calculation of the frequencies in each stage observed in the MFGC, analysis of the general output of an astable multivibrator was required (See Below). | ||
+ | |||
+ | {{:group1:theoretical_output.jpg|}} | ||
+ | |||
+ | Where t1-t0 is the time that the output is high, and t2-t1 is the time that the output is low, and Vcc is the supply voltage – this is +6.5 volts in this case. These times are calculated using the following formulae: | ||
+ | |||
+ | (1) t1-t0 = (Ra + Rb)(C)(ln2) | ||
+ | |||
+ | (2) t2-t1 = (Rb)(C)(ln2) | ||
+ | |||
+ | Where RA and RB are resistors R1 and R2, and R3 and R4, for the first and second stages, respectively. C is the capacitor observed at C12 for the first stage and C2 for the second stage in the MFGC. | ||
+ | |||
+ | In the case of the envelope frequency, the time that the output is high, given by equation (1), was found to be 7.19E-4 s, which is equivalent to the time taken for about 51 pulses of 38kHz light to pass. The time determined by equation (2), or the low time, was calculated to be 6.26E-4 s, or the equivalent time of 24 pulses of 38kHz light low. Thus, the envelope allowed for 51 pulses of 38kHz light to be output, with a rest time equivalent to the length of time needed to output 24 pulses. As the 51 pulses high was within the 10 to 70 pulse window, and the 24 pulses low was greater than the minimum 10 pulse rest time, it was evident that this circuit would allow for a proper output. The resistor values at R1 through R5 were all designated as potentiometers so that both the envelope and the carrier frequencies can be tuned to their precise windows of operation. Fixed resistors could have changed their resistances through excessive testing as well as temperature changes in the external environment, however with potentiometers, if any changes in resistance were to occur due to the previously mentioned factors, each potentiometer can be adjusted until the desired wave form is recovered. Thus to ensure optimal success of creating the two necessary frequencies, it was justified to use potentiometers. The capacitor values attached to each stage were arbitrarily chosen and the subsequent potentiometer values were adjusted based on these selections. | ||
+ | |||
+ | The final output through the second stage and into the LEDs was used to bias the base of two NPN BJTs to allow for maximum voltage and current flow into the LEDs to increase their output intensities. The use of a 2.7kΩ “pull-up” resistor was necessary to add current to the output signal for better biasing purposes, while the 15kΩ “pull-down” resistors were used to limit the voltage into the LEDs so that they did not burn out. The voltage sources contained both two capacitors surrounding them as to negate the effects of any transient AC ripple voltages coming from the DC input of +6.5 volts. This ensured a clean DC supply was powering the circuit. | ||
+ | |||
+ | The simulated output of the MFGC can be observed in the following figure, and echoes the test input for the IR receiver, observed as the "Test Output" figure above. Note that the red signal is the modulated output of the second stage which exits through the LED, and the blue signal is a measurement of the envelope frequency, which outlines the groups of 38kHz pulses in the red signal. | ||
+ | |||
+ | {{:group1:oscillator_circuit_theoretical_output.jpg|}} | ||
+ | |||
+ | |||
+ | |||
+ | ==== 2.3 Comparator Circuit as Receiver/Demodulator ==== | ||
+ | |||
+ | This sub circuit contains the IR receivers which receive the modulated light from the MFGC. The output of the IR receivers can be observed in the second half of theoretical output diagram above defined by the IR receiver, where it is observed that for the time that the envelope frequency is high, the output of the receiver is low, and for the time that it is low, the output of the receiver is high. The output of the IR receivers is essentially a square wave with a high pulse equal in magnitude to the low pulse of the envelope frequency of the MFGC. The RDC can be observed in the following figure. | ||
+ | |||
+ | {{:group1:receiver_circuit.jpg|}} | ||
+ | Receiver Circuit | ||
+ | |||
+ | The square wave output from the receivers were too difficult to analyze within the microcontroller. Therefore the addition of the demodulator circuit was necessary in the later creation time of the project. The demodulator circuit, observed above as a PNP BJT, a 1μF capacitor, two 1kΩ resistors, and a comparator, acts to change the square wave output into a constant high voltage. Initially, if the beams were to be blocked, the square wave output would merely change frequency, however, with the addition of the demodulator circuit, the final output into the microcontroller would be a constant high voltage which only dropped low if the beam were to be blocked. This allowed for much simpler analysis. | ||
+ | |||
+ | To convert the square wave into a constant high voltage, the demodulator circuit takes the square wave and biases the BJT. Upon doing this, the capacitor is able to charge and discharge periodically within a given voltage window. This capacitor wave form is fed into the positive input of the comparator. In the negative input, a threshold, constant DC voltage is applied. When the circuit is not blocked, the wave form of the capacitor does not drop below the threshold voltage and therefore the output of the comparator remains high. Once the beam is crossed, the capacitor wave form drops below the threshold and causes the output of the comparator to switch to low. This is illustrated in the following figure. | ||
+ | |||
+ | {{:group1:comparator_inputs.jpg|}} | ||
+ | Inputs of the Comparator | ||
+ | |||
+ | The jagged wave form in the above figure is the output of the capacitor which is the first input of the comparator. The second input of the comparator is the observed DC voltage at roughly +1.14 volts. Upon crossing the IR beam, the square wave output of the receiver changes frequency, which in turn causes the capacitor to discharge below the previously mentioned threshold voltage. At this point the output on from the comparator switches from high to low. This corresponding output can be viewed as follows. | ||
+ | |||
+ | {{:group1:receiver_circuit_theoretical_output.jpg|}} | ||
+ | Receiver Output to Microcontroller | ||
+ | |||
+ | The output seen above is placed into the input of the microcontroller. It is a constant high output until the beam is blocked, where it switches to low. This event is much more easily analyzed by the microcontroller than the square wave. The demodulator circuit is replicated for the second IR receiver output. The comparators used were actually part of a quad comparator integrated circuit provided by Glen Leinweber. | ||
+ | |||
+ | Again, the DC sources have filter capacitors on them to remove any transient AC ripple voltages. Four AA batteries are used to power this circuit as well. | ||
- | ==== 2.3 Comparator Circuit ==== | ||
==== 2.4 Microcontroller System ==== | ==== 2.4 Microcontroller System ==== | ||
- | The 20-pin 8-bit PIC16F690 microcontroller was selected for use in the final design. The key features of the PIC for this design were the interrupt-on-change feature in Port A, and the timer1 overflow interrupt, both of which will be described below. The microcontroller also contained an internal clock and inverter, reducing external components and greatly simplifying the microcontroller circuit. This PIC was easier to work with and debug compared to larger PICs considered for the design. The pin and circuit diagrams can be seen below. | + | The 20-pin 8-bit PIC16F690 microcontroller was selected for use in the final design. The key features of the PIC for this design were the interrupt-on-change feature in Port A, and the timer1 overflow interrupt, both of which will be described below. The microcontroller also contained an internal clock and inverter, reducing external components and greatly simplifying the microcontroller circuit. This PIC was easier to work with and debug compared to larger PICs considered for the design. The pin and circuit diagrams can be seen below [1]. |
{{:group1:pic16f690_pin_diagram2.jpg|}} | {{:group1:pic16f690_pin_diagram2.jpg|}} | ||
Line 78: | Line 128: | ||
The final code was designed in accordance with the modified scope, therefore it assumed that the object was a pedestrian, and under this assumption could determine their speed and direction, and log the data into a text file. The program works in the following manner: | The final code was designed in accordance with the modified scope, therefore it assumed that the object was a pedestrian, and under this assumption could determine their speed and direction, and log the data into a text file. The program works in the following manner: | ||
Within the main function there are two interrupts: ‘timer1interrupt’ and ‘extinterrupt’. An interrupt is a function outside of main that is called only under specific circumstances. ‘Timer1interrupt’ is called whenever timer1 overflows, and ‘extinterrupt’ is called every time there is a falling edge, as seen in Figure 8. | Within the main function there are two interrupts: ‘timer1interrupt’ and ‘extinterrupt’. An interrupt is a function outside of main that is called only under specific circumstances. ‘Timer1interrupt’ is called whenever timer1 overflows, and ‘extinterrupt’ is called every time there is a falling edge, as seen in Figure 8. | ||
- | Timer1 was programmed to increment once every eight microseconds by setting the internal clock to 4Mhz and the prescaler to 8. A prescaler of eight indicates that the clock will increment once every 32 cycles. | + | Timer1 was programmed to increment once every eight microseconds by setting the internal clock to 4Mhz and the prescaler to 8. A prescaler of eight indicates that the clock will increment once every 32 cycles [2]. |
Time in increment= [increments per cycle]/ [frequency] | Time in increment= [increments per cycle]/ [frequency] | ||
Line 107: | Line 157: | ||
* output velocity | * output velocity | ||
- | A trial version of CCS PCW C Compiler was used to compile the code, and the PICC C Plus program available in the lab was used to program microcontroller. The segmented code can be seen in the figures below. | + | A trial version of CCS PCW C Compiler was used to compile the code, and the PICC C Plus program available in the lab was used to program microcontroller. The segmented code can be seen in the figures below. |
+ | |||
+ | {{:group1:maincode.jpg|}} | ||
+ | {{:group1:externalinterruptcode.jpg|}} | ||
+ | {{:group1:timer1interruptcode.jpg|}} | ||
+ | |||
+ | |||
+ | [1]PIC16F690 Datasheet, Microchip, http://ww1.microchip.com/downloads/en/DeviceDoc/41262E.pdf (accessed September 2008). | ||
+ | |||
+ | [2]Dubuc, Martin. “Programming Tips.” http://mdubuc.freeshell.org/Robotics/Tips.html (accessed October 2008). | ||
+ | |||
Line 125: | Line 185: | ||
==== 3.2 Electronic Proof-of-Principle ==== | ==== 3.2 Electronic Proof-of-Principle ==== | ||
+ | The initial electronic PoP consisted of a multisim simulation of the MFGC and receiver circuit, and an explanation of the microcontroller. As the parts for the circuit had not arrived yet, the analog portion had not been built and the programming of the microcontroller was still in development. An explanation of the interrupts was given for the microcontroller and how they would be used to observe when the beam was blocked. However, this was under the assumption that a square wave input would be used for the microcontroller, and not the simpler DC signal. Thus, it was too difficult to implement all the ideas in the electronic PoP as later modifications to the circuit proved that an entirely different microcontroller with new code would be used. | ||
+ | |||
+ | Given the chance to present later on, the completed MFGC circuit was demonstrated and powered with batteries to transmit an IR signal across the lab to be received and observed on an oscilloscope. This pseudo-PoP allowed the group to demonstrate that the analog components were able to be constructed in accordance with the Multisim schematic, and that it could be powered using batteries. Also, the microcontroller was programmed to output “Leigh”, indicating a beginning understanding on how to place code on the microcontroller and use it to perform operations. Overall, the electronic PoP mainly proved the validity of the then-existing circuit and microcontroller combination. | ||
===== 4. Final Completed Product Description ===== | ===== 4. Final Completed Product Description ===== | ||
+ | |||
+ | The MFGC, the RDC and the DPC as described in the final design can be observed in the following figures. | ||
+ | |||
+ | {{:group1:p4.jpg|}} | ||
+ | Modulated Frequency Generator Circuit | ||
+ | |||
+ | {{:group1:p5.jpg|}} | ||
+ | Comparator Circuit as Receiver/Demodulator | ||
+ | |||
+ | {{:group1:p6.jpg|}} | ||
+ | Microcontroller Circuit | ||
+ | |||
+ | As observed in the above figures, the entire circuit fit onto five bread boards. In the figure depicting the RDC, it is important to note that the quad comparator is set to receive three inputs. This is due to the initial design of three beams. However since one of the receivers malfunctioned, only two of the inputs were used, however the third input with the corresponding third demodulator circuit, was left on the bread board. The output from the second stage of the larger circuit in the MFGC screenshot, is also used to bias the base of the BJT in the smaller circuit of the same diagram. Two separate IR receivers were used. One was the ordered receiver from Digikey. Originally, it did not function properly, as it lost its signal from time to time. However during the testing of it implemented with the demodulator circuit, it always kept a constant output when receiving a signal. The second receiver, observed in the DPC figure, comes from an old ENG PHYS 4A06 project, and also receives light modulated at 38kHz. A visible LED is present in combination with a parallel resistor in the above figure to allow for a voltage step down from the +6.5V supply, so that the microcontroller can be powered with about +5V without being damaged. Also note the numerous electrolytic capactiors present in all three circuits, used to filter out transient AC noise from the power supply. | ||
===== 5.Final Demonstration of Completion ===== | ===== 5.Final Demonstration of Completion ===== | ||
Line 153: | Line 229: | ||
The allocated budget for the project was $200 CDN, including all component, construction and shipping costs. The following table is a comprehensive list of all components used in the completed product and their individual costs. Components that were used but not ordered are marked by an asterisk(*). | The allocated budget for the project was $200 CDN, including all component, construction and shipping costs. The following table is a comprehensive list of all components used in the completed product and their individual costs. Components that were used but not ordered are marked by an asterisk(*). | ||
+ | |||
+ | ==== Parts Used ==== | ||
+ | {{:group1:revised_budget.jpg|}} | ||
+ | |||
+ | |||
+ | ==== Parts Ordered But Not Used ==== | ||
+ | {{:group1:revised_budget-_parts_not_used.jpg|}} | ||
+ | |||
+ | The oscillator was purchased in anticipation of using it with the PIC16F877 microcontroller. The potentiometer was never utilized because a more applicable one was obtained from the Lab Technician. There was only one damaged part: a receiver was burnt during testing because it was put in the circuit the wrong way. | ||
+ | |||
+ | As shown in the tables and discussions above; the project stayed well within budget, including any components that were purchased but not implemented in the final design. | ||
+ | |||
+ | |||
You are here: start » group1 » group1start