1.0 discussion 2.1 approach - ece.ohio-state.edukasten/summer2001/fp_i.pdf(25000 / 60) or 416 times...

12
1 1.0 Discussion 2.1 Approach Group xyz proposes to Professor Kasten that the power monitoring and data logging system demonstrate the following simple functionality. The device should display the minimum of power usage information: voltage, current, and power, one parameter at a time on a small, 4-digit, liquid crystal display (LCD). These parameters are cycled by pressing a single external button on the front face of the monitor. Communication to the computer proceeds automatically and is accessible through a simple software interface. The only addition required to the computer system is a small module that is connected to a standard communications serial port. This functionality is realized through a system comprised of the following nine essential components: a microcontroller, an anal og to digital converter (ADC), an LCD, a local wireless communication device, a remote computer communication device, voltage and current sensing circuits, exterior user controls, a 5 Volt DC transformer source, and a software application for data logging. A diagram of how these components interact is shown in Figure 2.1. Figure 2.1: System Layout The sensing circuits are connected to the voltage and current flow from the wall outlet and output their signals to the analog-to-digital converter included as part of the microcontroller. The microcontroller receives power from the transformer and receives input from an external button operated by the user. The microcontroller outputs the measured values to the LCD through its included driver and communicates with the computer through the transceivers. 2.1.1 Microcontroller The system that is proposed by Group xyz is centered around the Texas Instruments MSP430P325 microcontroller, whose data sheet can be found in Appendix A. This controller was selected over the Microchip PIC16C745 after examining the following properties: processor speed,

Upload: hoangkien

Post on 14-Aug-2019

213 views

Category:

Documents


0 download

TRANSCRIPT

1

1.0 Discussion

2.1 Approach Group xyz proposes to Professor Kasten that the power monitoring and data logging system

demonstrate the following simple functionality. The device should display the minimum of power usage information: voltage, current, and power, one parameter at a time on a small, 4-digit, liquid crystal display (LCD). These parameters are cycled by pressing a single external button on the front face of the monitor. Communication to the computer proceeds automatically and is accessible through a simple software interface. The only addition required to the computer system is a small module that is connected to a standard communications serial port. This functionality is realized through a system comprised of the following nine essential components: a microcontroller, an analog to digital converter (ADC), an LCD, a local wireless communication device, a remote computer communication device, voltage and current sensing circuits, exterior user controls, a 5 Volt DC transformer source, and a software application for data logging. A diagram of how these components interact is shown in Figure 2.1.

Figure 2.1: System Layout

The sensing circuits are connected to the voltage and current flow from the wall outlet and

output their signals to the analog-to-digital converter included as part of the microcontroller. The microcontroller receives power from the transformer and receives input from an external button operated by the user. The microcontroller outputs the measured values to the LCD through its included driver and communicates with the computer through the transceivers.

2.1.1 Microcontroller The system that is proposed by Group xyz is centered around the Texas Instruments

MSP430P325 microcontroller, whose data sheet can be found in Appendix A. This controller was selected over the Microchip PIC16C745 after examining the following properties: processor speed,

2

LCD driving requirements, analog to digital resolution, communication ability, power consumption, and cost. A comparison of these properties for each chip can be found in Table 2.1.

Table 2.1: Comparison between Two Possible Microcontrollers

Micro-controller Speed (MHz)

LCD Driver

ADC Resolution Communication Power

Consumption Cost

TI MSP430P325 3.3 Yes 12-bit RF Transceiver 3 mA, 3 V $6.88

Microchip PIC16C745 24 No 8-bit USB Connection 16 mA, 5 V $6.21

The Texas Instruments (TI) microcontroller operates at a clock speed of 3.3 MHz. This is one of the slowest operating speeds available on the market, as typical values can range from 3 to 40 MHz. However, for this particular application, the calculations listed below were used to justify accepting a slower clock speed in order to maximize other beneficial characteristics. The ADC capability of the TI chip requires 12 clock cycles to sample. Although the exact coding of the software is not complete, a conservative estimate would require 10 clock cycles per bit of A/D input for memory storage and transmission. For 12 bit ADC each sample requires 12 + (10 x 12) or 132 clock cycles. With 3.3 million cycles per second the TI chip could sample the voltage and current from the appliance 25,000 times per second. Because voltage cycles at 60 Hz, the waveform can be sampled (25000 / 60) or 416 times per period, which is more than sufficient to make the necessary power calculations.

The accuracy of the analog to digital conversion has been determined by Group xyz to be

