Table of Contents

Creating a PWM Output Sensor
Using a Field-Programmable
Analog Array


FPAAs are powerful and flexible ICs useful for quickly, efficiently, and accurately designing a wide variety of circuits, including one that converts a pressure sensor's analog output into a digital pulse width modulated signal.


Eric Jacobsen, Motorola

For remote sensing and noisy environments, a digital pulse width modulated (PWM) output is more desirable than an analog voltage because PWM outputs inherently have better noise immunity for these types of applications. For analog voltage output sensors, discrete circuit solutions that convert the analog signal to a digital PWM signal are readily available; unfortunately, these solutions can suffer inaccuracies due to component tolerances and mismatches. Consequently, generating a PWM output with a desired accuracy can require time-consuming calibration and/or component replacement. In the worst case, re-breadboarding/redesigning the entire circuit solution may be required if the chosen analog-to-PWM conversion circuit topology does not adequately accommodate the sensor's output (e.g., offset and dynamic range characteristics).

An alternative to manually calibrating and breadboarding a PWM output circuit is to use a field-programmable analog array to quickly and accurately achieve the desired PWM sensor output characteristics. With this technique the sensor's analog voltage output characteristics may be quickly accommodated to obtain the desired transfer function without modifying hardware components. Where multiple circuit topologies are possible, each may be quickly and efficiently implemented within the analog array. This article demonstrates, by means of a pressure sensor example, how to design a PWM output for an analog voltage output sensor.

The Pressure Sensor's Characteristics
Typical analog voltage output pressure sensors include Motorola's MPX5000 Series sensors, which are signal conditioned (amplified), temperature compensated,

Figure 1. Figure 1. The pressure sensor's output is converted to a pulse width modulated output via a circuit implemented in the FPAA. The design is created using eight analog macro functions, only a few of the many in the FPAA's front-end design software tool.

and calibrated (i.e., offset and span are precision trimmed). The sensors are available in full-scale pressure ranges from 6 kPa (~1 psi) to 700 kPa (~100 psi). With the recommended 5 V supply, the MPX5000 Series produces an output of 0.25 V at zero pressure to 4.75 V at full-scale pressure. This corresponds to a dynamic range (commonly referred to as the span) of 4.5 V. The electrical characteristics of the MPX5100D are given in Table 1.

TABLE 1
MPX5100D Electrical Characteristics
Characteristic Symbol Minimum Typical Maximum Unit
Pressure Range Pop 0 -- 100 kPa
Supply Voltage Vs 4.75 5 5.25 VDC
Full-Scale Span (0°C-85°C) Vfss 4.388 4.5 4.613 V
Zero Pressure Offset (0°C-85°C) Voff 0.088 0.2 0.313 V
Sensitivity deltaV/deltaP -- 45 -- mV/kPa
Accuracy (0°C-85°C) -- -- -- ±2.5 %FSS

An Overview of the FPAA
A field-programmable analog array (FPAA) is the analog counterpart of the familiar field-programmable gate array (FPGA). As does the FPGA, the FPAA uses a front-end software circuit design program. Once the circuit is designed, it is converted into a serial data stream that programs the array's onchip static RAM (SRAM) by either downloading the data directly from a computer's RS-232 port or via a serial EPROM programmed with the circuit configuration data. This software circuit design interface allows circuit parameters and even entire circuit topologies to be quickly and efficiently designed electronically and then downloaded to the programmable array for verification.

Motorola's MPAA020 FPAA is based on switched-capacitor technology and contains an uncommitted array architecture of 20 op amps, a multitude of 8-bit capacitor banks, routing structures, and other supporting circuitry to configure any of the op amps as a variety of analog functions, including amplifiers, summing amplifiers, comparators, biquad filters, integrators, differentiators, and S/H circuits. With the FPAA's EasyAnalog, a front-end software circuit design tool, analog circuits may be designed, redesigned, and manipulated, and their performance confirmed quickly and efficiently. Once a circuit is designed, the software converts the circuit topology into a serial data stream that programs the MPAA020's onchip SRAM by either downloading the data directly from an RS-232 port or via a serial EPROM that is programmed with the circuit configuration data.

