Turns Counter Project An electronic circuit will be constructed using the ICAP/4 package that counts the turns of a rotating shaft. Counting shaft revolutions is a common problem. From a car odometer to a model robot, the problem is frequented in many real-world instances. This project requires a basic knowledge of algebra. It will also use elements of trigonometry, calculus and Boolean algebra that will be explained if you haven't been exposed to these subjects. If you are familiar with these topics, simply skip ahead to the Encoder Model. Pythagorean
Theorem
Later
Pythagoras, or someone from his school circa 560-480B.C., may have made
the first known proof, and the theorem bears his name. Today, there are
many proofs; the following is one of the simplest:
Circles and sine waves The
sine and cosine functions can be derived using the Pythagorean Theorem.
With the geometrical definition in figure 1, use the Pythagorean Theorem to define the following functions:
If the circle represents a shaft cross-section, then as the shaft rotates, A will change. You can find x and y as follows:
Enter pi It was recognized early on that the ratio of a circle's circumference to its diameter is a constant, no matter what the circle's diameter. We now call that constant pi. Around 2000 B.C., the Egyptians found it to be about (16/9)2 (.6% error), about the same time the Babylonians settled on 3+1/8 (.5% error). Circa 550 B.C, some argue the Bible references pi as 3 (4.5% error). Then Archimedes of Syracuse (287-212 B.B.) was the first to establish a method using polygons that can compute pi to any given accuracy, he calculated pi = 22/7 (.04% error) using 96 sides. Later, Zu Chongzhi from China (430-501) used a polygon method to compute pi to an accuracy of about one part per million. Now, with modern computers, pi has been calculated out to 1,241,100,000,000 digits. We need to know about pi to change rotational speed that we will simulate using ICAP/4 in revolutions per minute (RPM), into an angle that changes with time. First, a definition of the angular unit is needed. Degrees are used in everyday conversation, however, as a dimensionless quantity, the radian makes more sense in mathematics and engineering. Specifically, an angle A sweeps out a segment of a circle. The segment length (s) is given by s = r*A. Then A = s/r radians. When s=C, A=2*pi, so there are 2*pi radians in a circle or:
Finally RPM is converted to radians/second as follows: Angular speed=RPM * 2*pi radians/revolution*60Second/minute*time = pi/30*RPM rad/sec Next, the angle must be computed. For constant RPM, just multiply by time. However, if RPM is allowed to vary with time, we need to sum each RPM*dt, where dt is an arbitrarily small time interval, as shown in Figure 4 . As the time interval dt approaches 0, the function is defined as the integral.
Fortunately, you don't need to do any work to get the sine/cosine functions because there is already a model in the ICAP/4 library that does all the work for you. It's called Voltage Controlled Oscillator (VCO), and it performs integration using a built-in Laplace function. The sine/cosine functions are made with behavioral elements. The model is described in detail in http://www.intusoft.com/nlhtm/nl67.htm#costas . The application for that Newsletter was a 900 MegHz communications receiver. Here, the same model is used but with frequencies below 1Hz! The
Encoder Model
However, if the rotation direction is also needed, another sensor is usually added. Another pattern can also be added. The new pattern shown below (Figure 6) has the black and white stripes staggered. This arrangement is known as quadrature coding. If motion I is in the "forward" direction, then a 0-1 (black-white) transition in the "I" channel when the Q channel is false (black) is counted as a clockwise revolution. Conversely, a 1-0 transition counts as a counter-clockwise revolution. The logic reverses based on the quadrature channel so you can get 2 pulses for 1 pattern cycle.
Another way of building the quadrature signals is to stagger the sensors along a single pattern as shown in Figure_7. If half the shaft is painted white and the other half is painted black, separating the sensors by 90 degrees gives the desired result. The 90-degree separation places one of the signals in quadrature with the other.
For
shafts that are rotating, the x-y coordinate system was shown previously
in Figure 3. The radial distance
from the center of the shaft is given by r = x^2 + y^2. At an angle, A,
y = r*sin(A) and x=r*cos(A). But with A, the shaft angle changes with
respect to time. For a constant RPM, A increases with time just like the
distance you drive at a constant speed. But the speed can increase or
decrease, so you must integrate speed to obtain the correct angle. The
VCO model is used to integrate the speed input and get the sine/cosine
signals. The reflected optical signal has a cosine-tapered waveform because
the illumination is a disc shaped light beam. As the pattern passes across
the illuminating disc, the reflected light gradually changes from one
state to the other with a cosine-like shape. The disc gets larger as the
distance between the sensor and target pattern is increased and the spatial
rise-time increases. If the light beam disc diameter is known along with
the shaft diameter, then the spatial "rise-time" of the reflected
signal can be calculated as follows:
Now it is possible to have the pattern repeat in order to increase resolution. Yet, Arise is unaffected. But Arise will set an upper limit on the number of times the pattern can be repeated. Putting it all together in Figure 8 .
The ICAP/4 library models for VCO and invertex do exactly what is needed. VCO was developed for communications modulation and demodulation, while inverterx was made as a soft transition cosine shape limiter. The parameters passed into the model are:
Designing
the Decoder Next,
the up/down counting logic needs to be designed. It's first necessary
to know the current I and Q states, along with the previous states (called
Ip and Qp). The reason behind this is to be able to detect a change in
rotation direction soon after an up/down transition is made. These previous
states are measured using delay multi-vibrator (DMV) constructed using
CMOS inverters. The DMV uses positive feedback to make sharp transitions.
These DMV transitions will form the active clock edge, which is the transition
where the synchronous logic states are examined. The I, Ip, Q and Qp states
can be drawn in a logic truth table, shown in Figure
9 . To make the truth table, take the I signal with its pattern
of 0110. This pattern will repeat at the rotation frequency (RPM). Then,
Ip is the previous pattern, 0011. Similarly you can enter the Q and Qp
parts of the table. Next, reverse the rotation direction and make the
second truth table.
The logic states have been shaded to show groupings that are useful. The cyan colored groups represent "exclusive or" patterns, while the brown shade shows "exclusive or not" groupings. By inspection we can write:
Boolean Algebra Review There are three basic Boolean operations. In engineering they are called AND, OR and NOT. Mathematicians call them intersection, union and negation, and use symbols that aren't on your keyboard to represent them. Sticking with engineering notation, we'll define the following operations:
The exclusive or is encountered frequently enough to deserve its own operator; we'll use xor. A truth table is a table of all interesting states and a corresponding result. A logic equation expresses the results as illustrated in the table below for some two-input results.
Notice that A&B+A&D = A&(B + D) so that OR follows algebraic rules for addition and AND follows algebraic rules for multiplication. The completed decoder circuit is shown below in Figure 10.
The up/down pulse
widths are very short, so to see then using an oscilloscope, you must
trigger on one of the I or Q signal edges and expand the trace to 100
microseconds. Looking
further, suppose we want to use a laser to measure distance or speed.
We can construct a Michelson Interferometer and place I and Q sensors
¼ wave apart on the fringe pattern. If the light wavelength is
1 micron (10^-6 meters), then you would obtain a 4 MegHz signal for a
1 meter/second velocity. The same thing can be done with radio waves or
sound waves. The table below shows the sensitivity for 3 cases.
Table 2:
Sensitivity Counting
the Pulses and Displaying the Results Figure 12: One of 3 stages of the counter and readout display |