20
Ultrasonic Illuminance Detector December 3, 2015 EE 449 California Polytechnic State University Written By: Gerardo Sevilla, David Avila, Bret Omsberg

Ultrasonic Illuminance Detector

Embed Size (px)

Citation preview

Page 1: Ultrasonic Illuminance Detector

Ultrasonic Illuminance Detector

December 3, 2015 EE 449

California Polytechnic State University

Written By: Gerardo Sevilla, David Avila, Bret Omsberg

Page 2: Ultrasonic Illuminance Detector

Introduction: The ability to measure natural phenomenon has been a key advancement in human technology in the last century and has been key to advancements in nearly every scientific field. The system that was designed here builds off of this technology to improve the accessibility of the data. This particular system can measure the particular illuminance of a room or area, deliver it via a communication link to an liquid crystal display depicting the illuminance in foot candles. Illuminance detectors can be found in a variety of devices including darkness detecting circuits in night lights. One particular use of this device could be used for porch lights. On some houses and apartments, the porch light may be under a roof where normal darkness detecting circuitry would prove inadequate. This is where the wireless communication link would come in very handy. The illuminance detector could be placed in an area with a lot of sunlight, when the foot candle reading reaches below a certain point, the porch light could be turned on wirelessly. Another key feature of this device is that the detecting circuitry is powered from a nine volt D­battery. This is a key feature for this particular application because it needs to be versatile in terms of where it can be placed. An indirect feature of this product is energy efficiency. This can be attributed to the feature that controls whether the light is on or off instead of relying on human intervention to turn off the light during the day. This feature, over the long term, could actually pay for the device in energy savings alone. Product Specifications: This device was designed to output the illuminance in foot candles. The range of measurement will be from five to 200 foot candles. The device must be able to transmit over a ultrasonic link at 40 kHz and display the foot candles on a display with less than five percent error. The reading in a room with ambient light of 13 foot candles measured with a commercially available foot candle meter. This system measured the same ambient light at 14 foot candles, making the error less than 5%. The link distance goal between the two links was specified at 10 meters. This device was only able to transmit up to 20 feet. The transmitter current draw was measured at 14 mA, when the microprocessor and receiver was measured at 48 mA. The overall power used by the system was 558 mW. With the 9V battery used the device would run for about 40 hrs on the transmitter side and about 9hrs on the receiver side.The resolution of the display was a maximum of 5 stable digits at lower light intensity. As the intensity increases, instability of the frequency measurement causes instability in the current and foot candle measurements. A drawback of this microprocessor was the update rate. As the

Page 3: Ultrasonic Illuminance Detector

frequency increased, the time it takes to output a stable measurement increases. This issue could be resolved with a different microprocessor clocked at a higher rate. High­Level System Description:

Figure 1: High­Level Block Diagram of Entire System

Figure 2: Transmitter System Block Diagram

Figure 3: Receiver System Block Diagram

Page 4: Ultrasonic Illuminance Detector

A high­level system diagram of the illuminance detector is shown in Figure 1. The first block is the photo detector. This block takes light as an input and outputs a certain amount of current proportional to the light intensity. This current is this inputted into the transmitter block where the current will be converted into a modulated signal that will be passed through the ultrasonic link to the receiving block. The receiving block prepares the signal for the microprocessor by amplifying and passing only the frequency range of the transmitter. With the signal amplified, it can then be inputted into the microprocessor. This block measures the frequency of the input signal and outputs the illuminance measured in foot candles to the display for the user. This last block could be altered depending on the application. For the porch light application, the display would be changed to a switch that would control whether the light was on or off. Functionality Photodiode, Current Amplifier:

Figure 4: Photodiode and Current Amplifier Circuitry

Material List:

1 SFH 2430­Z ­ Photodiode 1 LMC662 dual, MOSFET rail­3­rail 1 9kΩ Resistor 1 3kΩ Resistor

Page 5: Ultrasonic Illuminance Detector

The schematic in Figure 4 shows the current amplifier bootstrapped by a current source that is used to model a photodiode. When incoming light in the form of photons strikes the silicon surface of the photodiode, the added energy causes electrons to flow creating an electric current. Since this current is a very small amount, current amplification is necessary for proper operation. This topology was also chosen because of the oscillator is controlled by current. The ratio of the resistors creates the gain of the current. This can be seen by applying the virtual short across the terminals of the op amp to find that that the two resistors are virtually in parallel. What this means is that whatever voltage is applied across R1 will also be seen across R2. The photodiode current source can also be shown to control the current through R1 which will set the voltage drop across R2 allowing for simple calculation to attain a desired amount of gain. Current to Frequency Converter:

