![]() |
|||||||
|
Electronics Reviews |
Electronic Projects |
Electric R/C Planes |
General Aviation |
Hammond Organs |
Calculator Collection |
Slide Rule Collection |
|
This is a program I originally wrote for the HP-67 calculator, and then ported to the HP-41C series. This program is for designing offset-and-gain stages using a single operational amplifier. Such stages are often necessary to convert an input signal covering one range of voltages (e.g., 0.1V to 0.2V from a sensor) to an output signal covering a different range (e.g., 1.0 to 4.0V into an A/D converter). Mathematically, such a stage performs a linear transformation on the input voltage, VOUT = m VIN + b where m is the slope and b is the intercept or offset. Given an input voltage range, VIL to VIH, and an output voltage range, VOL to VOH, the slope and offset are given by:
There are four main cases to consider, with different circuits for each, that are addressed by this program:
Positive Slope and OffsetA positive slope and offset stage is implemented by the following circuit:
The designer must select values for R1 and RF, and then appropriate values for R2 and RG can be calculated using the following formulae:
After determining theoretically ideal values for R2 and RG, real-world values can be chosen and the following formula applied to VIL and VIH to see the resulting values of VOL and VOH respectively:
This case is also used to handle the special case where b = 0 (postive gain with no offset). In such a case, the formula for R2 would result in dividing by zero, which means R2 is infinite. In other words, R2 and VREF are not needed. The value of R1 won't matter then either, and can be replaced by a direct connection. The circuit reduces to:
Positive Slope and Negative OffsetThe following circuit implements a positive slope and negative offset stage:
After choosing values for R1 and RF, values for R2 and RG can be be calculated using these formulae:
The following formula can then be used to determine the effect of real-world values of R2 and RG on the transformation:
Negative Slope and Positive OffsetA negative slope and postive offset stage is implemented by the following circuit:
Given values for R1 and RF, values for R2 and RG can be be calculated as follows:
The following formula can then be used to determine the effect of substituting real-world values of R2 and RG:
This case is also used to handle the special case where b = 0 (negative gain with no offset). As in case 1, the formula for R2 would involve division by zero, so R2 and VREF are not needed. The non-inverting input of the op-amp can be connected directly to ground, giving the following circuit:
Negative Slope and OffsetThe following circuit implements a negative slope and offset stage:
This circuit has no R1, so it is only necessary to choose a value for RF, after which R2 and RG are given by:
The effect of using real-world values of R2 and RG can then be tested using this formula:
LimitationsTheoretically, the formulae presented here work perfectly well for gains between -1 and 1 (i.e. |m| < 1). However, many real-world op-amps are unstable in such cases. Instead, it will usually be necessary to design for a higher gain (|m| ≥ 1), with an attenuator on the input side. The design procedures for this are described on Texas Instruments' Op Amp Gain and Offset Page. Using the ProgramFirst type in the program and save it, or read it from a previously recorded magnetic card. The card should be labelled as follows:
Forward Solution: Finding R2 and RGConsider the following example. A sensor has an output ranging from 0.5V to 0.7V, and we want to interface it to an A/D converter that is expecting an input between 1V and 4V. There is no reference voltage available other than the well regulated 5V supply voltage of the circuit. Use a 10kΩ resistor for R1, and 100kΩ for RF. Follow these steps to solve the problem:
NotesIt is not necessary to compute the slope and offset (by pressingA) before determining the case number. Likewise, it isn't
necessary to determine the case number (by pressing B) before
computing resistor values (although you'll want to know the case number in
order to know which circuit to build). The program keeps track of which
information is up to date, and will (re)compute anything that it needs that
hasn't already been computed.
Reverse Solution: Finding the Effect of R2 and RG on VOL and VOHThe closest available 5% resistor values for R2 and RG are 1kΩ and 6.2kΩ respectively. What effect does using these have on the solution? Follow these steps to find out:
This is within the A/D's input range at the lower bound, but outside the range at the upper bound. What happens if we use the next available value for RG, 6.8kΩ, instead?
This is almost centered within the desired output range, and covers 93% of it. The only remaining concern is how component tolerances might affect the solution. This can be analyzed by trying different combinations of R1, R2, RF, and RG representing resistors that are maximally out of tolerance (±5%) in each direction. For example, to test the case where R1 and RF are 5% low and R2 and RG are 5% high, follow these steps:
The results show that in this case, the lower limit of the output is out of range, meaning either a redesign is necessary, or tighter tolerance components are needed. Cases where b = 0In cases where the offset, b, is zero, the program will instead use b = 10-9 as the offset. This will avoid any division-by-zero errors. The program will then use case 1 (if m > 0) or case 3 (if m < 0) to compute the solution. In both cases, the computed value for R2 will be very large, typically around 109 times the value specified for R1. This indicates that R2 and VREF can be omitted, and that R1 can be replaced by a direct connection. Program Listing
Two interesting aspects of this program are its use of indirect addressing for branching to the forward and reverse solution subroutines for each of the four cases, and its use of repeated labels.
The forward solution for each of the four slope/offset cases is implemented by
a sequence of instructions starting with the label corresponding to the case
number (1 to 4). When the user presses
Similarly, the reverse solution for each case is also labeled according to the
case number. When the user presses
So, there are two each of This program also makes use of many small subroutines to compute sub-expressions common to multiple solutions. Since there were not enough labels for all the subroutines needed, the same labels were used more than once. Had this not been done, the same sequence of steps would have been repeated several times, and the program would not have fit into the calculator's 224 step memory. Registers and Flags
Revision History2009-May-26 — Initial release. Other HP Calculator ProgramsI've written programs for many of the HP calculators calculators in my collection. You may be interested in some of these:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
SubscribeShare |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||