LVDT Oscillator/Demodulator Design and Build ECE 4902 – Senior Design II Team 181 May 2, 2014 Final Report Team Members: Ryan Williams (EE) Damon Soto (EE) Jonathan Wolff (EE) Jason Meyer (EE) Faculty Advisor: Helena Silva (hsilva@engr.uconn.edu) Trans-Tek Contacts: Mark Bennett (mbennett@transtekinc.com) Jeffrey Gladu (jgladu@transtekinc.com) 2 Table of Contents [1] Abstract………………………………………………………………………………. 3 [2] Background…………………………………………………………………………... 3 [3] Project Specifications [3.1] General Requirements…................................................................................ 4 [3.2] Oscillator…………………………………………………………………… 4 [3.3] Demodulator………………………………………………………………... 4 [4] Methods [4.1] Oscillator…………………………………………………………………… 5 [4.2] Demodulator…………………………………………………………………6 [4.3] PCB Design………………………………………………………………… 8 [5] Final Design [5.1] Oscillator…………………………………………………………………… 9 [5.2] Demodulator………………………………………………………………..10 [5.3] PCB Design……………………………………………………………….. 11 [5.4] Overall System……………………………………………………………. 12 [6] System Results [6.1] Oscillator………………………………………………………………….. 13 [6.2] Demodulator………………………………………………………………. 13 [7] Discussion………………………………………………………………………….. 14 [8] Timeline…………………………………………………………………………….. 15 [9] Budget………………………………………………………………………………. 15 [10] Conclusions and Future Work……………………………………………………... 15 [11] Appendix [11.1] Demodulation Algorithm……………………………………………….. 17 [11.2] C Code for ATtiny85……………………………………………………. 18 3 [1] Abstract Linear variable differential transformers (LVDTs) are high-precision, robust position and velocity sensors. They are used in high-pressure, high-temperature, industrial applications worldwide. AC inputs and outputs require the addition of oscillator/demodulator devices for use with DC power in some LVDTs. An internal oscillator/demodulator device was designed and built. The oscillator produced a range of 1.5-12.5kHz, 1-6V RMS sinusoidal output, but failed to drive the LVDT. The demodulator was designed using a microcontroller and digital signal processing (DSP). DC output voltage ranges of 0-5V, 0-10V, 0.5-4.5V, and 0.5-9.5V were achieved. An algorithm was developed and tested, but failed to function due to issues with the analog to digital conversion in the microcontroller. [2] Background As technology has improved dramatically over the past few decades, the demand for accurate and reliable measuring devices has also increased. Trans-Tek is a company that focuses on measuring devices, and has a strong reputation for making reliable and accurate linear variable differential transformers (LVDTs). Our project will focus on the combination of these LVDTs, with an oscillator/demodulator circuit. It is paramount to understand these devices and their purpose to fully understand the project at hand. LVDTs, also known as differential transformers, are electrical transformers that measure linear displacement. This robust device converts a linear displacement signal into an electrical signal. This information contains the direction and amplitude of that signal. It is important to note that the linear displacement signal is referenced off a “null position” or “zeroed” position (mechanical reference). The reason it is said that these devices are so reliable is because there is no electrical contact between the core assembly and the coil. Signals observed from the LVDT depend upon the electromagnetic coupling between the stationary coil and core assembly. This allows the device to survive in extreme heat or cold temperatures. The oscillator/demodulator device works side by side with the linear variable differential transformers. It is a signal-altering tool that introduces a signal at a certain frequency to a displacement probe. The output produced by that probe is demodulated, which yields output signals that are relational to the average and dynamic gap distances of that specific probe. The combination of these devices allows one to obtain a signal and alter it, yielding a set of useful and accurate data. Figure 1: The model and function of an LVDT Source: http://upload.wikimedia.org/wikipedia/commons/0/07/Lvdt_how.gif 4 [3] Project Specifications The design proposed by Trans-Tek was given with the following specifications: [3.1] General Requirements Oscillator/demodulator on flexible PCB to fit into 0.7” diameter tubing, length T.B.D. Input voltage 11.5V DC to 30V DC internally regulated Reverse polarity protection Surface mount components, preferably SOIC or smaller Preferably a DSP IC (if not plausible for demodulator try a RMS to DC converter All programming to be fully documented and commented [3.2] Oscillator Sinusoidal waveform Total harmonic distortion less than 1% Amplitude stability best effort (<5% error) Frequency stability best effort (<5% error) Will drive a primary coil of 50Ω or greater Frequency range of 1.5kHz to 12.5kHz selectable by resistor/capacitor combination Voltage range 1.0V RMS to 6.0V RMS selectable by resistor Temperature coefficient best effort (1%) [3.3] Demodulator High input impedance of 1MΩ or greater Secondary LVDT output voltage between 0.14V RMS to 3.3V RMS at maximum displacement, output selectable ranges as follows: o 0 to 5V DC o 0 to 10V DC o 0.5 to 4.5V DC o 0.5 to 9.5V DC Ripple voltage less than 0.2% of output voltage Non-linearity less than 0.3% Temperature coefficient best effort (1%) 5 [4] Methods [4.1] Oscillator Due to the fewer restrictions on the oscillator, there were several choices for the design process of this component. However, there were three necessary parts for the oscillator design: an internal voltage regulation method, the oscillation, and the amplification of the oscillating signal. The voltage regulation scheme could only be accomplished using a voltage regulator IC, as well as zener diodes. This is because of the large input voltage range requirement. The highest possible regulated voltage was ~9V, so that the device could run off the minimum 11.5V. The 9V regulators that were found had a maximum operating voltage of less than 30V, so a zener diode was necessary to limit the input voltage to a safe maximum operating voltage. The amplification design was achieved in the simplest possible way, using an inverting operational amplifier. The amplification of a simple inverting op amp is given as follows: 𝑅𝑓 (1) 𝑉𝑜 = 𝑉𝑖 𝑅𝑠 Because of this voltage relationship, the amplification can easily be changed with a simple resistor change. There were three main choices for designing the oscillator: modifying TransTek’s current oscillator model, building a new analog oscillator model from scratch, and using a microcontroller to generate the oscillations. Each choice had advantages and disadvantages. Building a new analog oscillator from scratch would be significantly more difficult and time consuming than modifying the current model, but it would lead to a far deeper understanding of the circuitry involved. There could also be stability issues with designing a new oscillator, as it is known that Trans-Tek’s current oscillator model is very stable. Using DSP would reduce the number of component parts needed, but may introduce programming issues into the system, as well as waveform distortion due to sampling. There would also be concerns of the oscillator stability with this design. Modifying Trans-Tek’s current model would be easier to achieve than building a new oscillator, but tuning it to match the new specifications may prove difficult. The current model is very stable, however. The first attempt at building an oscillator was to redesign Trans-Tek’s Series 1000 oscillator model. A prototype was built, but difficulties were encountered due to the complexity of the design and the discontinuation of some of the oscillator parts. A working model of the Series 1000 was not achieved, and due to time constraints, a new approach was taken. Two different standard analog oscillator models were investigated for prototyping: a Wien Bridge oscillator, and a phase-shift oscillator. Both designs were prototype and debugged, and both failed to produce oscillation. Again, due to time constraints, a new design approach was taken. The next design prototyped was based on a microcontroller design, using a PWM output to achieve oscillation. This design was successfully prototyped, but only produced a single-frequency output. Thus, the design needed to be modified. The next design attempted was a variable-frequency microcontroller-based model. This design used a 6 sinusoidally-varying PWM output from the microcontroller, but successful implementation of this was never achieved, due to issues with programming the PWM output. The final design attempted was a new analog circuit design, using a timer IC. This design was based heavily on the single-frequency microcontroller-based design, and was successfully implemented into the system. [4.2] Demodulator The function of the demodulator is to receive a signal from the LVDT output and convert it into a useful signal for the corresponding readout device. Due to the design of the LVDTs to be used with this system, this conversion with be from an AC signal to a DC signal. The output from the LVDT will be a sine wave, with an amplitude that varies with respect to the distance from the LVDT core to the null position, and a phase that varies with the direction of the core’s movement from null. The demodulator will receive the LVDT output signal and a reference signal from the oscillator, and compare their amplitudes and phase shift to output a corresponding DC signal. Figure 2: The ideal demodulator output voltage, with respect to LVDT core position. Source: http://www.singer-instruments.com/sites/default/files/images/tutorials/how_lvdt_works_fig3.gif Because of the subtractive formation of the LVDTs secondary coils, its output will have a range from –Vmax to +Vmax, where Vmax is the maximum amplitude, and 0 will be the default output (when the core is in the null position). The design of the demodulator could be done with two different approaches: using an analog demodulation circuit, or designing for DSP-based demodulation. Using an analog circuit would be simpler for the initial design, because the current demodulator design is composed of analog components. However, it would be challenging to modify and tune, as new circuit components would be required every time changes were made. A DSP-based demodulator would be harder to implement initially, as Trans-Tek currently has no DSP-based systems. However, tuning the demodulator would be far easier with DSP, and the size of the system would be greatly reduced. However, this method would introduce some additional necessary circuitry, such as circuit to apply a DC offset to the reference and LVDT output signals. Trans-Tek has specified that a DSP approach would be preferred to an analog approach, and as such, the demodulator design was chosen to be a DSP-based system. 7 There are two possible approaches to the demodulator design using DSP. Either an embedded microcontroller or a digital signal processor chip can be used. However, due to the size constraints of the design, a microcontroller is a more optimal choice. DSP chips tend to be larger, and while they are designed for use with DSP, they are both larger and more expensive than most microcontrollers. Because only a single signal must be processed in this system, it will be better to use a microcontroller, as it can achieve the same function as a DSP chip while staying within both the size and monetary budgets of the project. An external and internal flow diagram of the DSP system can be found below. Figure 3: The external flow of the demodulation process. Figure 4: The internal flow of the demodulator microcontroller design. 8 The demodulator will receive the LVDT output and reference signal from the oscillator, and apply a DC offset, as the chosen microcontroller cannot receive negative voltages for its ADC inputs. It will convert these to digital signals, and perform amplitude and phase comparison. Based on the amplitude ratio and the phase shift, the microcontroller will output the appropriate PWM for the desired DC signal after performing the necessary calculations. [4.3] PCB Design One of the most critical aspects of our project revolves around the integration of a PCB into the housing of our LVDT. As such, it was proposed by Trans-Tek that we use a flexible PCB for this design. This option focused around the idea that the flexibility of the PCB would offer more space to fit inside the LVDT housing. After looking over this possibility, we determined that the space that could be saved is essentially negligible. Seeing as the flexible PCB can be four times as expensive as a rigid PCB, less reliable, and cause issues down the line with circuit components, we decided to choose a rigid PCB design. It is also important to note that rigid PCBs can be manufactured at differing thickness. If the space within the LVDT was not enough for the designed PCB, Trans-Tek also provided another option. This would include extending the LVDT housing, but stopping the inner tube and coils. This would allow us to take advantage of the entire .7inch diameter tubing, rather than squeezing into a space less than half an inch (.491 inches). This, however, was less desirable. The final PCB design was compact enough to fit into the 0.491” space shown below. Figure 5: An image of the cross section of an LVDT to be used with the new oscillator/demodulator design. 9 [5] Final Design [5.1] Oscillator The final design chosen for the oscillator was using a NA555 Timer IC from Texas Instruments. The benefits of this design were that it has an easily-variable frequency, so it matches the desired oscillator specifications given by Trans-Tek. The output frequency of the oscillator can be calculated using Equation 2 below, along with the schematic of the oscillator. 1.44 (2) 𝑓= (𝑅1 + 2𝑅2 )𝐶1 Figure 6: The circuit schematic for the first oscillator PCB. The square-wave output from the timer is then sent through a bandpass filter network to convert it into a sine wave. In addition to the oscillation, the voltage regulation is on the first PCB for the oscillator system (as shown in Figure 6). The final amplifier determines the output voltage of the oscillator, and can be seen in Figure 7. The second board also contains the DC offset circuit, and applies a DC offset to the reference and LVDT output signals. It then reduces the signals to a 0-3V range through a voltage divider. 10 Figure 7: The second PCB of the oscillator system. [5.2] Demodulator The demodulation network is based on an ATtiny85 microcontroller. Two ADC inputs are used, connected to the oscillator reference signal and the LVDT output signal. The PWM output is sent through a low-pass filter network, followed by a differential amplifier. A larger PWM duty cycle leads to a larger DC output voltage. The differential amplifier amplifies the difference between the PWM output and a fixed reference voltage. This reference must be the midpoint between the minimum and maximum PWM output, so that the overall output is centered around 0V DC. The output voltage ranges are selected using software in the microcontroller’s programming. The demodulation algorithm programmed into the microcontroller can be found in the appendix. The schematic is below. Figure 8: The circuit schematic for the demodulator hardware. 11 [5.3] PCB Design Three PCBs were designed for the system, due to limitations in the size allowed by the free version of Eagle PCB Editor. The boards are 3.25” x 0.4”, 4.0” x 0.45”, and 3.875” x 0.475” in size. They all fit within the 0.491” size constraint of the project. The board layouts can be found below. Figure 9: The PCB layout for Oscillator 1. Figure 10: The PCB layout for Oscillator 2. Figure 11: The PCB layout for Demodulator. 12 [5.4] Overall System Layout Figure 12: The overall system block diagram. 13 [6] System Results [6.1] Oscillator The oscillator prototype was capable of achieving 1.5-12.5kHz range, at an amplitude of 1-6V RMS, as specified. A 7kHz, 2.5V RMS waveform is shown below. Problems arose when the oscillator was connected to the LVDT. The input and output to and from the LVDT became severely distorted. Upon further investigation, the team hypothesized that such an output could be due to the fact that the oscillator filter network utilized impedance values several orders of magnitude larger than the LVDT’s resistance (~50Ω). There is future work to be done in fixing this issue. Although the oscillator circuit works well on its own, when connected to the LVDT it did not yield a proper output. Figure 13: An oscilloscope screenshot of a 7kHz, 2.5V RMS waveform output by the oscillator. [6.2] Demodulator The demodulation circuitry was able to produce all of the desired output voltage ranges. Shown below is the maximum of the specified ranges, 0 to ±10V DC, in relation to the output PWM duty cycle selected to achieve the DC outputs. However, further testing of the microcontroller code revealed that the ADC conversion was not functioning properly, and as such, the demodulation failed. Future work in this area would be to debug the code at its most basic level, and fix the issue with the microcontroller’s ADC. 14 Demodulator Output Range 10 y = 0.0824x - 10.489 R² = 0.9987 8 6 4 2 Output Voltage (V) 0 -2 0 20 40 60 80 100 120 140 160 180 200 220 240 -4 -6 -8 -10 Microcontroller PWM Duty Cycle Output (x/256) Figure 14: The relationship between the demodulator circuitry output voltage and the duty cycle of the microcontroller PWM output. [7] Discussion The experimental results were promising, but failed to be integrated into the overall system. The oscillator functioned independently, but was unable to drive the LVDT’s primary coil. The demodulation circuitry produced the desired output voltage ranges with variations to the PWM duty cycle, but the microcontroller could not successfully implement ADC in receiving the input signals. Time constraints did not allow further completion beyond this point. PCBs were designed, planned, ordered, and received. They were not populated, since the prototype failed to produce full functionality. However, the boards do fit within the size constraints given by Trans-Tek. While the overall system was unable to function as desired, separate pieces were able to function within the specifications desired by Trans-Tek, so the project was successful in many respects. 15 [8] Timeline Figure 15: The timeline for the project over the course of both semesters. Figure 15 show the team’s timeline for the project. The most pervasive time issue was in designing the oscillator. Each oscillator design took between one and two weeks to design and attempt to implement. At least six designs were implemented and tested, and five failed to produce any usable output. Because of this, the project was delayed several weeks, and the demodulator code was not tested until late in the spring semester. This backup caused the team to fail in integrating the systems together for a final product. [9] Budget Trans-Tek covered all expenses for the project. However, the team aimed to keep the final costs under the allotted $1000 for standard projects in the ECE department. Team 181’s total expenses were as follows: Prototype parts: $120.56 PCB parts: $43.81 PCBs: $630 Total cost: $804.12 The team was able to keep costs under the $1000 self-imposed limit. However, the large majority of these costs were from ordering the PCBs with expedited shipping. For production purposes, ordering the PCBs and parts in bulk and with standard shipping, a single unit’s cost could be significantly less than $50. [10] Conclusions and Future Work The main goal of the project was to redesign Trans-Tek’s oscillator/demodulator unit which consisted of a voltage regulator, oscillator, and demodulator. We were successful in scaling this design down to fit within the 0.7” diameter casing for the LVDT 16 supplied by Trans-Tek. We accomplished many of the goals that we set for ourselves in the beginning. We scaled the circuit down a significant amount, we implemented DSP, and we have chosen a design that can easily be changed so that it works with a wide range of frequencies. Although we have accomplished so much, we have fallen short in getting our design to work with the lower impedance of the LVDT. Additionally, the microcontroller failed in digitizing the input signals. However, it was successfully shown that a microcontroller’s PWM can produce a linearly-varying DC output voltage with the desired demodulation characteristics. There is some future work that could be done on this project to produce a fullyfunctional system. Primarily, the oscillator circuit would be modified to reduce the negative impact of the LVDT’s resistance on the system. As stated before, the impedances within the filter network could be reduced to achieve this. The other primary issue with this oscillator model is that there is no simple formula for calculating the output amplitude, as the signal attenuation varies significantly over the specified frequency range. The final amplifier must be modified by a trial and error process if a new frequency is desired. The demodulator system failed to work due to ADC conversion in the microcontroller. However, the algorithm has been developed, and would be simple for Trans-Tek to implement in their future oscillator/demodulator designs. 17 [11] Appendix [11.1] Demodulation Algorithm Main Function 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. Initialize 2 ADC channels for inputs, 1 PWM channel for output Define two 40-point arrays, for the oscillator reference and LVDT output Select the oscillator reference to be the first ADC conversion Enable global interrupts Enter main loop Trigger ADC conversion every 1/40th of the oscillator reference period, so that the 40 points in each array cover an entire period of the signals Convert ADC binary values to voltages Parse both arrays of 40 points to determine the maximum value of each and save to respective variables Find the point where the oscillator reference is its maximum value a. If the LVDT output increases between this point and the previous, then the DC output from the demodulator is positive b. If the LVDT output decreases between this point and the previous, then the DC output from the demodulator is negative 𝐿𝑉𝐷𝑇 𝑂𝑢𝑡𝑝𝑢𝑡 Find the ratio 𝑂𝑠𝑐𝑖𝑙𝑙𝑎𝑡𝑜𝑟 𝑅𝑒𝑓𝑒𝑟𝑒𝑛𝑐𝑒 11. Calculate the PWM output needed to achieve the DC output magnitude in the direction specified by the phase information 12. Modify the PWM duty cycle as calculated 13. Return to Step 5 ADC Completion Interrupt 1. If interrupt occurred while parsing arrays, do nothing 2. If interrupt occurred any other time, continue a. If the oscillator reference was converted, set the ith value in the oscillator reference array to the binary value from ADC conversion i. Increment counting variable i 1. If i is greater than the size of the arrays, set to 0 ii. Trigger the next conversion, setting the LVDT output as the desired conversion pin b. If the LVDT output was converted, set the ith value in the LVDT output array to the binary value from ADC conversion i. Increment counting variable i 1. If i is greater than the size of the arrays, set to 0 ii. Do not trigger another conversion 3. Return to main function 18 [11.2] C Code for ATtiny85 /* Uconn ECE Senior Design Team 181 Jason Meyer, Jonathan Wolff, Ryan Williams, Damon Soto Oscillator/Demodulator Circuit Build Demodulation Code */ #include <avr/io.h> //Include AVR inputs/outputs #include <avr/interrupt.h> //Include interrupt service routines #define F_CPU 1000000UL //Define the internal clock to run at 1MHz #include <util/delay.h> //Simple function for delaying by a set time //Allow for easily changeable output voltage range static double Vout_max = 10; static double Vout_min = 0; //Allow for use with variable oscillator frequencies (in kHz) static int osc_freq_kHz = 12.5; //Declare necessary variables unsigned int fromadc, ref_binary, lvdt_out_binary; double ref_voltage, lvdt_out_voltage, voltage_ratio; unsigned int counter; double time_ms; double ref_max, lvdt_max; unsigned int ref_j, lvdt_j; unsigned int i, j, k; //Incrementing variables double ref_array[40], lvdt_array[40]; //40-point arrays for oscillator reference and LVDT output unsigned int start_conversion; unsigned int positive_out; double Vout, normalized_Vout; unsigned int dc_mid; unsigned int in_loop; unsigned int sample_period_us; //Define function for delaying with a variable input void delay_us(int us) { for (k = 0; k < us; k++) { _delay_us(1); } } int main(void) { //Define sampling period of ADC sample_period_us = 0.02*(1/(osc_freq_kHz*0.001))-1; //Set counter and time to 0 counter = 0; time_ms = 0; //Set PB1 as an output for PWM, and the remainder of PORTB as inputs //Initialize values for PB3 and PB4 DDRB = 0x01; TCCR0A = 0b10100011; TCCR0B = 0b00000101; //Set PB0 to output //Set to Fast PWM mode //Set to Fast PWM mode, no prescalar //Set output compare values for timer 1 with PWM OCR0A = 0; 19 //Initialize ADC ADMUX = 0x00; ADCSRA = 0xc8; //Enable global interrupts sei(); while(1) { //Wait the sample period before triggering ADC conversion delay_us(sample_period_us); //ADC Conversion ADMUX = 0b00000000; ADCSRA = (1<<ADSC); //Set ADC to convert oscillator reference voltage //Start ADC conversion //Parse arrays for amplitude and phase info for(j=0; j<40; j++){ in_loop = 1; //Signify that data is being parsed ref_max = 0; lvdt_max = 0; if (ref_array[j] > ref_max){ ref_max = ref_array[j]; //Max of oscillator reference signal ref_j = j; //Sample number of max } if (lvdt_array[j] > lvdt_max){ lvdt_max = lvdt_array[j]; //Max of LVDT output signal } } in_loop = 0; //Signify that data is no longer being parsed //Determine phase information, decide if demodulation output is positive or negative if(lvdt_array[ref_j-1] < lvdt_array[ref_j]){ positive_out = 1; } else if(lvdt_array[ref_j-1] > lvdt_array[ref_j]){ positive_out = 0; } //Calculate PWM output based on phase and amplitude information voltage_ratio = (lvdt_max/ref_max); Vout = voltage_ratio*(Vout_max - Vout_min) + Vout_min; normalized_Vout = (Vout/5) + 2.5; dc_mid = 113; if (positive_out == 1){ OCR0A = dc_mid + floor(51.74096974*normalized_Vout); } else if (positive_out == 0){ OCR0A = dc_mid - floor(51.74096974*normalized_Vout); } } } ISR(ADC_vect) { if (in_loop == 0){ switch (ADMUX){ case 0x00: //Set ADC0 value to variable - reference oscillator voltage fromadc = ADCL; ref_binary = ADCH<<8 | fromadc; ref_voltage = 5*(ref_binary/1024); ref_array[i] = ref_voltage; //Set next conversion for ADC1, start conversion ADMUX = 0x01; ADCSRA |= 1<<ADSC; break; 20 case 0x01: //Set ADC1 value to variable - LVDT output voltage fromadc = ADCL; lvdt_out_binary = ADCH<<8 | fromadc; lvdt_out_voltage = 3*(lvdt_out_binary/1024); lvdt_array[i] = lvdt_out_voltage; //Set next conversion for ADC0 ADMUX = 0x00; break; default: break; //Increment i, reset if 40 or higher i++; if (i>=40){ i = 0; } } } }