Figure 5: Current­to­Frequency Converter

Material List: 1 ICM7555 IPAZ ­ 555 timer 1 NCP431AILPRAG 1 1kΩ Resistor 1 100nF Capacitor

Page 6: Ultrasonic Illuminance Detector

Figure 5 shows the topology for converting current to frequency. This is done by using the current amplifier with the photodiode shown above, modeled as the current. The corresponding frequency of oscillation created by the 555 timer can be estimated with the equation below:

fosc = 2 I*V c C*

The frequency of oscillation can be determined through the charge current supplied from the current amplifier. The output of the 555 timer will later be used to generated the amplitude shift keying for the transmitter that will encode the illuminance detected by the photodiode. As the illuminance increases, so will the frequency of oscillation controlling the switch. Modulator:

Figure 6: Modulator Schematic

Material List: 1 HCF4016B

The circuit in Figure 6 was simulated with the CD4066 which is an analog switch. The part that was used for the realized design was a quad bilateral switch with very similar operation to the CD4066. The 40 kHz oscillator will either be passed through to the transmitter amplifier when the 555 timer outputs a high signal and will pass nothing when the 555 timer is low. The 555 timer, controlled via the photo amplifier, will control the modulation that will be transmitted across the ultrasonic link to the receiver. Amplitude shift­keying is the form of modulation used for the encoding of the foot candles. ASK modulation represents digital data by modulating the carrier signal either high or low at a fixed amplitude and frequency. ASK modulation is implemented in this design via the switch. A binary one is outputted with the presence of a carrier signal and binary zero for the absence of the carrier signal.

Page 7: Ultrasonic Illuminance Detector

Figure 7: Simulated Output of the Modulator

The simulated response of the modulator shown in Figure 7. In this case, the pulse is a 50% duty cycle square wave with a frequency of 1 kHz. The simulation was measured to have a frequency of 998 Hz using the cursors.

Figure 8: Response of Modulator, crystal oscillator and 1 kHz Square wave Generator

Page 8: Ultrasonic Illuminance Detector

The modulator and oscillator system were then implemented together. Figure 8 shows the response with a 1 kHz square wave as previously shown in the simulation. This frequency is used for testing purposes due to the photodiode and amplifier having a similar frequency. This figure shows that there is relatively little error between the input square wave frequency and the output waveform as the output waveform was determined to be 980 Hz using the cursors function on the oscilloscope. Crystal Oscillator:

Material List: 1 ECS­.400­12.5­13 Crystal Oscillator 1 CD4069UB IC 1 10MΩ Resistor 1 150kΩ Resistor 1 22pF Capacitor 1 18pF Capacitor

The oscillator circuit shown in Figure 9 is an equivalent circuit to the crystal oscillator operating at 40kHz. The equivalent circuit was determined through consultation with the crystal oscillator’s datasheet.

Figure 9: Schematic showing crystal oscillator equivalent circuit used to simulate design This circuit shows the configuration of the crystal oscillator circuit in open loop form

The phase and magnitude response can be seen in Figure 10. This graph shows that right around 40 kHz, the frequency at which the circuit should oscillate, has very little phase shift and a gain of over unity is achieved. The reason this is important is due to Barkhausen stability criterion which states the magnitude needs to be greater than or equal to unity and the phase shift has to be a multiple of 2π in order to have steady­state oscillation of the system.

Page 9: Ultrasonic Illuminance Detector

Figure 10: Magnitude and Phase Response to the Oscillator Equivalent Circuit

Magnitude and Phase response of the Open­Loop circuit showing the conditions of the circuit at the desired frequency

The major difference between the simulation and the realized circuit is that the simulation requires a jump start in order to actually oscillate. In figure 11 the transient response of the system is shown. The simulation requires an initial condition to placed on a capacitor in order to generate the oscillation. This can be easily seen by noticing that the waveform doesn’t appear to oscillate until about three seconds into the simulation.

Figure 11: Time Response to Equivalent Oscillator Circuit

The time response of the crystal oscillator based on the closed loop oscillator circuit

Page 10: Ultrasonic Illuminance Detector

Comparing the time response of the simulation to the time response of the realized oscillator, the actual oscillator takes nearly no time to generate a sinusoidal, 40 kHz signal with no initial voltage charge on a capacitor or a tail current source. The realized open­loop response can be seen in Figure 12. The measured frequency of the waveform was 39.9983 KHz, well within the specification of the design.

Figure 12: Realized Open­Loop Response of the Crystal Oscillator