one of the areas more deserving of expense and attention than simple processing speed. As referred to earlier, the TI microcontroller allows 12 bit accuracy rather than 8 bit, which is common to many other devices. The calculations presented here show that these 4 additional bits greatly improve the dependability of the power monitoring system. Typical consumer wall outlets provide 120 volts root mean square (rms) voltage. Thus voltage fluctuates between (120 x √2) or 170 and –170 volts, representing a range of 340 volts. By separating this range (or the corresponding range ratio produced by the voltage sensing circuit) into 212 = 4096 different divisions, the maximum error is (340 / 4096) = 0.083 volts. The corresponding error from an 8 bit system is (340 / 256) = 1.32 volts. Thus the 12-bit ADC improves accuracy by a factor of almost 16.

Another advantage of the MSP430 is the inclusion of an 84 segment LCD display driver. This

is more than sufficient to provide an interface to the 28 segment, 4 digit, LCD display selected for this project. The inclusion of this device in the microcontroller unit provides a number of advantages. It saves the cost, power, and space requirements of purchasing a separate chip to perform this function. Most importantly though, it ensures compatibility of the LCD driver and reduces the programming burden and the manpower needed to integrate the two systems.

Another property of the microcontroller that can be optimized to improve performance is

power consumption. The TI chip operates at 3 mA and 3 V, consuming 9 mW of power. This level is far below that used by most household items. Even devices that operate off of DC transformers generally consume close to 200 mW. Keeping the power usage of the microcontroller to a minimum ensures that the consumer does not decrease their power conservation when purchasing the power monitor.

Perhaps most importantly, the TI microcontroller selected by Group xyz is designed to

function with its own transceiver unit manufactured by the same company. Because effectively integrating the communication system is one of the most technically difficult aspects of this proposal, ensuring the compatibility of this combination produces advantages in the development cost and time.

3

Finally, $6.88 is the cost of the MSP430. Examining some of the other comparable options

on the market, the TI chip is not appreciably more expensive. For example, a comparison to the PIC16C745 manufactured by Microchip shows a price increase of only sixty-seven cents. Given the extended capabilities of the TI chip detailed in this section, this small, added cost is more than justified by the savings in development cost and included components.

2.1.2 Analog to Digital Converter To convert the measured analog signal to a digital signal, we need to use an analog-to-digital

converter. The chosen microcontroller incorporates a 12-bit ADC into its package. This helps to decrease the overall size of the power monitor because an additional ADC does not have to be included. The 12-bit ADC has the capability to distinguish 4096 different voltages. Common household voltages range from -170 to 170 volts peak voltage; therefore, with a 12-bit ADC we can determine every 0.083 voltage step. The characteristics of different resolutions are shown in Table 2.2, with voltage resolution representing the difference in analog voltage that is signified by a single bit difference in the digital data.

Table 2.2: ADC Resolutions

ADC Resolution # of Digital Steps Voltage Resolution (volts)

8-bit 256 1.328 10-bit 1024 0.332 12-bit 4096 0.083

2.1.3 LCD Display

The values of voltage, current, and power that are measured by the analog to digital converter and computed in the microcontroller are then shown on the Liquid Crystal Display (LCD). The maximum power a household appliance uses is 3600 W.

pmax = vmaximax = (120 V) x (30 A) = 3600 W Therefore, the project group has chosen to use a 4 digit LCD, the LCD-S401C71TR from Lumex Inc. The LCD provides enough detail for the average consumer to read off the power-monitoring unit. The data sent to the remote computer contains more significant figures. The chosen microcontroller has a built in LCD driver for up to 84 segments which is more than needed. However, because the LCD driver is built into the microcontroller, the design needs 5, 3-to-8 line demultiplexers, which have been selected to be TI’s SN74LVC138A decoder. The built in driver contains 4 groups each having 3 output control lines. Figure 2.2 shows that 7 segments represent each digit. Therefore, by multiplexing the 3 output lines from the driver, a single digit can be controlled.

The LCD does not display the units of the value being measured. Instead the design incorporates three red LEDs to display the units, which Figure 2.2 demonstrates. An additional LED is used to indicate if the power monitor is currently turned on of off. The LCD display is 38 mm tall and 70 mm wide with an 18 mm character height. Figure 2.3 shows the actual LCD display unit.

Voltage

Current Power

4

Figure 2.2: How the Device Indicates which Quantity is being Displayed

Figure 2.3: The LCD-S401C71TR Liquid Crystal Display