Using an FPAA to Design a PWM Output Pressure Sensor
The first step is usually to convert a sensor's low-level and/or differential output signal to a single-ended signal with a dynamic range of 4.5 V (0.25-4.75 V). Since for this design example the pressure sensor's output is already signal conditioned to the appropriate level, front-end signal conditioning is not discussed here [
1]. After this step, the signal is converted to a PWM output signal via the appropriate circuit topology that is implemented in the FPAA. In Figure 1, the blocks represent macros that are provided as part of a library in the software to assist the circuit designer. Once the topology is implemented within the analog array, the individual blocks can be adjusted (e.g., for gain) via software to obtain the final PWM output. Also, the output of each block in Figure 1 is available using the MPAA020's 13 I/Os to monitor the output of the various circuit stages.

Creating the PWM Circuit
The PWM output is created, from a global perspective, by generating a repeating linear ramp waveform and then using a comparator to compare it

Figure 2. Figure 2. Using a comparator to compare the sensor's output voltage to that of a ramp generator creates a pulse train with a given pulse width. As the sensor's output voltage increases or decreases, the pulse train's pulse width changes accordingly, thus creating a pulse width modulated output.

to the sensor's analog DC voltage output. As shown in Figure 2, the comparator's output is high whenever the sensor's voltage is greater than a given ramp voltage and low whenever the sensor's voltage is less than the ramp voltage.

By visualizing the sensor's voltage increasing and decreasing (corresponding to increasing and decreasing pressures), the duty cycle of the PWM output can be seen to change accordingly. Thus, the linear ramp waveform provides a linear translation of the sensor's analog voltage output to a pulse train with a duty cycle that varies linearly with the sensor's analog output voltage. If the sensor's analog voltage changes linearly with pressure, then the PWM output's duty cycle will also vary linearly with pressure.

   Stage 1. Stage 1 is the ramp generator and consists of four analog macro blocks whose characteristics can be modified to customize/calibrate the ramp for a specific application. To see how this is done, it is first necessary to understand how they work to create the repeating ramp waveform.

Beginning at the output of the comparator macro (in Stage 1), let's assume the comparator's output is negative, or in other words, is low. (To allow inverting and noninverting signal gains, i.e., noninverting and inverting macro gain stages, all input signals to the MPAA020 are referenced to a signal ground, created by an internal bandgap reference, which is typically 2.5 V.) The output of the comparator connects to two macro inputs, the rectifier and an inverting gain stage. The rectifier simply rectifies the negative signal and creates a positive reference at the negative terminal of the comparator; the comparator's negative input terminal will therefore always be a positive voltage determined by the rectifier. This positive voltage can be conveniently adjusted by changing the gain parameter of the rectifier.

The comparator output is also input to an inverting gain stage. Therefore, the comparator's negative output is inverted to a positive voltage. This positive voltage is then input to the ramp generator. The inverting gain stage, like the rectifier, has a gain parameter that can be adjusted to modify the ramp waveform's characteristics.

The ramp macro has a few important parameters that can be adjusted to modify the ramp waveform, but in general it functions as follows: when its input voltage is positive (referenced to signal ground), the ramp voltage increases linearly; when its input voltage is negative, the ramp voltage is discharged to signal ground. The repeating ramp waveform therefore can be generated by continuously applying a positive voltage to the ramp macro's input to increase the ramp voltage and then applying a negative voltage to discharge the ramp's voltage back to signal ground.

The ramp macro's output is then input to Stage 2, and is also fed back to the positive terminal of the comparator. As the ramp charges, its voltage is compared to the rectifier's output. When the ramp voltage is lower than the rectifier's output, the comparator's output is low, as is the current state of the comparator. Thus, while the ramp's voltage is lower than that of the rectifier, the Stage 1 system remains in this "steady state."

Once the ramp voltage exceeds the rectifier's output voltage, the comparator's output becomes positive (high). By following the signal path around the loop once again, the comparator's high output is input to the rectifier and the inverting gain stage. The rectifier simply rectifies the positive voltage, but now the output of the inverting gain stage becomes negative.