Input and output of the crystal oscillator in open loop form

The waveform shown in Figure 13 shows the closed­loop time response of the crystal oscillator. This shows that the circuit will oscillate in either open­loop or closed­loop configuration and will maintain the correct frequency in both cases as the closed­loop frequency was measured to be 39.9986 KHz. This value was determined by using a digital multimeter to probe the output of the crystal oscillator. This value is also in agreement with the open­loop response as well as the frequency calculated via the oscilloscope shown in the figure below.

Page 11: Ultrasonic Illuminance Detector

Figure 13: Closed­Loop Response of Crystal Oscillator Output of the Crystal Oscillator in closed loop form

With the oscillator’s operation verified, the power needed to drive this oscillator was then determined. This was calculated by measuring the root mean square (RMS) voltage across the shunt capacitor. This was calculated using the following formula:

Vrms = 1.548 V (Measured using Digital Multimeter) Irms = = 1.548/2.21*10^5 = 6.8uAXc

V rms Power = = 6.8uA2 *150k = 6.94uW Irms2 * R

f = 1

2π√LC 40kHz = 1

2Π√L 3 10* * −15

L = 5.28kH Q = = (40kHz * 5.28kH)/(35kΩ) = 6.034*103wL

(R)

Bandwidth = Δf = = (40kHz)/(6.034*10^3) = 6.63 HzQfc

Figure 14 shows how each component of the crystal oscillator equivalent circuit was determined. Most of the component values are determined by the manufacturer or have a set range in which the component must fall between. The inductor in this circuit is dependent on the frequency of the oscillation and the series capacitance of the oscillator. This value was determined to be 5.28kH which is an extremely large inductance and could only be used in simulation.

Page 12: Ultrasonic Illuminance Detector

Figure 13: A Portion of the Crystal Oscillator Equivalent Circuit Component Values

The equivalent circuit elements for the crystal oscillator circuit

Ultrasonic Driver and Transmitter Transducer:

Material List: 3 CD4069UB IC 1 40TR12B­R Transmitter 1 100kΩ Resistor

The goal of the power amplifier is to provide a gain of greater than one and a phase of zero. This power amplifier has better power deliverance to the transmitter due to the low amount of attenuation from other resistors. The 100k resistor is effectively a pull­up resistor that provides additional current from VCC. This current will then be inverter and then delivered to the load which is the transmitter with little voltage drop from input to the load allowing a greater amount of power to be delivered to the load.

Figure 15: Power Amplifier for the Ultrasonic Transmitter

Page 13: Ultrasonic Illuminance Detector

The amplifier shown in Figure 15 is used to amplify the modulated signal coming from the modulator. This signal needs to be amplified due to the effects of attenuation across the ultrasonic link. If the signal was not amplified, the receiver may not be able to detect the signal.

Figure 16: Modulator interfaced with Power Amplifier

The modulator was interfaced with the power amplifier for testing purposes. The inputs to the modulator were synthesized with a pulse input acting as the 555 timer and a 40 kHz sine wave acting as the oscillator. The simulated response of this system can be seen in Figure 17. When the input signal goes low, the inverters of the amplifier cause the output to go high. The constant amplitudes in the waveforms create the frequency of the waveform that is produced from the 555 timer which corresponds to the illuminance delivered to the photo amplifier.

Page 14: Ultrasonic Illuminance Detector

Figure 17: The Output Response of the Modulator and Power Amplifier

Receiver Amplifier and Receiver Transducer Material List:

2 LM358NG Op­Amp 1 300pF Capacitor 5 10kΩ Resistors 2 18kΩ Resistors 1 50kΩ Resistor 1 100kΩ Resistor

Page 15: Ultrasonic Illuminance Detector

Figure 18: Bandpass Amplifier Schematic

The final design of the Bandpass Amplifier centered around 40 kHz. Designed using a two stage Op­amp Amplifier

The circuit designed for the receiver is shown in figure 18 in which a two non­inverting amplifiers are used to achieve the desired gain of 50. The use of two amplifiers was used in order to obtain the desired bandwidth range of the entire amplifier. The 10k resistor and the 300pf capacitor were used to create a low pass filter stage before the next stage as the entire amplifier also had to have bandpass capabilities. A high pass filter was not necessary as the circuit would naturally filter out the higher frequencies. The resistor values chosen for the first stage gave the first stage a gain of 10 making the second stage requiring a gain of about 5 due to the cascading effect of amplifiers. Finally the 18k resistor at the end represents our load which in our case would be the input to the Tone Decoder.

Page 16: Ultrasonic Illuminance Detector