2.1.4 Communication Device and Interface In addition to displaying the power information on the front panel of the device, another

feature of the power-monitoring unit is to send the recorded information wirelessly to a computer, which logs the data. To accomplish this wireless link, there are two separate communication devices. The first communication mechanism is located in the power-monitoring unit, and the second is in a remote device that attaches to the consumer’s computer. The local and remote devices communicate through radio frequency (RF) signals. We have chosen to implement this RF transmission with the TRF9600 transceiver manufactured by TI. A picture of this unit is displayed in Figure 2.4. The data sheet is found in Appendix B. Two transceivers are required, one for each of the local and remote units.

Figure 2.4: The TRF9600 Transceiver Unit

5

TI’s TRF9600 meets several important criteria defined by the project team. First the

transceiver is specifically designed for operation with the MSP430 microcontroller, thus ensuring compatibility and ease of interface between the two devices. The simplicity of interfacing the microcontroller to the transceiver is shown in Figure 2.5. Compatibility is an important issue given the limited amount of time assigned for this project. Secondly, the TRF9600 transmits signals between 868 – 915 MHz on an Industrial, Scientific, and Medical (ISM) band. The Federal Communications Commission (FCC) has declared this ISM band an unlicensed band. Another feature of our transceiver is that it already contains a 24-bit direct digital synthesizer (DDS). The function of the DDS is to convert our digital data to a transmittable signal. An extra feature this transceiver provides is a typical RF output power around 4.5 Decibel milliwatts (dBm), 0 dBm = 1 mW or 30 dBm = 1 W. This means that no additional RF amplifier is needed. Group Nine proposes that the power-monitoring unit should be a hand held device, so size is important. The TRF6900 has the dimensions of 7.2 square millimeters and is reasonably priced, making it ideal for the given size constraints.

Figure 2.5: Interface between the Microcontroller and the Transceiver [1]

The local and remote communication devices are implemented with only the microcontroller

and the transceiver. However, the remote device requires some additional hardware. The remote communication interface with the PC is accomplished through the use of an RS-232 chip. The RS-232 chip, TI’s SN75LV4737A, provides the acceptable protocol for a serial link to any personal computer. The remote device can plug into any serial communications (COM) port on a PC. The communication interface to the COM port on the PC can then be controlled by the software on the PC. This enables Group xyz to design computer software for data logging purposes. The analog signals that the power monitor measures are taken from voltage and current sensing circuits inside the power monitor, which are described in the next section. 2.1.5 Voltage and Current Sensing Circuits

An additional component that supports the functionality of the device is the voltage sensing circuit, which scale down the voltage from the appliance to a suitable value that it can be read by the A/D converter. The voltage sensing circuit is designed so that it consumes little power because, if it did, the power meter would be measuring the combined power consumed by the appliance and the sensing circuit. To make sure that the voltage sensing circuit does not consume a great amount of power, it must have extremely high input impedance.

The voltage sensing circuit is designed using an Instrumental Differential Amplifier (IDA) as

this configuration has the requisite high input impedance. This allows the circuit to measure the voltage from the appliance while drawing very little current into the op-amps. The IDA cannot handle a 120 Vrms input signal so the voltage input to the circuit must be stepped down. To accomplish this a voltage divider is used at the front end of the circuit as seen in Figure 2.6.

6

Figure 2.6: Voltage Sensing Circuit

The resistors R1 and R2 form the voltage divider, with R1 = 10.0 MΩ and