The inverting gain stage's negative output is input to the ramp, discharging (turning off) the ramp to signal ground. But now the ramp voltage upon discharging is lower than the rectifier's voltage output at the comparator's negative terminal. Thus the comparator's output switches low, resulting in a positive output from the inverting gain stage. This positive output, input to the ramp, now starts the ramp charging all over again. The circuit uses feedback to reset the ramp every time its voltage exceeds the reference voltage created by the rectifier.

The individual Stage 1 macros and their parameters are:
   Comparator. The comparator has no parameters to customize. It provides a logic-level output based on the relationship of its two inputs to each other.

Figure 3. Figure 3. The ramp waveform linearly increases until it equals the reference voltage created by the rectifier. When the ramp waveform voltage exceeds the reference voltage, the ramp discharges to signal ground, ready to begin another charge­discharge cycle. The ramp discharge time is exaggerated to emphasize that the discharge time, though short, is nonzero.

   Rectifier. The rectifier generates the constant reference voltage that determines at what voltage the ramp discharges (turns off) and has a gain parameter that can be modified to adjust that voltage level (see Figure 3. The input to the rectifier is ±2.5 V (the comparator's output, referenced to signal ground). For example, by setting the rectifier's gain to 0.8 V/V, the rectifier's output will be ABS (±2.5 V • 0.8) = 2.0 V. Thus, the ramp will charge from 0 V to 2.0 V (signal ground referenced—remember that signal ground is 2.5 V referenced to earth ground).

   Inverting Gain Stage. The input voltage to the ramp is controlled by adjusting the inverting gain stage's gain parameter. Although from the

Figure 4. Figure 4. The ramp's input voltage, modified by adjusting the gain of Stage 3, controls the frequency of the ramp waveform. The waveform's frequency is directly proportional to its input voltage. As in Figure 3, the ramp discharge times are exaggerated to emphasize that the discharge time, though short, is nonzero.

previous discussion this point might not seem significant, it should be noted that the slope of the ramp is a function of its input voltage. In other words, the speed at which the ramp charges is directly proportional to its input voltage. The frequency of the repeating ramp waveform can therefore be modified by adjusting its input voltage (see Figure 4). For example, the desired input voltage to the ramp is 1 V. The gain of the inverting gain stage is therefore designed to be 0.4 V/V (±2.5 V • 0.4 = 1.0 V). Note that the positive 1 V is significant in controlling the speed of the ramp's charging but the negative voltage does not control the ramp's discharging—any negative voltage causes the ramp to discharge at the same rate.

   Ramp Generator. The ramp generator has up to three adjustable parameters:

  • Number of clock cycles per input volt (Clk Cycles/Vin)
  • Input voltage, Vin, to the ramp generator; Vin should be set to the actual input voltage to the ramp generator (i.e., the output of the inverting gain stage).
  • Switched capacitor sampling clock frequency for the macro itself

Modifying the clock frequency from its fastest sampling rate of 1 MHz is not recommended since slower clock frequencies result in fewer samples per unit time. Thus, a very slow clock frequency can result in a ramp waveform with a stair-step output. The overall accuracy of the PWM output will then be limited by the ramp itself and not the noise floor or sensitivity (resolution) of the sensor.

The ramp waveform is subject to:

ramp waveform's period = (rectifier's gain • 2.5) • (number of clock cycles/volt) • (inverting amplifer's gain • 2.5)-1 • (sampling clock frequency)-1

ramp's initial dynamic range = rectifier's gain • 2.5

Figure 5. Figure 5. To create a ramp waveform that spans the sensor's dynamic range, the ramp waveform must first be level-shifted symmetrically about the signal ground. The formula is: level-shift voltage required = ­0.5 · ramp's dynamic range.

   Stage 2. Stage 2 is an inverting summing amplifier used to level-shift the ramp such that it symmetrically straddles signal ground (see Figure 5). Remember that the ramp's dynamic range extends from signal ground to, for example, 2.0 V above signal ground. But the sensor's output voltage spans 0.25-4.75 V referenced to earth ground. Thus, the ramp's dynamic range must be signal conditioned to be greater than the sensor's dynamic range. Stage 2 uses Stage 4, a precision reference voltage generator, to accurately level-shift the ramp. The required level-shift voltage is governed by:

level-shift voltage required = -0.5 • ramp's initial dynamic range

The gain for each input signal to the summing amplifier is set to 1 (unity gain) since only level-shifting of the ramp is required.

For the example in which the ramp spans 0-2 V referenced to signal ground, a reference voltage of -1 V is generated in order to position the ramp from -1 V to +1 V referenced to signal ground (or from 1.5 to 3.5 V referenced to earth ground).

Figure 6. Figure 6. The final ramp waveform, at the output of Stage 3, has a dynamic range larger than that of the sensor to ensure that the PWM output has minimum and maximum duty cycles >0% at zero pressure and 100% at full-scale pressure, respectively. Thus, the ramp extends lower than the sensor's zero pressure offset voltage and higher than its full-scale pressure output voltage.

   Stage 3. Stage 3 amplifies the level-shifted ramp waveform so that its dynamic range is larger than that of the sensor (see Figure 6). If the sensor's output extends from 0.25 V to 4.75 V, or, referenced to signal ground, from -2.25 V to +2.25 V, then the ramp waveform must be amplified to be greater than this sensor's range (e.g., -2.3 V to +2.3 V).

To increase the ramp's dynamic range from 2 V [1 V - (-1 V)] to the desired dynamic range of 4.6 V [2.3 V - (-2.3 V)] requires a gain of 4.6 V / 2 V = 2.3 V/V:

Stage 3 gain = ramp's desired dynamic range / ramp's initial dynamic range

   Stage 4. As previously noted, Stage 4 is the precision reference voltage added to the ramp waveform. For the above example, to position the ramp waveform symmetrically about the signal ground, a reference voltage of -1.0 V is required.

   Stage 5. Stage 5 is the comparator that compares the final ramp waveform to the sensor's analog output voltage. The output of Stage 5 is the PWM output.

Important Note: Because the MPAA020 is a sampled system, an anti-aliasing filter for the sensor's analog output signal is recommended.

A Design Example for the PWM Output Pressure Sensor
For this example, the design parameters are:

  • The sensor is the MPX5100D with a dynamic range of 0.25 V
    to 4.75 V.
  • The PWM output frequency is 2 kHz.

Based on the second parameter, the ramp frequency is also 2 kHz; its period is therefore ˝ kHz = 0.5 ms. Plugging into the ramp design equations:

Let the ramp's reference voltage = 2.0 V, thus:

ramp's initial dynamic range = 2.0 V
= rectifier's gain • 2.5
arrow rectifier's gain = 0.8

And, let the ramp's input voltage = 1.0 V, thus:

1.0 V = inverting amplifier's gain • 2.5
arrow inverting amplifier's gain = 0.4
arrow V
in = 1.0 V

0.5 ms = 2.0 • (number of clock cycles/volt) • 1.0-1 • 1 x 10-6
arrow number of clock cycles/volt = 250

Now the ramp must be level-shifted and amplified to the appropriate level. It is first level-shifted to symmetrically straddle the signal ground. As before, this requires a reference voltage of:

level-shift voltage required = -0.5 • 2.0 V = -1.0 V

Finally, amplify the ramp by adjusting the gain of Stage 3, the ramp's desired dynamic range divided by its current dynamic range:

Stage 3 gain = 4.6 V / 2.0 V = 2.3

Measuring the Sensor's PWM Output
A popular method used to measure the PWM output's pulse width is by means of a microcontroller's input capture timer channel. This channel can be programmed to detect the output's low-to-high and high-to-low edge transitions. Using the microcontroller's precise internal digital counter, the time difference between subsequent edge transitions (low-to-high then high-to-low or vice versa) can then be calculated, resulting in an accurate digital representation of the analog sensor's output:

  1. Using a microcontroller's input capture timer channel, detect a low-to-high edge transition on the PWM output.
  2. Store the microcontroller's digital counter value when the edge transition occurred, calling it, for example, PWM_LtoH.
  3. Next, detect the subsequent high-to-low edge transition on the PWM output.
  4. Store the microcontroller's digital counter value when the edge transition occurred, calling it, for example, PWM_HtoL.
  5. Calculate the pulse width by determining the difference between the two values, i.e., calculate PWM_HtoL - PWM_LtoH.

Calibrating, via Software, the Sensor's PWM Output
Because the relationship between the PWM output and the sensor's analog voltage is linear, linear interpolation can be applied to calibrating the

Figure 7. Figure 7. The PWM output is software calibrated by first measuring the output pulse width at zero pressure (A) and again at full-scale pressure (B). The corresponding pulse widths are stored and used to calculate the current pressure by first measuring the PWM output's pulse width (C) corresponding to the current pressure, and then by using a simple linear interpolation equation.

PWM output after obtaining two known pulse widths at their two known corresponding pressures. Typically a two-point calibration technique uses the zero and full-scale pressure of the application as the known pressures (see Figure 7).

Follow these steps to calibrate the PWM output:

  1. Apply zero pressure to the sensor.
  2. Using the technique in "Measuring the Sensor's PWM Output," measure the PWM output's pulse width that corresponds to zero pressure.
  3. Store the zero pressure pulse width as, for example, PWM_ZERO.
  4. Apply full-scale pressure to the sensor.
  5. Using the technique in "Measuring the Sensor's PWM Output," measure the PWM output's pulse width that corresponds to full-scale pressure.
  6. Store the full-scale pressure pulse width as, for example, PWM_FS.
  7. Use the following equation to calculate the current pressure as a percentage of full-scale pressure from the currently measured pulse width.

equation

Important Note: This calibration procedure will yield excellent system accuracy (neglecting any sensor output nonlinearity, ramp nonlinearity, and so forth, as explained above). Care must be taken, however, to ensure that the sensor's analog output is compensated for environmental conditions such as temperature, humidity, or mechanical stresses (other than the property the sensor is meant to detect) that may cause the sensor's output to drift.

Calibration Tips for the Analog Array
The analog array contains onchip well-matched capacitor arrays that result in accurate designs, so the PWM output requires little or no calibration. Fine-tuning the macro parameters may be useful, however, to adjust the PWM's duty cycle at zero and full-scale pressures to a desired level. Adjusting the duty cycle may be accomplished by fine-tuning the gain (thus adjusting the amplitude of the ramp waveform) of the inverting gain stage of Stage 3. Table 2 summarizes the effects of each macro parameter. The bolded macros, parameters, and resulting effects from adjusting the parameters are the recommended fine-tuning points for the circuit.

TABLE 2
Macro Parameter Effects
Macro Parameter Resulting effect
Rectifier Gain Ramp
Amplitude/Frequency
Inverting Gain Stage (Stage 1) Gain* Ramp Frequency
Ramp Clock Cycles per Volt Ramp Frequency
Ramp Vin* Ramp Frequency
Ramp Sampling Clock Frequency** Ramp Frequency
Precision Reference Voltage Voltage Level Ramp Offset
Inverting Gain Stage (Stage 3) Gain Ramp Amplitude/Offset
* Vin and the voltage generated from the output of Stage 1's inverting gain stage should be equal.
** Changes to the sampling clock frequency are not recommended.

Summary
An analog array is a powerful and flexible integrated circuit for quickly, efficiently, and accurately designing a wide variety of circuits, including one that converts a sensor's analog output into a digital pulse width modulated signal. FPAAs may soon prove valuable for applications requiring fast analog circuit prototyping and flexibility in the final analog circuit design.

References
1. Eric Jacobsen. Nov. 1997. "Signal Conditioning a Pressure Sensor with a Field-Programmable Analog Array," Sensors, Vol. 14, No. 11:12-17.


Eric Jacobsen is a System Design Engineer, Hardcopy Imaging, Motorola, Inc., 2100 E. Elliott Rd., M/D EL344, Tempe, AZ 85284; 602-413-4055, fax 602-413-5597, r18084@email.sps.mot.com

For more information on field-program-mable analog arrays, contact Bill Altonen, Business Manager for FPAAs, Motorola, Inc., 2100 E. Elliot Rd., Tempe, AZ 85284; 602-413-4663, r12953@email.sps.mot.com

For more information on sensors, contact Sensor Marketing, Motorola, Inc., 602-244-4556, fax 602-244-4201.


 

 


Questex Media
Home | Contact Us | Advertise
© 2009 Questex Media Group, Inc.. All rights reserved.
Reproduction in whole or in part is prohibited.
Please send any technical comments or questions to our webmaster.