Date post: | 03-Jun-2018 |
Category: |
Documents |
Upload: | piromaniacos |
View: | 220 times |
Download: | 0 times |
of 11
8/12/2019 Capacitive Angle Transducer _CAT
1/11
1
Author: Jeremy Leach Email: [email protected] June 2006
IntroductionThis article describes an experimental PICAXE-
based transducer that detects angular displacement ofa shaft. It relies on the variation in capacitance
between 'plates' of aluminium foil, therefore the name
"Capacitive Angle Transducer" or CAT !Commercial transducers are available that rely on
variation in capacitance and there are a number of
techniques used, often with considerable complexity(Capacitive Angular Displacement Transducers).
This project is a relatively basic idea compared to
commercial versions, but proves that a basic, cheap
transducer giving 32-Sector resolution seems
possible.
It has proved fascinating to make working capacitors
out of household materials, and there is much moreexperimentation that can be done. This project also
demonstrates the power and versatility of the
PICAXE08M chip.
ACKNOWLEDGEMENTS
PICAXE is a trademark of RevolutionEducation Ltd.
PICAXE Forum http://www.rev-ed.co.uk/picaxe/forum/
IN THIS ARTICLE
2 Basic Principles
3 Details of the CAT
3 Measuring Capacitance
5 Real Capacitance Graphs
5 Algorithm to read the Graphs
7 Conclusion
PDF created with pdfFactory trial version www.pdffactory.com
mailto:[email protected]://www.rev/http://www.pdffactory.com/http://www.pdffactory.com/http://www.rev/mailto:[email protected]8/12/2019 Capacitive Angle Transducer _CAT
2/11
2
Figure 1 : Ideal Graph
0 90 180 270 360Degrees
Capacitance
Figure 2 : The Base
Figure 3: The Disc
Basic principles
A variable Air Capacitor
An 'Air capacitor' consists of two conducting 'plates'
a small distance apart. The 'dielectric' is air and thecapacitance is represented by this general formula:
C = A/D + C0
Where:
= Relative-permittivity of the dielectric.
A = area of overlap of the plates.
D = distance between the plates.
C0 = a constant for the 'stray' capacitancebetween the plates and other conductors.
By having plates that rotate, it's possible to make a
variable capacitor, where the capacitance varies
depending on the overlap between the plates. Radio
sets have typically used variable air capacitors, which
have two sets of interleaved plates or 'vanes'.
This is the basic principle behind the CAT. It
measures the capacitance between plates, and
'knowing' the relationship between overlap andangular displacement, calculates and outputs anglevalues.
Unambiguous output
The transducer must generate a unique output for
each unit of angular displacement. A bit of thought
shows that, whatever the shapes of the plates, it's not
possible to have a unique capacitance value for each
angle. In general there will be at least two positions
of the shaft that give the same capacitance value.
One way of getting round this problem would be to
know the starting angle and for the transducer to
'deduce' the most likely angle out of the two or more
choices. This is entirely feasible, although it relies on
the shaft position being sampled rapidly compared tothe rotation speed.
Dynamic duo
My solution uses two variable capacitors. This does
allow a unique transducer output per angular unit.
Figure 1 shows an ideal output of capacitor valuesagainst angular displacement. Each angle has a
unique combination of capacitance values. Thegraphs for each capacitor are out of phase by 90
PDF created with pdfFactory trial version www.pdffactory.com
http://www.pdffactory.com/http://www.pdffactory.com/8/12/2019 Capacitive Angle Transducer _CAT
3/11
3
Figure 4 : Shaft Contact
degrees. The straight-line segments would berelatively easy to implement in code.
This output is also useful for 'auto-scaling', which is
discussed later.
Details of the CATThe title picture shows the prototype unit. A disc is
attached to a copper shaft and rotates over a 'base'. I
stuck a computer-generated pattern on the disc
showing sectors to approximately 5.625 degrees.
Figure 2 shows the base, with three separate sectors
of aluminium foil, but actually only two adjacentsectors being used. The foil is glued to the MDF base
using contact-adhesive, which seems to work well
and produces a very flat foil surface.Figure 3 shows the disc, which rotates above the
base. I made the disc out of the lid of a CD holder.
The plastic is very brittle to cut but is nice and flat.
The copper shaft is literally a piece of thick copper
wire, carefully rolled until straight. The shaft rests ina hollow on a small piece of metal sheet, shown in
Figure 4. The shaft is electrically connected to thedisc by a thin wire on top of the disc.
For best operation it's critical to get the disc as close
as possible to the base in order to achieve themaximum fluctuation in capacitance. It's alsoimportant to avoid any tilt in the disc. I managed to
get a pretty consistent gap of around 1 to 2 mm.
Measuring capacitanceThere are two sectors on the base each of 90 degrees,
and a single 180 sector on the rotating disc. This
arrangement gives two independent variable
capacitors.
Figure 5 shows the CAT circuit, with C1 and C2
being the variable air capacitors. Figure 7 shows the
circuit constructed on Strip-board. Figure 8 and
Figure 9 show the Strip-board layout.
The PICAXE generates a 250KHz signal on Output
2, which is fed into the variable capacitors via the
copper shaft. Each variable capacitor has an
associated resistor (C1 and R4; C2 and R7). Each R-
C pair is therefore a high-pass filter.
The output from each filter feeds into a unity gainbuffer in the LM358N dual Op-amp, and then to a
low-pass RC pair which extracts a DC voltage
corresponding to the amplitude of the AC voltage
from the filter. This DC voltage feeds into aPICAXE ADC input. The PICAXE reads the ADC
values, and translates them to angular displacement
information that is output serially via Output 0.
The frequency of the driving signal and the values ofR4 and R7 have been chosen carefully. A simple
PICAXE program was written that generated a range
of frequencies and captured ADC values while thevariable capacitor C1 was fixed at it's maximum
overlap and R4 = 47K. The response curve is shown
in Figure 6. Note that the PICAXE can only generate
a selection of frequencies, which are shown as steps
in the graph. I've added a smooth trend-line to the
graph.
From this graph the ADC value reaches it's
maximum value when the driving frequency is
around 230KHz. If the driving frequency is fixed at
this value, then variation in capacitance will give a
good variation in ADC values.
250KHz is the nearest value that can be generated bythe PICAXE, so this is the frequency I've used.
R4 and R7 should ideally be metal film to minimise
the effect of temperature. 50ppm per degree is a
quoted figure. The Op-amps have high inputimpedance and low output impedance with unity
gain, and so are not expected to show anytemperature-related effects.
The values of R5 and R6 aren't too critical becausethey effectively just determine the responsiveness of
the smoothing capacitors C4 and C5 to changes inDC level. I chose tantalum capacitors for C4 and C5
PDF created with pdfFactory trial version www.pdffactory.com
http://www.pdffactory.com/http://www.pdffactory.com/8/12/2019 Capacitive Angle Transducer _CAT
4/11
4
Figure 5 : CAT Circuit
0V
O0/Serout
I/O1
I/O2
+ V
Serin
I/O4
I3 PICAXE
08M
IC1C3
0.1uF
+
22K
R2
10k
R1
Download
4K7
R3
R7(Me
tal
Film
)
47K
+ 5V
GND
250KHz Signal
C4
1uF
+R4(Me
tal
Film
)
47K
+ V
Out B
InB -
InB+
Out A
InA -
InA+
- V LM
358N
IC2R5
10K
C1
C2
R6
10K
C5
1uF
+
D1
(Shottky)
Figure 6 : Frequency response of R-C combination
Frequency Response
0
50
100
150
200
250
0 20 40 60 80 100 120 140 160 180 200 220 240 260
F KHz
ADC
Value
C1ADC
Poly. (C1ADC)
PDF created with pdfFactory trial version www.pdffactory.com
http://www.pdffactory.com/http://www.pdffactory.com/8/12/2019 Capacitive Angle Transducer _CAT
5/11
5
Figure 7 : Strip-boarded circuit
Figure 8 : Strip-board topside
GND
I/O1I/O4
SOutSIn
I/O2I3
Vcc
IC8
PicAxe08M
R34K7
R2
22K
R1
10K
21
3
J1
C3
ST1
1
2
C5+
R7
47K
A+ B-
OB
V-
V+OA
B +
A-
IC5
LM358N
R6
10K
R5
10K
C4
+R4
47K
GND
I/O1I/O4
SOutSIn
I/O2I3
Vcc
IC8
PicAxe08M
R34K7
R2
22K
R1
10K
21
3
J1
C3
ST1
1
2
C5+
R7
47K
A+ B-
OB
V-
V+OA
B +
A-
IC5
LM358N
R6
10K
R5
10K
C4
+R4
47K
GND
I/O1I/O4
SOutSIn
I/O2I3
Vcc
IC8
PicAxe08M
R34K7
R2
22K
R1
10K
21
3
J1
C3
ST1
1
2
C5+
R7
47K
A+ B-
OB
V-
V+OA
B +
A-
IC5
LM358N
R6
10K
R5
10K
C4
+R4
47K
Figure 9 : Strip-board underside
GND
I/O1I/O4
SOutSIn
I/O2I3
Vcc
IC8
PicAxe08M
R3
4K7
R2
22K
R1
10K
21
3
J1
C3
ST1
1
2
C5
+
R7
47K
A+ B-
OB
V-
V+OA
B +
A-
IC5
LM358N
R6
10K
R5
10K
C4+
R4
47K
GND
I/O1I/O4
SOutSIn
I/O2I3
Vcc
IC8
PicAxe08M
R3
4K7
R2
22K
R1
10K
21
3
J1
C3
ST1
1
2
C5
+
R7
47K
A+ B-
OB
V-
V+OA
B +
A-
IC5
LM358N
R6
10K
R5
10K
C4+
R4
47K
because this type has low leakage current.
Normal temperature variation is not likely to affect
the capacitance of the variable capacitors
significantly. The expansion of the copper shaft etc
should not be too great, and if it was then the shaft
could be shortened. The aluminium in the disc andbase shouldn't expand or contract much at all.
Overall I believe that temperature effects are
therefore minimised. However a significant factor totry to take account of is the variation in capacitance
with humidity. This is discussed later.
Real capacitance GraphsFigure 10 shows graphs of the ADC values recorded
for one rotation of the disc. The values weresurprisingly stable at the time of reading them,
fluctuating by only +/- 1 digit. A clear difference
between these graphs and the 'Ideal' of Figure 1 is the
sloping top sections. My explanation for this is that
there is probably a slight tilt to my shaft - but I can'tsee it easily!
The lack of 'flat tops' is a pity, but nevertheless these
are useable graphs, which demonstrate unique pairs
of values for each angle of rotation.
Another feature of the graphs is the generalsmoothness, which is possibly due to effects at the
edges of the foil plates.
Also, the values fall to zero, or almost zero, when
there is no overlap of foil. This is a good thing and
shows that stray capacitance in the foil, connecting
wires and strip-board tracks is very low. Which
means that the capacitance equation is more like:
C = A/D
This means that changes in the permittivity of the airdue to fluctuations in humidity are likely to increase
the capacitance values in a linear fashion.
Algorithm to read the GraphsThe full code listing is given at the end of this article.
The basic job of the PICAXE software is to take the
pair of ADC values and translate them into angular
displacement. However in addition to this, the
software must also allow for tolerance in the
readings, and fluctuation of the readings due tohumidity changes.
There are a number of methods that could be used to
PDF created with pdfFactory trial version www.pdffactory.com
http://www.pdffactory.com/http://www.pdffactory.com/8/12/2019 Capacitive Angle Transducer _CAT
6/11
6
Figure 10 : ADC values vs Angle
ADC Value vs Angle
0
10
20
30
40
50
60
70
80
90
100
110
120
130
140
150
160
170
180
0 45 90 135 180 225 270 315 360
Angle in Degrees
ADC
Value
C1
C2
achieve this, and I've experimented with a few.
However the programming space on a PICAXE08M
is limited, so whatever method is used has to be
simple and effective.
Translation
I've stored the graphs in 64 bytes of EEPROM as
sequential pairs of readings. When a new pair of
values is obtained, the values are compared to thoseon the graph until a matching 'scenario' is found.
What this means in detail is that the reading relating
to Capacitor1 lies between a pair of data-points on
the C1 graph, and the reading relating to Capacitor2lies between the associated pair of data-points on the
C2 graph.
Tolerance
Because there is slight fluctuation in ADC readingsfor a fixed shaft position, a tolerance value is
employed, which allows values to be 'matched' that
fall slightly outside the data-point ranges.
The tolerance value starts small. The graph data is
scanned. If the end of the graph is reached and no
matching scenario has been found, then the graph
data is scanned again with a slightly increased
tolerance.
This process will repeat a number of times until amatch is found, or the tolerance reaches a maximum
value, at which point an error value (Sector = 32) is
generated.
Auto Scaling
Humidity is likely to change the capacitance in alinear fashion. This will affect the range of ADC
values obtained when the disc is rotated. The ADC
values are not a direct measure of capacitance and
the relationship between how the ADC values
change with capacitance is complex. However as a
fairly good approximation, I've assumed that the
ADC Value graphs scale in a linear way as Humiditychanges. To do anything more complicated is not
easy with the limited code-space available!
The code detects the special condition where theADC values are equal (or nearly equal) then
compares this value to the same point on the internal
-graphs, and calculates a 'gain' value to apply to the
PDF created with pdfFactory trial version www.pdffactory.com
http://www.pdffactory.com/http://www.pdffactory.com/8/12/2019 Capacitive Angle Transducer _CAT
7/11
7
Figure 11 : Flowchart
ADC Values equal
(special condition)?
Initialise
Adjust Gain
Calculate Normalised
ADC Values
Loop
Yes
No
Find Matching
Scenario from
internal Graphs
Output Sector
Sector = 32 (Error)
Tolerance =
MinimumTolerance
Increment
Tolerance
Tolerance
Maximum
Value?
No Match
No
Yes
Match
Read ADC Values
ADC values. There are two shaft positions where thespecial condition is met, but only the one with the
higher ADC values is used, in order to get best
granularity of the gain value.
The gain 'normalises' the range of ADC values to
match those of the internal graphs. The gain isadjusted automatically whenever the shaft is in the
correct position. (In the ideal graph, the auto-scaling
could occur over a whole 90 degree range).
Whether this solution to address humidity variation
really works well is difficult to say as I've only testedthe CAT over a few days, and the automatic
adjustment in gain has been small.
The gain value is held as 'GainNumerator' and
'GainDenominator' bytes in code. This is an effective
way of performing an accurate multiplication usinginteger arithmetic.
CAT Output
The CAT outputs values via a Seroutcommand. At
present I read the output via the 'Terminal' program
in the PICAXE Programming Editor. However in a
real application, the output pin could be connected to
other PICAXE chips etc.
The CAT outputs a 'Sector' number from 0 to 31
(which avoids using a Word value for 'Angle'). Alsothe gain numerator and denominator value, to
indicate when re-scaling has occurred.
An outline software flow is shown in Figure 11.
ConclusionThis project should be classed 'proof of concept'. It
demonstrates that it's possible to build working
variable air capacitors out of basic household
materials, and it's possible to make a working
transducer with a simple circuit, relying on the powerand versatility of the PICAXE08M chip. It also hints
at further possibilities using home-made capacitors.
The likely accuracy of this transducer is admittedly a
bit questionable. I haven't put it through any thorough
testing, but it seems to work well to 32-sector
resolution.
There are limitations in the design that would need to
be considered if it was used for any serious
application. For instance, the copper shaft simplyrests on a metal 'dent' contact, which is not fantastic.I've used a small piece of aluminium for this contact
and think I've already experienced some oxidation
problems at the point of contact.
It's also not clear how this transducer could be used
in real-life. A key feature is low shaft-friction with
no mechanical contact with any gears etc.
Optical solutions also have this advantage, although
to make your own optical encoder to 32-sector
accuracy might need multiple sensors and perhaps be
harder to achieve.
v
PDF created with pdfFactory trial version www.pdffactory.com
http://www.pdffactory.com/http://www.pdffactory.com/8/12/2019 Capacitive Angle Transducer _CAT
8/11
8
PICAXE Code'***************************************'* *'* CAPACITIVE ANGLE TRANSDUCER (CAT) *'* Version:1 *'* Author:Jeremy Leach 2006 *
'* *'***************************************
'**********************'**** LOOKUP TABLE ****'**********************
'NOTE: Data is stored in the Lookup Table in a sequence of 32 pairs of'Cap2Value>.'The first pair in the table is for Angle = 0 degrees,'the last pair for Angle = 348.75 degrees (11.25 degrees * 31).
Eeprom0,(169,9,164,19,159,29,152,44,146,59,141,76,136,93,127,118,118,143,94,142,70,142,50,138,31,135,20,131,10,128,5,122,0,116,0,98,0,81,0,65,0,49,0,36,1,24,3,17,5,10,18,8,32,6,58,5,85,4,111,4,137,4,153,6)
'**************************'**** GLOBAL VARIABLES ****'**************************'Word0 (b0 and b1) SymbolCap1ADCValueLSB = b0 Symbol Cap2ADCValueLSB = b1'Word1 (b2 and b3) Symbol TempValue = b2'Word2 (b4 and b5) Symbol CheckValue = b4 Symbol Tolerance = b5'Word3 (b6 and b7) Symbol SectorIndex = b6 Symbol IsBetween = b7'Word4 (b8 and b9) Symbol GainW = w4 Symbol GainNumerator = b8 Symbol GainDenominator = b9'Word5 (b10 and b11) Symbol Address1 = b10 Symbol Address2 = b11'Word6 (b12 and b13) Symbol Value1 = b12 Symbol Value2 = b13
'*******************'**** CONSTANTS ****'*******************'Pin assignmentsSymbol Cap1InputPin = 1Symbol Cap2InputPin = 4Symbol PWMOutPin = 2Symbol ResultOutPin = 0
'Character constants
PDF created with pdfFactory trial version www.pdffactory.com
http://www.pdffactory.com/http://www.pdffactory.com/8/12/2019 Capacitive Angle Transducer _CAT
9/11
9
Symbol COM = 44 'commaSymbol RET = 13 'carriage returnSymbol LFEED = 10'line feed
'Other constantsSymbol MaxSectorIndex=31Symbol LookUpTableEndAddress=63Symbol Yes = 1
Symbol No = 0Symbol C1C2HighCrossover = 125Symbol ErrorSector = 32Symbol MinimumTolerance = 2Symbol MaximumTolerance = 10Symbol DifferenceThreshold = 3Symbol DoubledDifferenceThreshold = 6
'***********************'**** RAM POINTERS *****'***********************
'*********************'**** INITIALISE *****'*********************
PwmoutPWMOutPin,3,8'Sets a 250KHz signal with 50:50 DutyGainW= 257 'Set Gain Numerator and Denominator both to 1.Pause 1000 'To let the smoothing capacitors charge
'************'*** MAIN ***'************
GetAndTransmitSector:
'READ THE ADC VALUES 'Although ReadADC10 is used, only the lower byte 'is relevant as the ADC values do not exceed 255. Readadc10 Cap1InputPin,Cap1ADCValueLSB Readadc10 Cap2InputPin,Cap2ADCValueLSB
'CHECK FOR 'HIGH CROSSOVER' SCENARIO TempValue=Cap1ADCValueLSB-Cap2ADCValueLSB+DifferenceThreshold IfTempValue > DoubledDifferenceThreshold Or Cap1ADCValueLSB < 40 ThenGATS_2
'ADJUST GAIN GainNumerator = C1C2HighCrossover GainDenominator = Cap1ADCValueLSB
'NORMALISE THE ADC VALUES GATS_2: Cap1ADCValueLSB=Cap1ADCValueLSB * GainNumerator / GainDenominator Cap2ADCValueLSB=Cap2ADCValueLSB * GainNumerator / GainDenominator
'FIND SECTOR 'Scan the Lookup table for a scenario that fits the normailised ADC 'values and return the associated SectorIndex. 'If a Scenario can't be found then set SectorIndex = ErrorSector Tolerance=MinimumTolerance-1
FS_1:
Tolerance=Tolerance + 1 ForSectorIndex = 0 ToMaxSectorIndex
PDF created with pdfFactory trial version www.pdffactory.com
http://www.pdffactory.com/http://www.pdffactory.com/8/12/2019 Capacitive Angle Transducer _CAT
10/11
10
'Check if Cap1ADCValue is between the indexed Cap1 data points from the 'Lookup Table.
CheckValue=Cap1ADCValueLSB Address1 =SectorIndex * 2 GosubCheckIfBetween If IsBetween = No ThenFS_2
'Check if Cap2ADCValue is between the indexed Cap2 data points from the 'Lookup Table.
CheckValue=Cap2ADCValueLSB Address1 =Address1 + 1 'Note Address1 is not corrupted by CheckIfBetween. GosubCheckIfBetween If IsBetween = Yes ThenGATS_3
FS_2: Next
'Try relaxing the tolerance IfTolerance
8/12/2019 Capacitive Angle Transducer _CAT
11/11
11
Value1=Value1/240Xor1*Value1 Value2=Value2/240Xor1*Value2
'Check if the CheckValue is between Value1 and Value2. CIB_2: IsBetween=No
IfCheckValue =Value1ThenCIB_5
IfCheckValue >Value1ThenCIB_3 IfCheckValue >= Value2ThenCIB_5 Return
CIB_3: IfCheckValue < Value2 Then CIB_5 Return
CIB_5: IsBetween = Yes Return