home *** CD-ROM | disk | FTP | other *** search
-
- CAPACITOR FITTING
-
- Here is an interesting example of an advanced application of the PLD
- hardware language.
-
- Consider a bank of six capacitors, each with its own capacitance
- rating, each of which can be enabled or disabled by an individual line of
- a six-bit signal. If all six lines are inactive, none of the capacitors
- are enabled and the capacitance of the bank is zero. On the other hand,
- if all six lines are active, all capacitors are enabled and the
- capacitance of the bank is maximal, equal to the sum of the capacitances
- of the individual parts. If some lines are active and others are
- inactive, the capacitance of the bank is intermediate, equal to the sum of
- the capacitances of just the parts that are enabled.
-
- We want to enable the bank of capacitors in such a way that the total
- capacitance starts at an initial value and changes approximately
- quadratically with time. A synchronous binary counter that steps through
- the values 0, 1, 2, ..., 15 in either direction is available externally.
- Such a configuration of capacitors is useful for linearity corrections in
- the sweep circuits of multi-synchronous monitors.
-
- The basic problem is to find the combinations of capacitors that most
- closely fit a specified quadratic capacitance curve at each point along
- the curve, then to create logic to enable that combination at the right
- step of the counter. The values of the individual capacitors in the bank
- are chosen to be approximately proportional to the binary values of 1, 2,
- 4, 8, and so forth. Unfortunately, capacitors are not available (readily)
- in precisely the desired values, so it is not a simple matter of feeding a
- binary number to the bank of capacitors and having it replicate the binary
- value represented. Instead, for each point, it is necessary to choose
- from among all possible combinations of capacitors the one that best fits
- the desired value.
-
- Implementation is as follows: The source code works like a computer
- program. In an outer loop, variable k is set to each desired capacitance
- in nanofarads. The sixteen values for k represent sixteen points along
- the quadratic curve. These points could have been computed from quadratic
- coefficients in the source code, but the example is a little clearer and
- more versatile with the values given explicitly. In an inner loop,
- variable i is set to each possible combination of bits from 000000 to
- 111111 binary (0 to 63 decimal). The individual capacitance values appear
- in the equation for variable j, represented here in nanofarads so they
- will be integers. For each combination i, the resulting capacitance of
- the entire bank is computed by multiplying the value of each capacitor by
- the value of the corresponding bit of i, then by summing up the results
- (i[5] represents the high order bit, i[0] represents the low). If a bit
- in i is zero, then the product will be zero and the capacitor will not
- contribute to the sum. If the difference between the total capacitance
- and the desired capacitance is less than the best thus far, the newly
- computed value is remembered for later use. Finally, when all
- combinations have been examined, the combination that yields the best
- total capacitance is used to generate a product term for that step.
- Function "line" merely displays the step number, the total capacitance,
- and the deviation from the ideal value. After that the next capacitance
- value for the next point on the curve is processed in the same way.
-
- When studying the source code, please refer to the following
- definitions for the variables used. The first two are actual signal sets,
- the remainder are variables used only in computations.
-
- IN Counter signals (input)
- CAP Capacitor control signals (output)
- n Step number (0, 1, 2, ..., 15)
- k Value desired for the bank of capacitors at step n
- m Value resulting in the best fit thus far
- l Output combination corresponding to m
- j Value of output combination being tested
- i Output combination corresponding to j
-
- This technique changes what would be a very laborious process into a
- simple joy. Thanks to Fred Lehman for the idea underlying this
- application and for permission to use it as an example.
-
-
- |PAL16L8 in:IN[3..0], io:CAP[5..0]
- |
- | Active-low: CAP[5..0]
- |
- | n = 0 |Clear the input step number.
- |
- | k = 19, |For the next input step, select
- | 38, |the capacitance value that is
- | 59, |desired from the bank of
- | 83, |capacitors.
- | 110, |
- | 141, | [Step 5]
- | 176, | [Step 6]
- | 216, | [Step 7]
- | 263, | [Step 8]
- | 319, | [Step 9]
- | 384, | [Step 10]
- | 462, | [Step 11]
- | 556, | [Step 12]
- | 670, | [Step 13]
- | 813, | [Step 14]
- | 992: | [Step 15]
- |
- | { m = 99999 |Initialize the minimum deviation.
- |
- | i = 000000b..111111b: |For the next possible output
- | { j = 680 * i[5] |value, compute the capacitance
- | + 330 * i[4] |that would result by adding the
- | + 150 * i[3] |value of each capacitor enabled.
- | + 68 * i[2]
- | + 47 * i[1]
- | + 33 * i[0]
- |
- | abs(j-k) < abs(m-k): |If the newly computed capacitance
- | { m = j |is closer to the desired value
- | l = i |than the best thus far, switch
- | } |attention to the new value.
- | }
- |
- | i=5..0: |Attach the product term for the
- | CAP[i] = IN[3..0]==n & l[i] |value that fits best.
- |
- | i = line(n, m, m-k) |Display the results.
- |
- | n = n+1 |Advance to the next step and
- | } |repeat.
-
-
- | Vectors:
- | { Display (IN[3..0])d, CAP[5..0]
- | Test IN[3..0]
- | End }
-
-