-Abstract: brief intro, clear concise statement of problem, a brief explanation of solution and its key ideas, a description of the results obtained and their impacts.
-Include a list of keywords.
Introduction:
In the unlikely event that someone else on this planet may enjoy the pain derived from learning, I figured it would be a good idea to document my project work part by part. I'm still working out how I'd like everything formatted, but I'll attempt to keep each write-up within the topic scope.
The problem to be resolved in this topic is a smaller problem within the overarching project. To give a very brief backstory, my Jeep Comanche truck has a standalone Transmission Control Unit (TCU) which has died. Two of them died in the same manor within 6 months, leaving me with a non-functioning vehicle. To get the vehicle back up and running in a more reliable state, I figured it would be easier to design my own TCU from scratch.
In order to shift the transmission gears automatically, the TCU will require some information from the vehicle. One of these inputs will be the topic at hand. The roadspeed or output sensor is located towards the rear of the transmission and is responsible for reading the speed of the driveshaft. This reading must be processed before it becomes useful.
This can be achieved by building a circuit to bridge the gap between the raw sensor input and the micro controller that needs to read it.
Sensor:
The transmission in my vehicle is a 1999 model Aisin-Warner AW4 automatic 4 speed. This transmission was used from 1987 to 2001, with the most major change coming in 1997+ models. In addition to a different overdrive gear ratio, the later models included a different kind of output (road speed) sensor and an input speed sensor. Both of the sensors are interchangeable. See Figure 1 for a visual of the sensor locations and the transmission layout.
Figure 1:
In order for the microprocessor in the transmission control unit to determine precise speed of the input and output shafts, a sensing mechanism is required. The modern standard for this application is a variable reluctance sensor. They are very common in industrial and automotive applications. They are cheap, reliable, great for high temperature applications, and do not require an external power source as they are a type of active transducer. These sensors function by sensing the change in reluctance as a ferrous object, like metal teeth on a wheel, pass by the sensor's pole piece, varying an air gap between the two. You can think of reluctance as analogous to electrical resistance, except that it stores magnetic energy, rather than dissipate electric energy. Mounted on each end (Figure 1), they are used to measure rotational speed (angular velocity) of the transmission output shaft and input shaft respectively.
Figure 2:
The change in reluctance caused by magnetic flux can be measured as an AC voltage coming from the output wires of the sensor. This AC waveform amplitude and frequency is directly proportional to the rotational speed of the shaft. It's also dependent on the fixed size of the air gap between the top and bottom land of the teeth and the sensor poll piece, and windings in the coil. The amplitude of the waveform in this variable reluctance sensor ranges from approximately 0.1 Volts to 30 Volts.
Waveform:
The waveform generated by the sensor must be processed by an electronic circuit before it can be read by the micro controller. Data must be collected to determine the waveform. An arbitrary function generator can then be used to simulate the wave at various amplitudes and frequencies for circuit testing. Using an oscilloscope, the signal wire coming from the transmission sensor can probed.
Figure 4:
The collected probe data shows the sensor is generating a sinusoidal waveform with an exponential rise and fall that varies in amplitude and frequency (Figure 4). Using the properties of sine waves, a mathematical model can be constructed. This model can be used to create the data needed for the function generator.
Using sine to approximate a graph of the function, the values can be plotted. Graphing the values of the sensor rotation from 0 to 360 degrees converted to radians is equivalent to sin(πx) for the period of the wave (2π). With the sine wave collected in the test data (shown in Figure 4) being exponential, it must be split into two different intervals using piecewise functions to get the closest approximation. The values of sin(πx) from the interval 0 to 1 are equivalent to 180 degrees of rotation, starting at 0. This is representative of the positive half of the waveform. This same function can be duplicated, inverted, and shifted to represent the negative half of the wave. The result is two separate functions, one describing the positive half, and one describing the negative half of the waveform. This allows the pulse to be graphed on a Cartesian coordinate system to a relatively high degree of accuracy. Trial and error was used to determine the best fit exponent.
For the positive half of the function, the expression in Figure 5 can be used:
Figure 5:
For the negative half of the function, the same equation can be used, except for a negative sine value and a two unit shift to the right, with a shifted coordinate constraint of 1 to 2 on the x-axis (Figure 6):
Figure 6:
This gives a full 360 degree simulated rotation, mapped from interval 0 to 2 on the grid (Figure 7):
Figure 7:
Now that the equations are known and the interval is set, it needs to be mapped to a larger range. The arbitrary function generator uses a digital input file with a list of 2048 values in rows. These values are representative of y-values in Cartesian coordinate form with the 0 to 2048 being x-values. To get the derived equations into a readable state for the function generator, the interval can be remapped from 0 to 2, to 0 to 2048 on the x-axis. Since both values start at zero, two can be divided by (2048 - 1) and the resulting value multiplied by x. (Multiplying x by the reciprocal of 2047/2). This gives the results in slope-intercept form (Figure 8):
Figure 8:
The data can be plotted in Excel by creating 2048 points, starting at 0 and ending at 2047. Entering the formula in Figure 8 for the X Column, Figure 5 formula in the Y column from 0 to 1023, and Figure 6 formula in the Y column from 1024 to 2047. A sample portion of these values are shown (Figure 9) below:
Figure 9:
The values in the Y column can be copied to a file and uploaded to the function generator. Once configured, the function generator can be attached to an oscilloscope and the signal can be viewed (Figure 10):
Figure 10:
An overlay comparison of the transmission waveform is shown below (Figure 11):
Figure 11:
Circuit Design:
Now that the waveform can be simulated, the next steps involve designing a circuit that processes it into a digital signal that can be read by a microcontroller. This will allow the signal reading to be manipulated with code.
When designing a circuit and schematic, it's important to reference the datasheets for any Integrated Circuit (IC) chips or active components you're implementing as there are a near endless number of variations for any particular component or circuit module. Any relevant details or special characteristics from the datasheets will be detailed when necessary in the appropriate sections.
The circuit can be broken down into four sections: Rectification, buffering, Schmitt Trigger action, and level shifting. The sensor input wire will connect to the circuit and the signal generated on the wire, by the sensor, will flow through a rectifier. This function will clamp the wave to allow only positive voltages. This is necessary due to a characteristic of the integrated circuit used in the buffering and Schmitt Trigger stages of the circuit. Once rectified, the signal will flow into the buffer. Buffering the signal will create a stable wave source with a set peak amplitude and reduce electromagnetic interference. From the buffer, the signal will flow into a Schmitt Trigger, which will convert the sine wave to a square wave. This output signal will be inverted. A transistor will revert the signal and level shift it to the correct output voltage. The final output is passed to a microcontroller for manipulation by code. Each section of the circuit will be expanded in detail. The circuit schematic with all labeled figures is shown below (Figure 12):
Figure 12:
Half-Wave Rectification:
The first step in converting the waveform to a readable signal is half-wave rectification. This converts the alternating current to direct current, so only the positive half of the wave is passed through the circuit. It is necessary due to a characteristic of the operational amplifier in the next stage of the circuit. The datasheet of the op amp states that when the voltage across the inverting (-) and non-inverting (+) pins goes more than 0.3 Volts negative, the op amp will output that value at it's maximum positive voltage. This is undesirable as the wave only needs to be counted once. Additionally, the negative portion of the wave is excess information and does not need to be saved. This rectification can be achieved by using a rectifying diode (which is a regular diode) in series from the sensor input signal. The rectification can be modeled mathematically using a ramp max function (Figure 13):
Figure 13:
Shown in Figure 13 is the definition of a ramp max function. Setting the b variable to 0 and the a variable to the independent variable being evaluated (sin(x) will be used for this example and the simulated circuit diagram as it is a smoother approximation that will work interchangeably to the real signal) gives the mean value of sin(x) and it's absolute value:
Figure 14:
Plotting this function (Figure 14) on a graph models the behavior of half-wave rectification in a circuit. This function can be seen in the Figure 12.2 circuit diagram oscilloscope.
If this rectification were to be performed using the two equations in Figure 5 and Figure 6, the entire second equation (Figure 6) would be equal to zero from 1 to 2 on the graph, giving the rectified function for the input signal (Figure 15):
The circuit pointed to in Figure 12.1 can be constructed and tested. Note that the oscilloscope in Figure 12.1 is pointing at the input of the signal and the beginning of the rectifier diode circuit, while the actual rectified signal is shown in shown in Figure 12.2. A 1N4454CT-ND general purpose diode is used in this circuit, with a 100K Ω resistor to ground to consume the direct current generated by the diode. Since a 100K Ω resistor is used and the Forward Voltage (VF) of the Diode is known for a lower current, using Kirchhoff's Circuit Laws and Ohm's Law, the following formula can be created:
Figure 16:
Where the following variables are defined:
VS: Input voltage from 0 Volts to 30 Volts.
VF: Forward Voltage of the Diode. The datasheet says 250 uA of current through the diode gives 0.505 V forward voltage.
R1: Load Resistor. A value of 100,000 Ω will be used. This limits the current to a very small value.
I1: Current through resistor.
The current can be solved for using some algebra (Figure 17). This also lets us know the voltage across the resistor and the current through the diode at any given input voltage. This is important to make sure too much current is not flowing through the diode and the forward voltage remains stable.
Figure 17:
Plugging in the selected resistor value and the forward voltage of the diode taken from the datasheet, a test voltage for VS can be substituted to determine max current. A real-life test can also be performed (Figure 18).
Figure 18:
Setting VS equal to 3 Volts from the equation in Figure 18 gives a current of ~25 uA. This means the forward voltage of the diode will be very close to 0.5 Volts.
A picture of the half-wave rectification circuit test is displayed below in Figure 17. This test was done with a 6 volt amplitude, which when split produces 3 volts minus the diode forward voltage. Each vertical division on the scope in Figure 19 represents 1 volt.
Figure 19:
Seen in Figure 19 is the rectified signal with a 0.5 Volt forward voltage drop of the diode.
If the peak sensor voltage of 30 were entered into the equation in Figure 18, the current through the diode would be 295 uA. This is just slightly above the datasheet forward voltage spec of 0.505 Volts @ 250 uA, but well within maximum current specs by more than an order of magnitude for the diode. This means that even at 30 Volts, the forward voltage should be stable at around 0.5 Volts.
The next stage of the circuit will take the half-rectified analog signal and convert it into a digital square wave. A set of operational amplifiers will be used to achieve the signal transformation. One operational amplifier will be used for signal buffering (Figure 12.2) and a second for signal transformation (Figure 12.3).
The common operational amplifier, such as a LM324N (used in this project), is an analog voltage amplifier with a multitude of applications. The datasheet lists all relevant specification data for the chip, as well as information on how the IC will behave under certain conditions. In circuit schematics, op amps are commonly represented as a sideways triangle. This specific chip has four internal op amps which can each be used independently. The main characteristics of this kind of op amp are it's dual inputs represented by the + and - shown in Figure 12, and a very high internal amplification, known as gain. The magnitude of this gain can be described as infinite as long as the op amp is in an open loop configuration (no negative feedback). The inputs are more commonly known as the op amp's non-inverting (+) and inverting (-) inputs. These inputs have a very high impedance, meaning that no current flows through them. Think of them as read only. The voltage difference between these inputs, known as the op amp's differential voltage, is multiplied by the device's internal gain at the output pin when in an open loop configuration. For most applications of the op amp, a closed loop configuration is used. This is known as applying negative feedback to the circuit.
Negative feedback allows the gain and circuit response to be controlled externally via the feedback network. This network may be comprised of various components such as capacitors, diodes, and resistors, or just a single wire. Negative feedback is achieved by tying the output of the op amp back into the inverting (-) input. When the op amp is configured in this manner, the internal circuitry of the chip does whatever it can to make the voltage at the inverting (-) and non-inverting (+) terminals equal by driving the output voltage through the feedback network.
For the case of the first stage of this circuit, the most basic form of negative feedback is used to reduce the gain. When the output of the op amp shown near Figure 12.3 is connected back to the non-inverting (-) input, this negative feedback loop provides the op amp with a stable output value that will track the input up to the output voltage maximum value.
Op amps can only output a voltage as large as their power supply input voltage. When this voltage is reached, the op amp is at saturation. In most cases, there is a set voltage the output will saturate at based on the supply voltage. Referencing the datasheet for the LM324N shows that this voltage is 1.5V below whatever the op amp is being supplied with. This means the op amp output voltage will saturate at (3.3V - 1.5V) = 1.8 Volts in this circuit. In the diagram, the power supply input and output are shown on the top and bottom middle of the sideways triangle schematic.
A Schmitt Trigger is needed to convert the rising and falling analog wave signal to a high or low digital signal. Having a voltage that is either high or ground allows the micro controller to process the reading correctly as it uses binary states on the pin that reads the signal.
Figure 20: Shown below is the final product of a Schmitt Trigger The input and output voltages are overlaid.
Schmitt Trigger
A Schmitt Trigger is an active electronic comparator circuit that consists of several voltage thresholds and a differential amplifier. Abstract out a layer and think of the Schmitt Trigger as a function with an input and an output. When an input to the Schmitt Trigger rises above or falls below a respective voltage threshold, the output of the circuit is sent low or high depending on the configuration. This kind of circuit is primarily used to convert an analog electronic signal to a digital electronic signal. Since the Schmitt Trigger in this circuit is constructed with an Operational Amplifier, and the input to it is connected to the amplifier's Inverting (-) pin (Figure 12.4), the output signal is inverted.
Recalling that Operational Amplifiers have a close to infinite impedance on their inverting (-) and non-inverting (+) pins (meaning that no current can flow into them), a Schmitt Trigger circuit can be visually simplified and represented as a set of voltage dividers (Figure 23 & 24). This is helpful to derive the resistor values needed for the high state and low state of the trigger.
These resistor values will create a voltage "window" that will act as a buffer space between when the circuit switches to a high or low output. More specifically, adding in a third resistor that ties the output of the Schmitt Trigger Operational Amplifier back to the resistor network allows a voltage window to be created. This means that when the circuit switches high, the voltage on the input must then drop below a different value (instead of the same value) before it switches back to low. This is known as Hysteresis. It is essential to prevent noise and interference from "bouncing" the signal back and fourth thousands of times a second. Here is an example of a Schmitt Trigger with too little Hysteresis. If this output were to be read by a microcontroller, the signal would be jumping high and low thousands of times each second, making reading impossible as the signal is unable to stabilize. This is visualized by the filled in area below the circuit, which also traces out the path of the input signal as it rises. (Figure 21):
Figure 21: Shown below is how an output signal looks with too little Hysteresis. The shaded area represents the output signal switching back and fourth, unable to stabilize.
Figure 22: Shown below is how a normal output signal would look with the correct Hysteresis.
Two corresponding figures simplify the function of the Schmitt Trigger, each representing when the Schmitt Trigger output is either high or low respectively. These figures are broken down and described in detail below.
Figure 23: Figure 24:
These figures can be analyzed independently to give the equations needed to set the high and low trigger voltages. In each of the figures, the center line where all three resistors come together can be thought of as a single node shared between both figures. The voltage at this node will change based on the input to the Operational Amplifier via feedback. Solving for this node gives the corresponding high and low voltage thresholds around the Hysteresis window. The equations can be built using Kirchhoff's Voltage Law and Ohm's Law.
Mentioned earlier, that in order to create a Hysteresis window, a third resistor must be added. This resistor (R₂) will connect to the output of the Operational Amplifier in the Schmitt Trigger circuit. It is shown in the Figures 23 & 24 as being parallel with either R₁ or R₃ respectively depending on the input state.
Also shown are the input voltages, where VIN₁ is a reference voltage that is always at a stable value throughout the cycles of the circuit. For this circuit, this reference value is the same as the supply value to the Operational Amplifier, 3.3 Volts.
The value of VIN₂ will change based on the input state of the circuit. Since the Operational Amplifiers in this circuit have a maximum output of 1.8 Volts, based on their supply voltage, the value of this variable, VIN₂, will be either 1.8 Volts or 0 Volts. If the input to the circuit is 0 Volts (ground), the value of VIN₂ will be 1.8 Volts (since the circuit inverts the output). If the value of the circuit is a positive voltage above a certain value, VIN₂ will be 0 Volts (ground). See Figure 12.3-12.4 for clarity via an animation.
Representing the figures above as having two resistors total, instead of three simplifies the problem into a general equation for which values can be substituted in. To do this, the pairs of resistors that are parallel to each other can be simplified and represented by a single variable. Resistors in parallel can be calculated by summing their reciprocals and taking the reciprocal of the sum:
Figure 25: Substituted Parallel Resistor Value for Figure 23
Figure 26: Substituted Parallel Resistor Value for Figure 24.
Finally, recalling that VIN₁ has a different value from VIN₂, these voltages will average and can be represented as a variable in Figure 23:
Figure 27: Combined parallel voltages.
Figure 28:
Now that the equation for the total current is known, the voltage at the center node can be analyzed. Kirchhoff's Voltage Law and Ohm's law can be used to derive an equation for the output voltage at this node. Solving with algebra states that the voltage out of the center node is equal to the current times the resistance of R₃.
Figure 29:
Substituting in the value I into this equation (Figure 29) gives the general form for what is known as the voltage divider equation (Figure 30):
Figure 30:
General Voltage Divider Equation:
Substituting in the modified parallel resistor values and the total voltage values gives the full equation for Figure 23:
Figure 31:
An equation for Figure 24 can now easily be constructed via substitution into the general voltage divider equation.
Figure 32:
Replacing RM 2 with the previously substituted value and noting that there is only a single VIN, gives the full equation for Figure 24 shown below (Figure 33):
Figure 33:
Factoring the equations in Figure 31 & Figure 33 will give a much cleaner and easy to work with set of equations. Starting with Figure 31 shown below (Figure 34):
Figure 34:
Factoring Figure 33 in a similar fashion gives the second equation for the voltage at the node, shown below (Figure 35):
Figure 35:
Figure 36: The two equations for the voltage at the node.
https://www.desmos.com/calculator/8w8ksn59iy
y = (x - a) * (d - c) / (b - a) + c
VVVVVVVVVVVVVVVVVVVVVVVVVV PROBABLY REWRITE THIS VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
0.1=0.03030303*3.3
This sets the upper trigger point to 0.1 Volts
0.03030303
This is the ratio required to stay at a 0.1 trigger voltage, assuming voltage remains at 3.3.
0 .03030303=x/(x+y) 1/0.03030303=1/x/(x+y) 33=(x+y)/x 33=y/x+1 32=y/x y=32x
https://www.google.com/patents/US4700133?dq=variable+reluctance&hl=en&sa=X&ved=0ahUKEwjF49b7n_rWAhVKJCYKHc5XAtsQ6AEIZzAJ https://www.google.com/patents/US6433534?dq=variable+reluctance+automotive&hl=en&sa=X&ved=0ahUKEwi0-Ia0vPrWAhULQSYKHeqAABUQ6AEIKDAA
No comments:
Post a Comment