R2 = 95 kΩ. These resistors step down the input voltage to approximately 0.00952 of its previous value, and the voltage input into the IDA is taken from R2. The IDA is designed with specific resistors so that it has unity gain, specifically, R3 = R4 = 4.7 kΩ, R5 = 3 kΩ and R6 = 1.0 kΩ. Because the IDA is designed with unity gain, the only difference between the input and output voltages is that created by the voltage divider. The equation of the IDA shows that the circuit has unity gain:

))(*2

1( 123

4 VVR

RVo −+= α where

5

6

RR

=α . [Equation 2.1]

)(1))(7.4

7.4*21(

31

1212 VVVVk

kkk

Vo −=−+=

The current sensing circuit is also designed so that it consumes as little power as possible. Op-amps with high input impedance are once again used to ensure that very little current is drawn into the current sensing circuit. The IDA circuit is also implemented again due to its high input impedance and negligible effect on the appliance from which the current is sensed.

The current sensing circuit is placed in series with the device being tested to make the

current measurement. A 0.01-ohm resistor senses the current from the appliance. The voltage across this resistor is then input into the IDA, which like the voltage sensing circuit has unity gain. The current sensing circuit is shown in Figure 2.7.

7

Figure 2.7: Current Sensing Circuit

The voltage sensed by the IDA is equivalent to the current across the 1 ohm resistor since

according to Ohm’s Law, V=IR, and R = 1 ohm. The equation of the IDA circuit is the same as the voltage sensing circuit in Equation 2.1, and has unity gain for simplification.

After the voltage dividing circuit and the isolating amplifier, both the voltage and current

sensing elements require one last modification to allow analog to digital conversion. The TI chip can effectively provide conversion of values ranging from ground to the positive supply voltage. Although the circuits detailed thus far have scaled the voltage to be measured at the appropriate range, these signals still include the negative characteristics of the AC waveform. Thus, a level shifting circuit is needed to ensure that the entire waveform lies within the measurable range of the ADC. This circuit is illustrated below in Figure 2.8.

Figure 2.8: Level Shifting Circuit

The equation for this circuit is

Vo = (1 + (R9 / R8))*V1 + (R9/R8)*Vcc [Equation 2.2]

8

where R7 = R8 = 1.0 kΩ and R9 = 2.0 kΩ. As stated earlier, wall voltages range from roughly –170 to 170 volts. The voltage divider scales this voltage by 0.00941 resulting in a range from –1.600 to 1.600 volts for V1. Referring to Equation 2.2 above, and because Vcc = 5V, the effect of the level shifter is to multiply the voltage range by 1.5 and shift it up by 2.5 volts. This leads to a range from 0.100 to 4.900 volts for Vo. As the ADC can detect values from ground to Vcc = 5V, this is an ideal range to allow for taking current and voltage measurements. With these measurements the microcontroller can calculate the power that the appliance is consuming.

2.1.6 Calculating Power Power is calculated using the following equation,

P = Vrms*Irms*pf [Equation 2.3] The power factor (pf) is equal to the cosine of the phase angle difference between the voltage and current, pf = cos (Φ v- Φ i). If a load is not purely resistive, then there is a phase difference between the current and voltage. If the load is inductive, then the phase of the current actually lags the phase of the voltage. The power factor is said to be lagging in this case, and the phase angle of the current with respect to the voltage is negative. If the load is capacitive, then the phase of the voltage lags the phase of the current, and the phase angle is positive. For our calculation purposes, since cos (-x) = cos (x), the calculation of the power factor is the same regardless if the phase angle is negative or positive.

In order to calculate the power factor, we must find the difference in time between the voltage

and current signals. The difference in time between these two signals can be found using the timer in our microcontroller. To find the exact difference in time between the two signals, we must find an equivalent point on a graph that the two signals hit and measure the time difference between them. An easy point to use would be to find the difference in time between when the two AC signals cross the zero axis.

After finding the time difference between the two signals, the phase angle and power factor

can be calculated using the following equations:

α = ω * time difference of AC signals (rad/s) [Equation 2.4] pf = cos (α)

The factor ω is the radian frequency of the signal, which is ω = 2*Π*60 Hz (60 Hz is the frequency of the voltage signal from the wall outlet).

So after the microcontroller has sampled a current reading and a voltage reading when they

cross the zero axis and calculated the time difference between the two signals, the microcontroller can calculate the power factor using pf = cos (α). Then the microcontroller can calculate the instantaneous power the appliance is consuming using Equation 2.3.

2.1.7 Transformer

An internal transformer is utilized to supply a 5V DC source to the microcontroller and other internal components of the device. This transformer is internal to the main body of the device and is only needed to supply a relatively small amount of power. Group xyz decided to use a Power Volt Inc. standard model SZ step down transformer.

9

Figure 2.9: Picture of Transformer 2.1.8 User Interface

The user interfaces with the system directly through the use of two push-button switches, labeled “On/Off” and “Mode”, on the front of the exterior case shown in Figure 2.9. The first push-button switch has two pins and is used to power the system on and off. This switch allows the user to turn the system on or off with one push of the button. Initially the system is powered off and can be turned on by one press of the switch. The second push-button switch has three pins and signals which mode the system is currently monitoring: current, voltage, or power. The push-button cycles though all three pins continuously. This push-button determines which mode the user would currently like to monitor. When the push-button is pressed for the first time, the system begins measuring the voltage. The next two successive presses of the push-button toggles the system between the current and power monitoring modes. Finally, the cycle repeats, and the user may read measured values for each mode again. Each switch is interfaced to the microcontroller’s input/output to register an interrupt when pressed, thus cycling through the measurement viewable on the LCD.

Figure 2.10: Sketch of Final Product

2.1.9 Power Monitor System Software

The microcontroller inside the power monitor needs to be equipped with adequate system software to make the power monitoring system work. The program is installed on the TI PMS430E325, an Electrically Programmable Read Only Memory (EPROM) chip. The flow chart in Figure 2.10 illustrates how the system software functions:

Wall Outlet

• Voltage (V) • Current (A) • Power (W)

ON/OFF MODE

Appliance

Group xyz, Inc.

10

Figure 2.11: Power Monitor Software Flow Chart

When the power monitoring system is turned on, it does a self-diagnostic test to determine if

all the components of the system are in proper working order. If so it next attempts to communicate with the software on the PC that is used for data logging purposes. The power monitoring system sends a signal to the PC to see if the data logging software is currently running on the PC. This is accomplished using the transceiver inside the power monitor. The power monitoring system then waits a specified period of time for a response from the PC, which is sent from the transceiver and microcontroller connected to the PC.

If the power monitor receives a response signal from the PC, then it knows that the PC is

ready to accept data for data logging purposes. It transmits the data it records to the PC at certain time intervals specified by the system software. If the power monitor does not receive a response signal, it does not attempt to transmit data to the PC during its operation. Therefore the data logging software on the PC must be running before the power monitor is turned on for communication between the two devices to take place.

Once the self-diagnostic test is completed, the user is given the choice to display the voltage,

current, or power the appliance is using. If the user selects to display the voltage or current, the microcontroller simply takes the digital value of the specified signal from the A/D converter and displays it on the LCD.

If the user selects to display power, the microcontroller continuously receives digital values of

the voltage from the A/D converter until the voltage reaches zero. After this occurs the

11

microcontroller continuously receives digital values of the current from the A/D converter until the current reaches zero. Once the zero crossings of the two signals have been obtained the microcontroller can calculate the displacement in time between the two signals. With this value the instantaneous power is calculated as described in Section 2.1.6. The microcontroller then sends the value of the instantaneous power to the LCD.

If the communication link between the power monitor and PC has been established, the

power monitor periodically transmits data to the PC for data logging purposes. At each specified time interval, the power monitor calculates and transmits values for the voltage, current, and power the appliance is using at that time. The PC software then processes this data accordingly. 2.1.10 PC Software

Finally, the power monitoring system comes with PC software that is used for data logging purposes. The PC software is useful in that it allows the user to simply turn on the power monitoring system and the significant data that is recorded by the system is transmitted and logged onto the PC. The flow chart in Figure 2.11 illustrates how the PC software functions.

First, the PC software does a diagnostic test to make sure the transceiver and microcontroller are connected to the computer to facilitate communication between the power monitor and the PC. Once the software determines that the PC is ready for communication with the power monitor, the software waits for a signal to be sent from the power monitor telling the PC it is ready for transmission. The PC then sends a signal to the power monitoring system telling it that the PC is also ready for transmission.

Figure 2.12: PC Software Flow Chart

Once the communication link has been established, the PC software receives data from the

power monitor until it determines that the power monitoring system has been turned off. It determines this by allowing a certain time limit for it to receive a signal from the power monitoring system. Once this time limit has been exceeded, it concludes that the power monitoring system has been turned off.

12

The PC software then saves the data it has received to a file. The PC software then returns to standby mode and waits for another signal from the power monitor to begin data logging once again.

4.0 Cost

4.1 Fiscal The proposed power monitoring and data logging system includes the following equipment

and design costs shown in Table 4.1. The majority of the cost, as expected, comes from the 2 microcontroller and 2 transceivers

that are fundamental components of the design. The values that have asterisks in the table indicate estimated prices for items whose price was not available without a more rigorous inquiry.

Table 4.1: Estimated Cost of Parts for Design

Component Quantity Cost

Microcontroller (MSP430P325) 2 $13.76 Transceiver (TRF6900) 2 $10.68 LCD (LCD-S401C71TR) 1 $2.20 Demultiplexers (SN74LVC138A) 5 $2.50

DB9 Right Angle Plug Connector (CD5509PP21F0) 1 $0.58

Voltage/Current Sensors 1 $5* Packaging 1 $15* Total Parts $49.72 Labor 45 Hrs $ 2700.00 Total Cost $2749.72