Figure 19: Simulation of Bandpass Amplifier with 33dB Gain at 40kHz

The specification for this system was to 34 dB plus or minus 1 dB. This design meets specification at 40 kHz due to the gain of the system to be right around 33 dB.

The simulation of the bandpass amplifier, shown in Figure 19, shows the appropriate gain at 40 kHz to deliver a readable signal for the tone decoder and is within the 34 1± dB of the specification for the design.

Tone Decoder Material List:

1 LM567 Tone Detector 1 67YR5KLF Potentiometer 1 2nF Capacitor 4 10nF Capacitors 1 100nF Capacitor 1 12kΩ Resistor

Page 17: Ultrasonic Illuminance Detector

Figure 20: 40 kHz Tone Decoder Schematic

The Final design of the tone decoder for the desired response

Developing the design for the tone decoder involved choosing resistors and capacitors that would create the frequency tracking response closely centered around the 40 kHz range. When the tone decoder was first being modified and capacitors were added, the capacitance chosen was in the microfarad range which resulted in a very slow locking process. Reducing the capacitor values on the output filter and loop filter pins to nanofarads in magnitude fixed this issue; what took tens of cycles to accomplish now merely took a few cycles as shown in Figure 6. The 12 kΩ resistor coupled with the 2nF capacitor needed a time constant that would match the center frequency of 40 kHz, while the output filter capacitor had to be at least twice as great as the loop filter capacitor to generate the proper output waveform.

Page 18: Ultrasonic Illuminance Detector

Figure 21: Simulation of Tone Decoder with Both 40kHz Input and Output Simulation depicting Locking Functionality of the tone decoder

When the tone decoder system senses a 40 kHz signal, the output goes from high to low. The system takes approximately 2.5 waveform cycles to change its state. Table 1 shows that the bandwidth where the system latches onto the input frequency has a magnitude of about 5.1kHz. The bandwidth where the system drops its tracking is 4.8 kHz.

Left frequency at which system loses its “lock­on” (Hz)

Right frequency at which system loses its “lock­on” (Hz)

Entering Center Frequency Range

37.4k 42.5k

Leaving Center Frequency 37.2k 42k

Table 1: Systems Left and Right Input Frequency Tracking Ranges The frequencies of the tone decoder when the output value changes depending on the

direction of frequency sweep into or out of the central frequency

Page 19: Ultrasonic Illuminance Detector

Microprocessor Material List:

Arduino REV 3

Figure 21: Signal Frequency Measurement Flowchart

The accuracy of this code for frequency measurement is dependent on the clock utilized for measuring the time elapsed, in this case the internal 16 MHz clock, during the input signal’s cycle. A higher clock frequency will result in better accuracy since the measured time will have a finer cutoff. Frequency Measurement Code: #include <FreqMeasure.h> #include <LiquidCrystal.h> LiquidCrystal lcd(7, 6, 5, 4, 3, 2); void setup() Serial.begin(57600); lcd.begin(8, 2); FreqMeasure.begin(); double sum=0; int count = 0; double fc = 0; double diodeCurrent = 0; void loop() if (FreqMeasure.available()) sum = sum + FreqMeasure.read(); count = count + 1; if (count > 30)

Page 20: Ultrasonic Illuminance Detector

float frequency = FreqMeasure.countToFrequency(sum / count); lcd.setCursor(0,1); lcd.print(frequency); lcd.print(" "); lcd.setCursor(7,9); fc = frequency*3.38; lcd.print(fc); lcd.setCursor(1,0); diodeCurrent = 128*frequency; lcd.print(diodeCurrent); sum = 0; count = 0; Conclusion: The project specifications were met meeting the design criteria but the functionality could be improved. The approach to the transmission and reception side of this project could benefit from a review since it can lead to noise easily interfering with transmission distance. Another form of modulation and an improved amplifier can help propagate the signal better and in turn enlarge the operation distance; the current operational distance is 20 ft falling below the product specification of 30 ft. The manufacturability concerns with this project on a massive scale would be the cost of the microcontrollers which directly results in an increased cost for the consumer. Possible sustainability concerns are the battery charge deterioration affecting normal operation. One weak link in design is the code used to read the frequency of the received signal which takes approximately 5­10 seconds to display the correct frequency. An improvement that could be made to the code is to use the reciprocal frequency measurement method instead of the built in edge counter function in the Arduino IDE library. A more clever algorithm for the frequency measurement, which corresponds to an accurate frequency, photodiode current and foot candle measurement greatly improves both the functionality and practicality of this project for the consumer.