Professional Documents
Culture Documents
Technical Data 2
Practical Instructions 3
Program Operation 5
DR300 Software 7
i
Laboratory Setup Speed Control DR300 Assembly and Start-Up
Date: 18.12.2000
1.5.5 Mains Supply and Signal Adaption Unit (POWER module) . . . . . . . . . . . . . . 1-3
The standard shipment of the DR300 consists of: 1.2 Setting up the System
• The DR300 mechanical setup consisting of two
DC motors with one tacho generator and one 1.2.1 DR300 Mechanical Setup
incremental encoder completely mounted and
wired. The lead to connect the DR300 mechanical Choose a place, where the system is not exposed to
setup to the actuator is fixedly mounted to the extreme temperatures. In particular direct sun light and
mechanic. direct heat radiation, e. g. by a radiator, are to be avoided.
Otherwise the Plexiglas cover could be damaged.
• A 19" module box (actuator) containing power
supplies, servo amplifiers operating as current The system must be placed on a solid surface.
controllers, signal adaption unit and a module for
measuring outputs. 1.2.2 Actuator
• A mains supply lead. The air must be able to circulate freely above, below as
well as behind the actuator box.
• A manual containing detailed documentation of
the hardware and software. Do not use a soft surface. Otherwise the ventilation slots
located on the bottom of the actuator box could be covered
Depending on the desired system option, the shipment due to its weight.
also includes the following items:
Do not place any objects, e. g. manuals on top of the
• Option 300-01 actuator box. (heat exchange).
An analog PI controller module integrated in the
actuator. 1.3 Description of the DR300
Mechanical Setup
• Option 300-02
An A/D-D/A converter card DAC98 for a
PC-AT-computer with a 50-pol. lead to connect to The platform and the rear panel of the laboratory setup are
the actuator and a 3.5" floppy disk containing the constructed of aluminium and are covered with an acrylic
executable program for the practical course. glass cover which can be opened. An aluminium box is
mounted at the left side of the platform. The lead which
• Option 300-03 connects the mechanic to the actuator is located at its rear
As an extension to Option 300-02, a 3,5" floppy panel. The leads to connect to the motors and sensors can
be seen at the right side of the aluminium box. A micro • the 50-pol. lead for the connection between the
switch is located at the same location, which is activated actuator and the adapter board. (Options 300-02,
when the cover is closed. The two motors are mounted 300-03),
facing each other. The drive shafts are rigidly coupled.
Figure 1.1 shows the arrangement of the motors and the • two BNC terminals to measure the control signals
sensors. of the servo controllers.
The left motor (M1) contains a tacho generator. An 1.5 The Front Panel
additional incremental rotary encoder is mounted at its
free drive-shaft. The right motor (M2) is the load of the
motor M1 when it is operating in generator mode. Its free Figure 1.3 displays the components located on the front
drive-shaft can be used to mount an additional mass to panel.
increase the inertia.
1.5.1 SERVO GENERATOR
1.4 The Rear Panel
The servo amplifier functioning as a current controller for
the generator is located on the left side of the front panel.
Figure 1.2 displays the components located on the rear
panel. The mains input unit is located on the right side. It 1.5.2 SERVO MOTOR
contains two fuse holders, the mains inlet and the power
switch. Located on the left side of the ventilation cover This module contains the servo amplifier for the motor
are: which functions as a current controller. The time constant
of the current controller is adjustable with a switch. The
• the 30-polar connector for the mechanical system, switch position "Time 2" corresponds to an optimal
PC-CONNENTOR
FUSE
POWER
SWITCH
SYSTEM
MAINS
INLET
• Ready (green): The acrylic cover is closed • Index: Index signal of the incremental encoder
• -35V (green): -35V power supply for the servo • +15V (green): A voltage of +15V is available.
amplifiers is available.
• -15V (green): A voltage of -15V is available.
• Stop: Using this key will disconnect the input
signals of the servo amplifiers. • +5V (green): A voltage of +5V is available.
• LED yellow: Control signal is scaled. The I portion of the controller can be switched off, which
reduces its transfer function to
Table signal switching functions:
GP (s) = KR TR. The light emitting diode labelled "system" should light
up. Now close the acrylic cover of the laboratory setup.
• Integrator switch: Switches the I portion of the The light emitting diode labelled "Ready" should light up.
controller "On" or "Off".
The system is no ready for operation.
• Potentiometer TR: Allows adjustment of the time
constant of the PI-controller (Scale 0-10 = ^ An additional adjustable DC supply voltage is required to
0-1sec.). perform a function test. Connect this supply voltage to the
input labelled "Extern Setpoint I-Motor" on the module
• Potentiometer KR: Allows adjustment of the INPUT EXTERN-CONTROLLER (with Option 300-01
^ 0-100).
controller amplification (Scale 0-10 = module PI-CONTROLLER). Adjust the voltage to 0 volt.
Using the key "Start" will enable the control voltage for
• BNC-terminal Setpoint Speed: Input for the speed the motor servo amplifier. The light emitting diode
setpoint of the analog controller (± 3000 Upm =^± labelled "Controller: Extern" should light up now.
7,5 V). The difference between this signal and the Increase the input voltage until the motor starts to rotate.
tacho signal (2,5mV / Upm) is the input signal The measurement jacks (outputs) can be used to control
(error signal) of the controller. the tacho signal (2,5 mV/Upm). The motor current can be
measured using the jack "I-Motor" (0,226 A/V). The
• BNC-terminal Setpoint I-Generator: Input for the motor operating in generator mode can be tested in the
^±
current setpoint of the generator (range ± 10V = same way.
2,37 A).
1.7 Control with Internal Analog
• Start key: Connects the output of the analog Controller
controller to the servo amplifier of the motor and
the setpoint voltage of the generator current to the
servo amplifier of the generator. This switch The analog PI-controller is adjustable with two
function is disabled when another controller or the coefficient potentiometers. Its measured value is the tacho
external input is enabled. Switching the key again signal (range ± 10 V, 2,5mV / Upm). This connection is
disconnects the signals. existing inside the actuator. The controller setpoint (speed
of the motor) is connected to the input jack "Setpoint
The components for connecting an external controller Speed" using a voltage in the range of -7,5 to +7,5 volt
(see chapter 1.5.7) are located on the lower part of this (2,5mV/Upm). The load moment is adjusted by
module. connecting a voltage signal (range ± 1,38 Ncm, 0.138
Ncm/V) to the input jack "Setpoint I-Generator". Using
1.6 Connecting the System the key "Start" will connect these signals to the servo
components and Start Up amplifiers of the motor and the generator. The control can
be aborted by using the key "Start" again, using the key
"Stop" located on the module "POWER SERVO" or by
Before setting up the system, please check whether your opening the acrylic cover.
mains supply provides a 230V/50Hz voltage. Switch off
the actuator and connect it to the mains supply. Then
establish the lead connection between the actuator and
the mechanical system. Now open the acrylic cover of the
laboratory setup. Switch on the actuator. Then check,
whether the light emitting diodes on the front panel of the
actuator indicate the availability of the supply voltages.
1.8 Control with External installation dialog but their names must contain only 8
Controller characters besides an extension). Following a successful
installation the controller program may be started
immediately.
The measured value for an external controller is provided
by the output jack "Tacho" (range ± 10V, 2,5mV/Upm). 1.10 Output Stage Release
The output of the controller has to be connected to the 40 - 100 us
"Stop" located on the module "POWER SERVO" or by Figure 1.4 : Signals for the output stage release
opening the acrylic cover.
The LEDs do not light up Check the connection to the mains supply
Check the fuses for the mains supply (rear panel)
LED + 35 V does not light up Check the fuse of the mudule "POWER SERVO"
LED - 35 V does not light up Check the fuse of the module "POWER SERVO"
LED + 15 V and - 15 V do not light up Check the fuse of the module "POWER UNIT SIGNAL ADAPTION"
LED + 5 V does not light up Check the fuse of the module "POWER UNIT SIGNAL ADAPTION"
LED "System" does not light up Check the lead connection between mechanical system and actuator
Chosen controller cannot be enabled Check whether another controller, is enabled (LEDs on "POWER
SERVO" module)
Check LED "Ready" lights up (cover closed)
Controller enabled but motor does not Check whether, the control signal for the servo amplifier is scaled or
rotate switched off on the disturbance module "SIGNAL ERROR"
Controller enabled but motor rotates Check whether, the tacho signal is scaled or switched off on the
too fast disturbance module "SIGNAL ERROR"
Technical Data
Date: 01.07.1998
Technical Data
Laboratory Setup Speed Control DR300 Table of Contents
Technical Data i
Table of Contents Laboratory Setup Speed Control DR300
ii Technical Data
Laboratory Setup Speed Control DR300 Technical Data
Length 56 mm
Diameter 41 mm
Max. misalignment of 0.17 mm
lateral axes
Max. misalignment of 0.5 mm
axial axes
Max. torque 900 Ncm
Torsion spring constant 4200 Nm/rad
Moment of inertia 0.33 kg ⋅ cm2
Weight 0.13 kg
Motor terminal ± 30 V
Weight 10 kg
voltage
Current monitor for 2.5 V/A
sensor modul
Mains input Value Unit
Frequency 50 Hz
Output voltage ± 15 V
+5 V
Practical Instructions
Date: 01.06.1995
Practical Instructions
Laboratory Setup Speed Control DR300 Table of Contents
5 Solutions 5-1
Practical Instructions i
Table of Contents Laboratory Setup Speed Control DR300
ii Practical Instructions
Laboratory Setup Speed Control DR300 Theoretical Background
Φ : magnetic exitation
1.2 Mathematical Description of
the Permanently Exited DC
Motor Ω : aramture frequency.
UA E Machine
ML
d
UA − E = RA IA + LA I Eq. 1.1 M = KM IA. Eq. 1.3
dt A
MB : acceleration torque
RA 1 + TA s
that means − ML (s)
KM C Φ 1 + T s + T T s2
M M A
JR T
T=
√ A A
K CΦ
=
√
TM TA The aquisition of the angular velocity Ω is usually
M performed by a tacho generator which is mounted on the
motor shaft. Its output voltage UT is proportional to the
and the attenuation rotation. UT is then subtracted from the reference variable
Usoll. The controller uses the difference UD to derive the
J RA TM
d=
1
2
√ KM C Φ TA
=
1
2
T
√ . control variable US for the actuator. The result is the
A
diagram shown in figure 1.3.
1 ML 1
Controller RA TA KM J
Uref UA IA M - MB ω
- -
UT E
CΦ
KT
1 ML 1
Ω − Controller IA − Controller RA TA KM
J
ωref Iref UA IA M MB ω
-
- - -
ωmeas IA meas E
CΦ
KW
KT
Tacho
Since usually TA << TM, disturbances in the armature can be converted to a clearer structure after rearrangement
control loop can be compensated rapidly. In addition to of the integrator. At the same time the time constant TM
improving the controller dynamics, the cascaded current is used which was introduced in 1.2.1.
control loop offers another advantage. Limit values of the
motor such as maximum armature current and maximum In figure 1.5 the drive feedback Ω is included in the
current rise time can be considered during controller current control loop (transfer function Fi (s)). In such a
parameter adjustment.
structure the suitable controller design is obtained at first
for the inner and then for the outer control loop. Thus, at
1.4 Structure Simplification of first the structure and the parameters of the IA-controller
the Cascade Control are designed. Then the calculated transfer function of the
inner closed loop is included in the outer control loop.
After that the speed controller is designed.
Figure 1.4 shows that the control variable Ω of the outer
control loop is coupled into the cascaded control loop. To
separate the two control loops one therefor asssumes that 1.5 The Cascaded Current
the load moment does not change (ML=const.). One Control Loop
designs the reference behaviour and hopes that the
disturbance behaviour will be acceptable. In these The isolated control loop, which is of interest in this case
assumptions the influence of ML is omitted and figure 1.4 is shown in figure 1.6. Before we start with the controller
1
IA − Controller TA RA 1
RA
Ω − Controller CΦ TM
ωref Iref IA ω
- - -
ωmeas IA meas 1 RA
TM
KW
KT
Tacho
1 RA
IA − Controller RA TA
Iref UA IA CΦ
- -
Imeas 1
TM
RA denoted in figure 1.5 is included in the amplification of
KW the current control loop to obtain a better overall view.
With that the result for the transfer function of the
cascaded current control loop is
1 -
IA − Controller RA TA
Iref IA
KT
-
Imeas Tacho
KW
Figure 1.8: Speed control with cascade current control
1
Figure 1.7: Reduced current control loop Gir (s) = Ki ⋅
1 + Ti s
to the rapid armature control loop since TM > TA. So we Figure 1.8 shows the diagram of the speed control loop
with the cascaded current control loop described as a first
can neglect this feedback in our evaluation of the dynamic
order lag element.
behaviour. In that case the plant under consideration acts
like a first order lag element which is shown in figure 1.7.
It should be noted that only the dynamic reference
behaviour of the system was considered in the shown
Since the plant includes no integral portion, a PI controller
structure. In that structure an adjusted armature current
is chosen to reach steady state precision. The transfer
will not yield a stationary rotation which does not
function of the closed control loop is now again described
correspond to reality (friction). On the other hand it is not
as a first order lag element.
possible to define the disturbance behaviour.
K ’i
G ’ir (s) = 1.6 Calculation of the Speed
1 + Ti s
Controller
The amplification ki is adjusted to 0,4 A/V. Using the
switch located on the front panel of the actuator, the time A PI controller with the transfer function
constant Ti is adjusted to Time2 = 0.005 s or Time1 = 0.03 1 + TRn s
s. Rn (s) = KRn
s
shall be used for the speed controller. In that case we have
The amplification factor
two degrees of freedom, KRn and TRn to influence the
|FS (j ω)| shifting 1⁄TRn to the left in figure 1.9 which results in an
|FKO (j ω)|
earlier phase shift to smaller values since the time constant
of the cascaded current control TRI has little influence at
o
0 ϕR (j ω)
these frequencies. Conversely the maximum of ϕD is
ϕS (j ω)
o
-90 reduced when TRn is reduced since 1⁄TRn approaches 1⁄TRI,
o which compensates for the decreasing effect of the
-180 ϕK (j ω)
controller time constant TRn.
Figure 1.9: Construction of the Bode diagram The phase reserve (phase margin) is a suitable measure
for the dynamics of the transient response. A small ϕD
control. To elucidate their effects we consider the Bode yields a large overshoot response and a long transient time
diagram of the control loop. since we approach the limit of stability. On the other hand
an increasing phase reserve will result in a reduced
Figure 1.9 shows the amplitude and phase characteristic overshoot amplitude and transient time until the transient
of the controller (with KRn =1), of the plant (amplification response is aperiodic. Increasing the phase reserve will
slow down the control loop. So we realize that small as
KSn=1) and of the corrected open control loop
well as large phase reserves yield less desirable results
(FKO (j ω)). We see that the controller increases the phase since in both cases the time duration is long until steady
angle (integral portion: -90°), which approaches zero with state is reached at the desired reference value.
rising frequency according to the denominator term. It can
be seen in the complete phase characteristic that For this reason one has to modify TRn to obtain acceptable
ϕK (j ω) starts at - 180°, rises to values in the range of -90° speed of the control loop combined with sufficient
> ϕK > -180° in the middle until it approaches stability. A suitable transient with a small overshoot and
a relatively short transient time is achieved using a phase
asymtotically the phase characteristic of the plant (current
control loop). reserve in the range of 40° ≤ ϕD ≤ 70°. To adjust those
values, the controller time constant has to approach the
Only the range -90° > ϕK (j ω) > -180° is of interest in our mechanical time constant TM of the DC drive.
a
log(KRn KSn) = . Eq. 1.10
20
1 1
T RN T RI
Substituting Eq. 1.11 and Eq. 1.12 in Eq. 1.14 gives the
since the absolute value of the controlled variable
result for the PI controller parameters
| X (j ω) | is equal to the absolute value of the reference
value | W (j ω) | or in the time domain
1
TR = T1 und KR = , Eq. 1.15
2 KS TS
| x (t) | = | w (t) | .
where KS is the amplification of the plant including the
From the identity | FW (j ω) | = 1 it follows with (Eq.
measuring element.
1.13):
is valid.
FR (j ω) FS (j ω) − FR (−j ω) FS (−j ω) + 1
=0
| FR (j ω) | 2 | FS (j ω) | 2 Again a PI controller is taken as the correction element.
Eq. 1.14
As we have seen from the controller design using the
must be valid. frequency characteristic method, it is possible to move the
intersection frequency ωD of the corrected open control
loop using a suitable controller. Thus one can locate the
intersection frequency for instance in the (logharithmic)
middle between the low bend frequencies 1⁄Ti and the high Now the load moment ML in figure 1.4 is considered in
the following. It can be combined by the load moment
bend frequencies 1⁄ti. Since then ωD is relatively far away
resulting from the coupled machine and the moments of
from both groups, only the large time constants Ti become
friction. One component of the moments of friction is the
noticeable in form of a straight line part falling with sliding friction proportional to the rotation. When this
m ⋅ 20 dB ⁄ dek in the neighbourhood of ωD. So the sliding friction is described by a feedback (Kreib) of the
frequency characteristic has some symmetry arround ωD integrator with the machine time constant TM its transfer
function is stated as
and can be taken as a representation of an single or
multiple integration element.
Ki
TM s
Starting from these assumptions one furthermore tries to GM (s) =
make the frequency characteristic of the reference Kreib ⋅ Ki
1+
variable equal to 1 in a range arround ω = 0 as wide as TM s
possible using suitable controller parameters. This is
similar to the absolute value optimum. This requirement 1 1
= ⋅ Eq. 1.17
is approximated when Kreib TM
s+1
Ki ⋅ Kreib
m
∏ Ti
i=1 1
TR = 4 m TΣ und KR = ⋅
(4 m TΣ) m 2 KS TΣ The amplification factors of the current controller (Ki)
and the measuring system are known. So the overall
with m=number of the large time constants and transfer function of the current controller, the motor and
TΣ= sum of the small time constants the measuring system is given by:
1 1 1 1
that means when m = 1 Gges (s) = ⋅ ⋅ ⋅
1 + Ti s Kreib TM 1 + Tmess s
s+1
Ki ⋅ Kreib
T1
TR = 4 TΣ and KR = Eq. 1.16 Eq. 1.18
8 KS TΣ 2
1
The amplification is measureable in the open control
is valid. Kreib
loop.
Here again KS is taken as the product of the amplification
of the plant and the measuring element. So the new machine time constant can be determined
using the measured amplification Vreal by:
1.8 Application to the Given
Structure TM ers =
TM ⋅ Vreal
Eq. 1.19
Ki
Vreal
Gges (s) = Eq. 1.20
(1 + TM ers s) (1 + Ti s) (1 + Tmess s)
Technical Data: The tacho signal is scaled with 0.5 using an input
amplifier and is filtered by a first order lag with a time
Motor
constant of 1 ms. The measuring signal available at the
Rated voltage 24 V
socket "Tacho" ranges from -10.0 V to + 10.0 V with 2.5
Rated current 2A
mV/Rpm.
Rated power 30 W
Rated speed 3000 Rpm
Rated torque 0.096 Nm
Voltage constant 6.27 mV/Rpm
Moment of inertia 17.7 10-6 Kgm2
Torque constant 0.06 Nm/A
Connected resistance 3.13 Ohm
Tacho
Output voltage 5 mV/Rpm
Moment of inertia 10.6 10-6 Kgm2
Incremental encoder
Number of lines 1024
max. resolution 4096/R
Moment of inertia 1.45 10-6 Kgm2
Clutch
Moment of inertia 33.0 10-6 Kgm2
ref. 3.3:
5 Solutions
60 1
KRpm = Kiges ⋅ = 200.0 => 46 dB
2π V min
5.1 Solutions to the preparation
problems from chapter 3
ref. 3.4:
ref. 3.1:
Tacho:
Jsum = Jmotor+ Jgenerator+ Jclutch+ Jtacho+ Jincremental encoder
Umax − Umin
= (17.7 + 17.7 + 33.0 + 10.6 + 1.45) 10-6 Kgm2 = 1.953 Rpm
mV
212 ⋅ 2.5
rotation
= 80.45 10-6 Kgm2
Incremental encoder:
Jges RA
TM = Revolution = increments/increments maximum/sampling
KM C Φ
period*60
6.27 mV ⋅ 60 s
CΦ= = 0.0598 Vs ≈ 0.06 Vs ref. 3.5:
2⋅π
Figure 5.1 shows the amplitude characteristic.
80.45 10−6 Kgm2 ⋅ 3.13Ω
TM = = 69.94 ms ≈ 70 ms
Nm DR300
0.06 ⋅ 0.06 Vs
A 50
ref. 3.2:
Amrplification[dB]
30
-25 dB
A RA
Kiges = 0.4 ⋅
V CΦ 10
A
0.4 ⋅ 3.13Ω
V
= -10
0.06 Vs 0.1 1 10 f1 100 1e+03
Frequency
25
KR = 10− ⁄20 ≈ 0.056
Figure 5.2 shows the phase characteristic. Figure 5.4 shows the phase chartacteristic.
DR300 DR300
-120 -120
Phase [Degree]
Phase [Degree]
-140 -140
40°
-160 -160
40°
-180 -180
0.1 1 10 f1 100 1e+03 0.1 1 10 f2 100 1e+03
Frequency Frequency
The right value of 40° is chosen to determine the The right value of 40° is chosen to determine the
amplification. The amplification taken from the diagram amplification. The amplification taken from the diagram
is -25 dB. The corresponding result for KR is 0.056. is approx. 27 dB. The corresponding result for KR is
0.042.
30
-27.5 2.8e+03
dB
10 2.63e+03
RPM
2.47e+03
-10
0.1 1 10 f2 100 1e+03
Frequency
Time in s
8.11.1993 12:33:37
3300.00
The result is a plant amplification of 3500 Rpm/V and
with this a time constant of
3100.00
0.07 * 3500 / 200 = 1.225 sec.
RPM
2900.00
ref. 4.2:
T = 1.225 s
2700.00
0 1 2 3 4 5
Time in sec
12.10.1994 13:59:16
K = 1/(2 * 3500 * 0.035) = 0.004
Figure 5.6: Parameters according to ’absolute value
optimum’, disturbance behaviour
2900.00
ref. 4.4:
2300.00
2600.00
RPM
2000.00
2400.00 0 1 2 3 4 5
Time in sec
12.10.1994 13:56:33
Figure 5.8: Parameters according to ’symetrical
optimum’, reference behaviour
2200.00
0 1 2 3 4 5
Time in sec
12.10.1994 13:55:07
Figure 5.7: Parameters according to ’absolute value
optimum’, reference behaviour
ref. 4.5:
3200.00
3066.67
RPM
2933.33
2800.00
0 1 2 3 4 5
Time in sec
12.10.1994 14:00:35
Figure 5.9: Parameters according to ’symetrical
optimum’, disturbance behaviour
2900.00
2633.33
RPM
2366.67
2100.00
0 1 2 3 4 5
Time in sec
12.10.1994 13:57:22
Figure 5.10: Parameters according to ’Bode Diagram’
reference behaviour
3200.00
3066.67
RPM
2933.33
2800.00
0 1 2 3 4 5
Time in sec
12.10.1994 14:01:30
Figure 5.11: Parameters according to ’Bode Diagram’
disturbance behaviour
Date: 01.06.1995
4 Solutions 4-1
1 Backgrounds of the
Fuzzy Controller
Fuzzy Controller
Knowledge Base
Rule Bases
← ←
W Inference ←
e u
Fuzzyfication Aggregation Implication Conclusion Defuzzyfication Process
←
X ←
Ymeas
Measuring
1[m]
theory. They are the mathematical base objects for which Figure 1.2: Mapping of the data set X to the real
corresponding operators are defined. numbers
Using this method a bar with the length less than 1 meter The difference between the figures 1.5 and 1.6 can be seen
is clearly representable by the set of x contained in the from the transition region from µA (x) = 0 to µA (x) = 1.
data set X which results with the expression µ = 1. Those While the membership changes step-wise in the figure
are all values which apply to 0 ≤ x ≤ 1. 1.5, a sliding transition of the membership values takes
place in the figure 1.6. Doing this according to human
mind a more natural description of the term length is
possible. Such a set is called an indistinct set or a fuzzy
set.
A = {(x,µA (x)) | x « X }
µ (x)
A1 1.2 The Linguistic Variable
0.5
It was shown in the previous section that with human
mind fuzzy terms are describable mathematically. With
0 this one must not forget that those terms always apply to
0 1 2 x/[m]
Figure 1.6: Example for a fuzzy set the set A ⊆ X with the membership function µA (x).
0
µ(x) µ(x)
xi li j xi li j
0 1 x/[m] 1 1
Figure 1.7: Example for a linguistic variable
ai j ai j maximum degree
variable. of corres pondance
xi AND l i j
0
So a linguistic variable can be taken as a group of fuzzy
0 x x 0 x x
sets, which are defined with respect to the same base set Meas Meas
X and the same range of values i.e. µ(x) ∈ [0,1]. Crisp value Value with tolerance
Figure 1.8: Fuzzification
1.3 The Fuzzification 1.4 The Rule and the Rule Base
Since the fuzzy theory generally defines operators only A rule also called fuzzy implication has the general form:
for fuzzy sets, a fuzzy set is to be assigned to each distinct
measured value (crisp value), i.e. the components of the if Premise then Conclusion
control error vector →
e. This process is called fuzzification.
It can be seen easily that µ(x) of a crisp value is identical An arbitrary number of expressions xi is lij is combined
to the normalized impulse function γo (x) as well as the by the operators and or or in the premise.
result is a square function rect(x) (see figure 1.8) in case
Example for a premise:
the value is full of tolerances.
The rule base describes the experience and the knowledge 1.5.2 The Implication
about the process and therefore must not be complete. For
The implication is used to infer the degree of fulfilment
instance it could be the case that due to the ignorance of
a′gr at the output from the degree of fulfilment agr of the
the developer not all physical actions are known. The lack
of dominant rules is the result of the incompleteness of premise.
the rule base. This leads to a bad or useless control
behaviour. This is repairable by the addition of further if agr then a′gr ⇔ agr → a′gr ≤ µmax
rules to the rule base.
Usually the identity agr ≡ a′gr is taken as a mapping
The totality of all linguistic variables and rule bases,
instruction.
which characterize the fuzzy controller is called
knowledge base.
1.5.3 The Conclusion
1.5 The Inference Operation After the implication has determined the degree of
fulfilment a′gr of the output the conclusion determines the
resulting fuzzy set.
1.5.1 The Aggregation
given by its control characteristic area. Unfortunately • the observation of the process.
there is no general method available to find suitable fuzzy
sets and rules for a given problem. The rules can be found with respect to
The fuzzy sets of the linguistic variables can be found with • the experience of the operators,
respect to
• the knowledge of the control engineers,
• the characteristic values of the actuator and
measurement system, • the observation of the process.
AN D
a1,0
a o0
PROD.
µ µ a1,1 µ
NM0 1 NM1 1 NMo 1
a o1
OR
a 0,1
x0v x1v
µ µ µ
1 PMo NMo 1 MAX 1
y
outv
Rule 0: if x0 is PM0 and x1 is PM1 then yout is PMo end
Rule 1: if x0 is NM0 or x1 is NM1 then yout is NMo end
Input variables: x0, x1
Sets of Input variables: PM0, NM0, PM1, NM1
Values of input variables: x0v, x1v
Output variable: yout
Sets of Output variables: PMo
Value of output variable: youtv
µ is degree of fulfilment
Figure 1.12: Example for the execution of a fuzzy algorithm using the Max-Product-Method
3 Carrying-Out the
Experiment
3.1 Edit the fuzzy description file according to the
preparation task and test the controller.
How do you evaluate the control behaviour? What
are the possible reasons for the observed
bahaviour?
ref.2.1
Fuzzy-Controller
s 1/s KP
n in Uout 1
+ G(s) = Kp(x,y) + Ki(x,y) * , mit x = s * y
s
1/s KI
ref.2.2
ref.2.4
The three dimensional representation of the function
z = Kp * x + Ki * y, As described in the theoretical backgrounds of the fuzzy
where x,y and z are the coordinates of a cartesian system, controller only the method "Center of Area" is used by
is a plane surface in the space. The gradient of the plane our fuzzy controller for defuzzyfication. A single fuzzy
set always has the same center of area independent of its
weighting by the Max-Prod-method. Therefore the value The definition range of x is limited by the maximum
of a fuzzy output variable with only one fuzzy set is change of y during a sampling period. To calculate this
always equal to the value of the constant center of area of value the maximum control signal 10V is assumed. The
this fuzzy set. So the output value is: result is:
With respect to the speed range of ±3000 rpm a maximum z ∈ [ −200, +200 ]
control error signal of 6000 rpm can be reached. The
definition range of y is therfore: Remark:
In the normal case the complete definition range of an
y ∈ [ −6000, +6000 ] output variable is never reached, since the center of areas
of the fuzzy sets of this variable determine the value of
If however the desired performance of the speed control the output variable (see task 2.4). The position of the
is considered it is recommended to significantly restrict center of area depends on the form of the fuzzy set but can
the above mentioned intervall. The value of a fuzzy set at never reach the limit of the definition range.
the limits of the definition range of a fuzzy variable is
continued to the infinity. That means if for instance the The following names are chosen for the fuzzy variables:
ref.2.6 ref.2.7
Since the behaviour of the fuzzy controller is unknown at In case of 2 input variables with 3 fuzzy sets each and only
this time, the definition range of each variable is divided one operator 3*3=9 input combinations are possible.
into three segments, "positive", "null" and "negative". Therefore 9 suitable rules are required to cover all cases.
The set with the name "null" will be defined above the
zero point and extends over 1/3 of the entire definition If in some cases the "and"-operator is replaced by the
range. This segmentation will be optimized during "or"-operator, the number of rules is reduced (1 rule per
experiments wit the plant. "or"-combination can be saved). It is even more
significant in case the premise of a rule considers only one
"SpeedError" of the two variables (2 of 9 rules can be saved).
Combinations of inputs, which can not occur due to the
1 negative positive physics of the plant, need not be considered in the rule
Membership
base.
null
ref.2.8
0
-6000 -2000 0 2000 6000 The result are the following 9 rules:
if SpeedError is null and Acceleration is null then ControlSignal
Figure 4.3: Variable y, SpeedError is null
if SpeedError is null and Acceleration is positive then
ControlSignal is positive
"Acceleration" if SpeedError is null and Acceleration is negative then
ControlSignal is negative
1 negative positive if SpeedError is positive and Acceleration is null then
Membership
ControlSignal is positive
if SpeedError is positive and Acceleration is positive then
null ControlSignal is positive
if SpeedError is positive and Acceleration is negative then
ControlSignal is null
"ControlSignal"
ref.2.9
1 negative positive
Membership
set negative -28560 1 00 endset The reason for the very small control amplification
set null -28560 0 01 28560 0endset determined with 3.1 is to be found in the definition range
set positive 0 0 28560 1 endset of the input/output variables and its fuzzy sets. The output
values of the fuzzy controller lay between the center of
endvar areas of the sets belonging to its output variable. The
center of areas are shifted further to the limit of the
var output ControlSignal definition range of the output variables by reducing the
sets of this variable to a smaller region. There is no need
set negative -200 1 -67 0 endset for an output variable to cover the complete definition
set null -67 0 01 67 0 endset range.
set positive 67 0 200 1 endset
The definition range of both input variables is
endvar significantly to wide. In case only the proportional part of
if SpeedError is null and Acceleration is null then ControlSignal a suitable PI controller is considered (its amplification is
is null end KR * TI = 0.0336, see practical course PI controller), one
if SpeedError is null and Acceleration is positive then realizes that the maximum control signal at the output of
ControlSignal is positive end
the proportional part is already reached below a control
if SpeedError is null and Acceleration is negative then
ControlSignal is negative end error signal of 300 rpm.
if SpeedError is positive and Acceleration is null then
ControlSignal is positive end To improve the control behaviour the definition range of
if SpeedError is positive and Acceleration is positive then the input variables is reduced and the center of areas of
ControlSignal is positive end the fuzzy sets belonging to the output variables are shifted
if SpeedError is positive and Acceleration is negative then
ControlSignal is null end
further to the limit of the definition range. One possible
solution looks like the following:
if SpeedError is negative and Acceleration is null then
ControlSignal is negative end
if SpeedError is negative and Acceleration is positive then /* The definition range of SpeedError is reduced to 10%
ControlSignal is null end of its original size. The definition of ’null’ is reduced
if SpeedError is negative and Acceleration is negative then
much more. */
ControlSignal is negative end
Program Operation
Speed Control
(Windows Version)
Date: 02-November-2000
1.9.3 Format of the Fuzzy Description File for the Laboratory Experiment DR300 (*.FUZ) . . . . 1-12
1.9.4 Format of the PI Controller File for the Laboratory Experiment DR300 (*.PI) . . . . . . . 1-13
The software package provides two versions to control The help file DR300.HLP allows for operating the
the plant "Speed Control with Variable Load". The first program without having this manual at hand. The function
version is a PI controller as described in the previous key F1 or a specific ’Help’ button presented in a dialog is
sections. Controller parameters are on-line adjustable. to be used to activate the corresponding help section.
The second version to control the DR300 is a fuzzy
controller as described in chapter "Fuzzy Practical The initialization file DR300.INI is completely
Course". Controller adjustments are storable to a hard controlled by the executable program itself and should not
disk and may be read at a later time. The setpoint for the be changed by the user. It serves for handling the
motor speed position is adjustable as a constant value or IO-adapter card driver.
a time function. Measurements of system variables are
recordable with various trigger conditions. Recorded data DR300.FUZ is the fuzzy description file, loaded
are representable in a graphic on the screen. automatically during the program start and used by the
fuzzy controller of the system. The file format is described
1.1 Program Start in 1.9.3.
DR300.PI
DR300.FUZ
1.3 Menu File detected. Further information about the fuzzy description
file can be found in the chapter 1.9.1 "Format of the Fuzzy
Description File (*.FUZ)".
The pulldown menu File (see figure 1.3) provides
functions for loading or saving of different files, to print Load Recorded Data: Opens a file dialog window for
plot windows as well as to terminate the program. user selection of a data file containing recorded
measurements (documentation file with extension
*.PLD).
1.4 Menu IO-Interface The function Setup opens a dialog (see figure 1.4b) to
adjust the drivers hardware address of the installed
IO-adapter card. This address has to match the hardware
The pulldown menu IO-Interface provides functions to settings !
manipulate the driver for the PC plug-in card (see figure
1.4a). The selected address is stored automatically as a decimal
number in a specific entry of the file SYSTEM.INI from
the Windows directory. This entry may look like:
[DAC98]
Adress=768
1.5 Menu Edit the button ’Abort’ which leaves the file unchanged.
Fuzzy Controller: Starts directly the fuzzy controller The adjustment of the setpoint, Setpoint Generator
defined by its fuzzy description file (*.FUZ). A possibly opens a dialog (see figure 1.6c ) for adjusting two
running setpoint generator is reset only when no independent signal generators for the motor as well as for
controller was active previously. the load (generator). The adjustments of the upper
generator are assigned either to the speed setpoint signal
Open Loop Control: Starts directly the open loop control [rpm] (PI, fuzzy controller or no controller is active) or to
of the motor meaning that the servos for the motor as well the control signal [V] (open loop control is active) of the
as for the generator are controlled directly by the control motor. The settings of the lower generator define the
signals from the Setpoint Generator (see below). A
The group of check boxes allows for manipulating the vertical axis 0...100%) displays the frequency occurrence
layout of the graphic: of the sampling period values. The number labelled ’N’
is the number of sampling periods used for the current
With ’Grid’ marked a grid with either a higher or lower calculations.
resolution depending on the setting of ’Low resolution’ is
displayed along the surface of the characteristic. The measurements are taken by means of the timer
components of the PC adapter card.
The surface itself is displayed in a grey scale (darker areas
indicate higher values along the Z-axis) when ’Surface’
is marked. The surface will be coloured if ’Colour’ is
marked in addition (increasing values along the Z-axis are
indicated by colour changes from red to blue).
The scroll bars labelled ’Rotate a:’ and ’Rotate b:’ allow The calculation of the minimum and maximum values of
for rotating the graphic with respect to the X-axis and the the sampling period may be restarted by resetting the
Y-axis respectively. The crossing point of these axes is values by means of the button ’Reset’
the middle of the cube. Alternatively the rotation is
achieved by moving the mouse in the cube area The dialog will be terminated by pressing the button
accordingly. ’Hide’.
The button ’Print’ starts a hardcopy output to the currently Remark: Due to the obvious variation of the sampling
selected printer device. period values, the calculation of speed variables has to be
done with respect to real time intervals obtainable from
The dialog is terminated by pressing the button ’Close’. the timer components of the PC adapter card.
The menu item Contents displays the contents of the help The fuzzy description file with the extension FUZ is a file
file DR300.HLP, while Search for Help On ... searches to configure a fuzzy controller. The file format is
developed by the amira GmbH and is used by several
products of the amira.
The Definition of Fuzzy Sets and Variables the premise and the conclusion. Both parts are separated
by the statement ’then’. The premise and the conclusion
The definition of fuzzy sets is only allowed within the are built by a series of expressions which are combined
definition of variables. It is ignored in the other case. The by operators (further details are shown in the chapter of
definition of a variable starts with the statement ’var’. The the theoretical backgrounds of a fuzzy controller).
next statement can hold two different names, either Permitted operators of the premise are ’and’
’input’ in case an input variable is to be defined or ’output’ (Min-Operator) and ’or’ (Max-Operator) whereas the
in case an output variable is to be defined. The third conclusion requires no operator to separate the
statement of a variable definition is its name. Now the expressions. An expression is the linkage of a fuzzy
definition of the fuzzy set follows. It begins with the variable with one of its sets using the statement ’is’.
statement ’set’ followed by the name of the fuzzy set. The
name is followed by the x/y values as base points for a The formulation of a fuzzy rule requires that all the
polygonal line. Similar to the statements the numbers are variables in use are defined previously since the fuzzy
separated by spaces or tabulators. The definition of the description file is interpreted only once from top to
fuzzy set ends with the statement ’endset’. The definition bottom. The syntax check of a fuzzy object tests whether
of a variable ends with the statement ’endvar’ after all the the variables are defined, whether the used sets really
fuzzy sets of the fuzzy variable are defined. Such a belong to the variable and if the expressions are used
definition may look like the following: correctly (input variables with the premise and output
variables with the conclusion). A simple definition of a
var input temperature fuzzy rule may look like the following:
set cold 10 1 20 0 endset
set medium 10 0 20 1 30 0 endset if temperature is cold then heating is high end
set warm 20 0 30 1 endset
endvar
Command Explanation
The status and error messages which occur during the /* Acceleration is the differentiated SpeedError */
interpretation of the fuzzy description file are written to
the file ERROR.OUT or appear on the screen. var input Acceleration
set negativ -14300 1 00 endset
1.9.2 Format of the Error Output File set null -2860 0 01 2860 0endset
ERROR.OUT set positiv 00 14300 1 endset
endvar
During loading and interpreting of a fuzzy description file
status and possible error messages are written to the file var output ControlSignal
ERROR.OUT. This file has the following format: set negativ -200 1 -190 0 endset
set null -20 0 0 1 20 0 endset
Fuzzy Parser Version 1.04 (07-DEC-94) set positiv 190 0 200 1 endset
endvar
Fuzzy-Set <set_name> is already defined.
Fuzzy-Set <set_name> expects numerical value. if SpeedError is null and Acceleration is null then
Unknown variable specification <string>. ControlSignal is null end
Variable <var_name> is already defined. if SpeedError is null and Acceleration is positiv then
Rule error, fuzzy variable <var_name> not found. ControlSignal is positiv end
Rule error, fuzzy variable <var_name> is an if SpeedError is null and Acceleration is negativ then
output variable. ControlSignal is negativ end
Rule error, fuzzy variable <var_name> is an input
variable. if SpeedError is positiv and Acceleration is null then
Rule syntax error, missing is. ControlSignal is positiv end
Rule error, fuzzy set <set_name> is not member if SpeedError is positiv and Acceleration is positiv then
of <var_name>. ControlSignal is positiv end
Rule syntax error, unknown Operator <string>. if SpeedError is positiv and Acceleration is negativ then
<label_name>isalreadydefined. ControlSignal is null end
<n>Errorsdetected.
if SpeedError is negativ and Acceleration is null then 1.9.5 The Format of the
ControlSignal is negativ end Documentation File *.PLD
if SpeedError is negativ and Acceleration is positiv then
ControlSignal is null end Measured data stored in a data file are reloadable and may
if SpeedError is negativ and Acceleration is negativ then be output in a graphic representation. In addition the
ControlSignal is negativ end system settings (CTRLSTATUS) which were active
during the start of the data acquisition are stored in this
file. They are displayable in a separate window.
1.9.4 Format of the PI Controller File
for the Laboratory Experiment The data file contains data in binary format stored in the
DR300 (*.PI) following order:
This file contains all parameters of the PI controller for The structure PROJEKT PRJ. (60 bytes)
the laboratory experiment DR300. Each entry consists of The structure CTRLSTATUS. (96 bytes)
two lines, an information block in square brackets in the The structure DATASTRUCT. (8 bytes)
first line and a data block in the second line. Further The data array with float values (4 bytes per value).
comments or empty lines are not allowed. The
information block describes sufficiently the function and The size of the data array is defined in the structure
number of data inside the data block. Please change this DATASTRUCT. With the DR300 speed control system
file only using corresponding functions of the DR300 the number of the stored channels is always 8 (the length
controller software. of the measurement vector is 8, i.e. equal to 32 bytes).
The PI controller file DR300.PI looks like the following: the speed setpoint of the motor in [rpm],
the control signal for the generator in [V],
[Sampling Period] the motor speed measured by tacho in [rpm],
0.005 the motor speed measured by encoder in [rpm],
[KR] the measured motor current in [A],
0.1 the measured generator current in [A],
[TR] the output signal for the motor in [V],
0.06 the output signal for the generator in [V],
struct PROJECT{
char number[10]; // P340 for speed control
char name[10]; // DR300
char Titel[10]; // SPD CTRL
char Version[10]; // last version
DAC98 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2
GetAdress . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2
GetInterrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3
GetClock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-7
WriteAllDigital . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-8
ReadDigital . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-8
ReadAllDigital . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-9
SetCounter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-9
GetCounter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-10
WaitCounter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-10
TestCounterJMP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-11
GateCounter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-11
SetTimer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-12
SetTimer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-12
GetTimer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-13
GateTimer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-13
SetINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-14
GetINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-14
ResetDDM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-15
ResetAllDDM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-15
ReadDDM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-16
ReadAllDDM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-16
ReadAnalogVolt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-17
WriteAnalogInt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-18
ReadDigitalInputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-19
DIC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-20
~DIC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-20
GetDigitalOut . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-21
GetAnalogOut . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-21
GetDDMCounter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-22
GetDDMTimer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-22
GetDDMStatus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-23
FilterINC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-23
TimerDirINC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-24
SetINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-24
SetTimer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-25
GetTimer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-25
GateTimer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-26
PCIO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-27
~PCIO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-27
DigitalOutStatus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-28
ReadAnalogVoltMean . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-29
ResetHCTL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-29
ReadHCTL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-30
SetINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-30
OpenDriver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-1
SendDriverMessage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2
CloseDriver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4
Resolution: 12 bit
1 The PC Plug-in Card Programmable input
DAC98 (PCA902) signal range : 5V
10V
+/- 5V
1.1 Introduction +/- 10 V
Digital Inputs:
• 16 bit counter for incremental encoder signals:
Number of inputs: 8
DDM
Level: TTL compatible
• 32 bit timer/counter for interrupt control or time 1.4 Installation of the DAC98
measurement
• 16 bit timer/counter for interrupt control or time 1.4.1 Adjustment of the Base Address
measurement
One of 8 possible base addresses (0x300..0x370) is
adjustable by means of a DIP switch providing a 3 bit
1.3 Specifications coding. The meaning of the switch positions is as follows
1 = Switch position on
Analog Inputs:
0 = Switch position off
Number of inputs: 8
(*) = Default configuration
Converter: 1 MAX197
Note: The base address is the start address of the I/O 1.4.2 Adjustment of the Interrupt
address range which must not be used by any other PC Channel
plug-in card.
In case the interrupt feature of the DAC98 is to be used,
The enclosed driver software requires the card with the a free interrupt channel of the PC hardware has to be
base address 300 ( hex ). If you want to use this software identified. This channel number is then adjusted by means
without any changes please assure that none of the other of the jumpers JP4 to JP12 (see table). The default
PC plug-in cards in your PC uses the same base address. interrupt channel setting is IRQ7. As for the base address
Otherwise you may change the base address in the it is to be assured that none of the other PC plug-in cards
software as well as for the PC plug-in card accordingly. uses the same interrupt channel.
I/O Address 3 2 1 JP 4 5 6 7 8 9 10 11 12
(Hex) IRQ 3 4 5 7 9 10 11 12 15
300(*) 1 1 1
310 0 1 1 The PC hardware may be damaged when more than one
320 1 0 1 jumper is installed or in case the selected interrupt channel
330 0 0 1 is in use by another card.
340 1 1 0
350 0 1 0
360 1 0 0
370 0 0 0
1.4.6 Installation of the Card in the PC (r) = read the DATR, (w) = write to the DATR
a) Switch off the power to the PC and all other connected HWADR
peripheral devices, e.g. monitor, printer. (r/w)
b) Disconnect all cables of your PC. 0x00(r) read the identification string
0x08(r/w) initialize A/D converter
c) Remove the top cover of your PC. (For details please A/D converter low-byte
refer to the manual of your PC). 0x09(r) A/D converter high-byte
0x10(w) D/A converter channel 0
d) Choose a free add-on slot (16 bit ISA) and remove the 0x18(w) D/A converter channel 1
corresponding slot cover at the rear. 0x20 Counter No. 0 of the 8254 timer
0x21 Counter No. 1 of the 8254 timer
e) Plug in the DAC98 in the chosen slot and tighten the 0x22 Counter No. 2 of the 8254 timer
screw to hold the card’s retaining bracket. 0x23 Mode of the 8254 timer
0x28 PortA of the 8255 IO-interface
f) Replace the PC’s top cover and fasten the screws. digital outputs
Connect all cables. 0x29 PortB of the 8255 IO-interface
digital inputs
The card is now ready for operation. To test the function 0x2A PortC of the 8255 IO-interface
please install the software (ref. chapter 3.1). digital outputs/inputs used internally
0x2B Mode of the 8255
0x30 DDM No. 0 high-byte during read operation
1.5 Programming of the DAC98 of the 16 bit increment counter,
chip reset during write operation
0x31 DDM No. 0 low-byte of the
Initialization and programming of the PC plug-in card 16 bit increment counter
DAC98 is described in the following to give a better 0x38 DDM No. 1 high-byte during read operation
understanding of its functions. The functions itself are of the 16 bit increment counter,
realized by the drivers (see also chapter 4) included in the chip reset during write operation
shipment. 0x39 DDM No. 1 low-byte of the
16 bit increment counter
1.5.1 The Registers of the DAC98 0x78 DDM No. 2 high-byte during read operation
of the 16 bit increment counter,
Mainly two ports are used to program the DAC98. One chip reset during write operation
hardware address register (HWADR) for addressing the 0x39 DDM No. 2 low-byte of the
individual components of the card, and one data register 16 bit increment counter
(DATR). The access mode of the HWADR at the base 0xBA CSDDMALL
address (BADR) is write only. 0xBB all of the DDM chips are reset 0xF8
interrupt/clock signal
The DATR is addressable by BADR + 4 and can either
be read or written, depending on the chosen HWADR.
1.5.2 Configuration of the DAC98 are to be read until this bit is reset to "0" to detect the end
of the conversion. The read operation for the digital inputs
The PC plug-in card DAC98 contains programmable chip is described in section 1.5.7.
devices which have to be initialized before using the
functions of the card. Now the result of the A/D conversion may be read:
At first the digital inputs and outputs are to be configured At first a value of 0x08 (address of low-byte) is written
by programming the 8255 chip containing 3 digital ports into the HWADR. Reading the DATR in the following
(PortA, PortB, PortC) either operating as inputs or outputs will result with the low-byte. Writing then a value of 0x09
with 8 bits for each port. PortC is used internally and is to (address of high-byte) into the HWADR will result with
be programmed such that its bits 0...3 operate as inputs the high-byte after the next reading of the DATR. The
and its bits 4...7 operate as outputs. PortA has to operate described sequence of operations is to be obeyed
as an output whereas PortB has to operate as an input. absolutely during reading the converter.
The programming of the chip is performed in two steps. Bit Pattern Selected Channel
At first a value of 0x2B (address of the 8255 mode D2 D1 D0
register) is written into the HWADR. Writing then a data 0 0 0 0
value of 0x8A into DATR will program the input/output 0 0 1 1
functions as described above. 0 1 0 2
0 1 1 3
1 0 0 4
At next the frequency to control the timer is to be
1 0 1 5
programmed which will be described in section 1.5.11 .
1 1 0 6
1 1 1 7
1.5.3 Reading the Identification String
Bit Pattern Selected Range
Reading the identification string (a preassigned bit map) D4 D3
is performed in two steps. At first a value of 0x00 (address 0 0 0..5V
of the identification string) is written into the HWADR. 0 1 0..10V
Reading then the DATR should result in a value of 0x55 1 0 -5..+5V
when the card is installed correctly. 1 1 -10..+10V
1.5.6 Programming the Timer Chip means 0x88 is written in the register DATR at first.
8253 Afterwards the high byte (0x13 in our case) is written in
the register DATR. With this the programming of the 32
Since this chip offers a lot of features it is recommended bit timer is completed.
to use its hardware manuals i.e. "Intel Microprocessor and
Peripheral Handbook, Volume II Peripheral". Only a You will find an application of this programming
simple application example will be described in the instruction in the "C++" respective "C" files in the
following. functions SetTimer, SetCounter. When using the 8253
timer/counter to program interrupts a minimum sampling
The 16 bit timer 0 and 1 of this chip are wired by hardware period should be regarded. This minimum sampling
such that they operate as a cascaded 32 bit timer. This 32 period depends on the available computing power, the
bit timer counts the clock signal provided by a quartz base used operating and bus system etc.. With a standard PC
with a programmable divisor. The remaining timer 3 (80386 DX40, operating system DOS, ISA-Bus) this
operates as a single 16 bit timer/counter either counting minimum sampling period is about 0.5 ms, in case the
the clock signal mentioned above or external events. On interrupt service routine has a very short execution time.
counter overflow an interrupt may be requested in case
this feature is enabled. 1.5.7 Reading the Digital Inputs
The following example describes the programming of the Reading the digital inputs requires two steps. At first a
32 bit timer operating as a square wave generator (suitable value of 0x29 (address of digital inputs) is written into the
for interrupt triggering) with a period of 10 seconds. HWADR. Reading the DATR in the following will result
with the state of the digital inputs. The single bits of the
According to the default clock signal with 2 MHz, the 32 data byte correspond to the input channel numbers as
bit timer has to be initialized with a value of 20.000.000. follows:
Since two 16 bit timer operate in a cascade, this value has
to be separated in the product 4000 * 5000 (hexadecimal Data bit Assignment
format: 0x0FA0 * 0x1388). At first the mode register of D0 digital input 0
the 8253 is addressed by writing the value 0x0B3 in the D1 digital input 1
register HWADR. Writing a value of 0x36 in the register D2 digital input 2
DATR will program the mode register such that counter D3 digital input 3
0 is selected, low-byte-first is adjusted and the mode 3 is D4 digital input 4
D5 digital input 5
selected. Then the counter 0 is addressed by writing 0x08
D6 digital input 6
in the register HWADR. Now the low byte of the desired
D7 digital input 7
divisor (in our case the low byte of 0x0FA0 is 0xA0), that
means 0xA0 is written in the register DATR at first. For the digital inputs a 1 means the input has an high level
Afterwards the high byte (0x0F in our case) is written in signal.
the register DATR. With this the programming of the
counter 0 is completed and the similar programming of
1.5.8 Setting the Digital Outputs
the counter 1 will be as follows. The mode register of the
8253 is addressed again by writing the value 0x0B in the Setting the digital outputs requires two steps. At first a
register HWADR. Writing a value of 0x76 in the register value of 0x28 (address of digital outputs) is written into
DATR will program the mode register so that counter 1 the HWADR. Writing a data byte to the DATR in the
is selected, low-byte-first is adjusted and the mode 3 is following will set the digital outputs accordingly. The
selected. Then the counter 1 is addressed by writing 0x09 single bits of the data byte correspond to the output
in the register HWADR. Now the low byte of the desired channel numbers as follows:
divisor (in our case the low byte of 0x1388 is 0x88), that
Attention !
3.4 Menu ’IO-Interface’ The test software tries to access the base address to test
the configuration when any selection is prompted using
the OK button. Caution, any fault address setting may
The pull down menu ’IO-Interface’, see figure 3.3, cause hardware conflicts!
provides two functions to manipulate the driver settings
for the DAC98 PC plug-in card.
The sub-menu ’Address of DAC98’ opens a menu to Figure 3.6: The window ’Error’
select one of the valid base addresses of the PC plug-in
card.
3.5 Menu ’Test’ The DDM devices may be reset using the displayed
control buttons.
The pull down menu ’Test’ provides two functions to test The timer resp. the counter decrement the preset value
the DAC98 PC plug-in card. only when the ’Gate’ control button is active. The preset
values may be changed at any time but they will be taken
The menu ’Show all’ opens a window displaying the as start values only when the corresponding control button
value of all signals of the DAC98 PC plug-in card. The is active.
analog signals are displayed in the left part whereas the
digital signals are displayed in the right part of the
window. The analog inputs will show a value of 0V and
the digital inputs will show low level when the external
connector of the PC plug-in card is open.
The menu item ’Test’ opens a window as shown in figure 3.6 Menu ’Measure’
3.8.
The field "DAC-Info-Box" displays the current The menu ’Measure’ opens a window displaying
configuration settings as well as a specific jumper setting measured data from the analog inputs in a graphic. One
of the PC plug-in card. For the jumper the message or multiple data channels are selectable by corresponding
"intern" means that the timer counts the internal clock. control buttons. The input signal range is +/- 10V for each
The message "extern/undef" means that the timer either analog input. The width of the graphic corresponds to 380
counts external events or that the jumper is missing. samples taken in between a time which depends on the
computing power of the PC.
The following fields allow for selection of single
component tests and display the corresponding results.
But all of these tests are meaningfull only when a special
test adapter from amira is connected to the PC plug-in
card.
The pull down menu ’Help’ only contains the item ’Info’
as shown in figure 3.10. The selection of this item will
display short information about the program version and
the copyright.
Basic Classes:
none
Public Data:
unsigned int ddm_counterr[3] is an array containing
the increment values
counted by the three DDM
devices.
enum Clkmodes defines the series of
constant values for the
clock rate of the timer device
Private Data:
unsigned char ddm_adr[3] is an array containing
the addresses of the three DDM
devices
unsigned long timer_counter0 is the content of the first timer
unsigned long timer_counter is the content of the second timer
unsigned int timer_counter2 is the content of the third timer
int Base is the base address of the DAC98
int WR_DATA is the offset which is to be added
to the base address to write
to the data register
Class: DAC98
Description:
Parameters:
Parameter: none
int adress is the base address of the PC plug-in
card in the IO address range of the PC. Return value:
int the adjusted base address of the PC plug-in card.
Return value:
none
Name: Name:
SetAdress GetInterrupt
Description: Description:
The function SetAdress adjusts the current base address The function GetInterrupt returns a flag representing the
to the new value of Base. This value has to match the base number of the interrupt channel which was adjusted by
address which is configured on the hardware of the the function SetInterrupt previously.
DAC98 to guarantee further accesses to the card.
Attention: The jumper configuration on the hardware
Attention: Address conflicts may damage the PC must be same. Interrupt conflicts may damage your
hardware ! hardware.
Parameters: Parameters:
int adr is the new base address of the none
PC plug-in card DAC98.
Return value:
Return value: int number of interrupt channel.
none
Name: Name:
SetInterrupt Identifikation
Description: Description:
The function SetInterrupt adjusts the flag representing The function Identifikation checks whether the amira
the number of the interrupt channel which is configured DAC98 responds to the base address of the driver
by a jumper on the hardware. software. Any value unequal to zero is returned when the
PC plug-in card returns a bit string preassigned on its
Attention: The jumper configuration on the hardware hardware.
must be same. Interrupt conflicts may damage your
hardware.
Parameters:
none
Parameters:
int i is the number of the new interrupt Return value:
channel
int Result = 1 indicates that the hardware responded
to the base address, else the result = 0.
Return value:
none
Name: Name:
Init Exit
Description: Description:
The function Init at first calls the function Identifikation. The function Exit adjusts the analog and digital outputs
When this call is successfull the amira DAC98 is to 0, the DDM devices are reset and the counter as well
initialized to the default settings. as the timer are stopped.
Parameters: Parameters:
none none
Name: Name:
Setup SetClock
Description: Description:
The function Setup searches for the amira DAC98 using The function SetClock adjusts the clock rate for the timer
all of the adjustable base addresses. This operation may device to the given value.
cause hardware conflicts when any other card operates in
the same address range, i. e. a network card. So the
function must only be used when this case can be Parameters:
excluded. int mode is the desired clock rate.
See the table for the adjustable values.
Attention: Address conflicts may damage the PC The variable mode may be used or
the string constant from the second
hardware !
column
Return value:
none
Name: Name:
GetClock WriteDigital
Description: Description:
The function GetClock returns the adjusted clock rate of The function WriteDigital resets the state of the output
the timer device. channel channel when the parameter value = 0 otherwise
the state is set to 1.
Parameters:
none Parameters:
in channel is the number of the digital output
Return value: channel
Return value:
none
Name: Name:
WriteAllDigital ReadDigital
Description: Description:
The function WriteAllDigital adjusts the state of the 12 The function ReadDigital returns the state (0 or 1) of the
digital output channels according to the lower 12 bits of digital input channel channel.
the parameter value .
Parameters:
Parameters: int channel is the number of the digital input channel.
int value state of the 12 output ports.
Channel Assignment
Data bit Assignment 0 digital input 0
D0 digital output 0 1 digital input 1
D1 digital output 1 2 digital input 2
D2 digital output 2 3 digital input 3
D3 digital output 3 4 digital input 4
D4 digital output 4 5 digital input 5
D5 digital output 5 6 digital input 6
D6 digital output 6 7 digital input 7
D7 digital output 7 8 busy signal of the AD
D8 set the gate of the 32 bit converter
timer (output 8) 9 not used
D9 set the gate of the 16 bit 10 not used
timer (output 9) 11 not used
D10 no function (output 10)
D11 no function (output 11)
Return value:
int state of the digital input channel.
Return value:
none
Name: Name:
ReadAllDigital SetCounter
Description: Description:
The function ReadAllDigital returns the state of the 12 The function SetCounter adjusts the initial value of the
digital input channels in the lower 12 bits of the return 16 bit counter to the given parameter count.
value.
Parameters:
Parameters: unsigned int count is the new initial value
none of the counter (will be decremented).
Name: Name:
GetCounter WaitCounter
Description: Description:
The function GetCounter returns the current content of The function WaitCounter provides a precise delay time
the 16 bit counter. by counting the internal timer clock. The function returns
1 only when the counter counts the internal timer clock
signal otherwise it returns 0.
Parameters:
none Attention: The delay time is correct only in case the
counter is configured to count the (internal) timer clock.
Return value:
unsigned int is the counter content.
Parameters:
unsigned long time delay time in milli seconds.
Return value:
int Result = 1, when the counter counts the internal
timer clock signal otherwise it returns 0.
Name: Name:
TestCounterJMP GateCounter
Description: Description:
The function TestCounterJMP checks whether the The function GateCounter enables or disables the gate
counter is configured for counting internal or external of the 16 bit counter. The counter is started with val=1.
events.
Parameters:
Parameters: int val is the new value for the counter
none gate.
Name: Name:
SetTimer SetTimer
Description: Description:
The function SetTimer adjusts the initial value for the 32 The function SetTimer adjusts the initial value for the 32
bit counter ( square wave operating mode). The upper 16 bit counter ( square wave operating mode). The parameter
bit are written into the upper cascade of the timer register time is taken as a period time in milli seconds.
and the lower 16 bit are written into the lower cascade.
The resulting period time is given by the product of the
upper and lower cascade settings multiplied with the Parameters:
period time of the clock signal (default 1/2000000 s). unsigned long time timer value in milli seconds.
Return value:
Parameters: none
unsigned long time is the new time value for the
timer cascade.
Return value:
none
Name: Name:
GetTimer GateTimer
Description: Description:
The function GetTimer returns the current content of the The function GateTimer enables or disables the gate of
32 bit timer. the 32 bit timer. The timer is started with val=1.
Parameters: Parameters:
none int val is the new value for the timer gate.
Name: Name:
SetINT GetINT
Description: Description:
The function SetINT enables the interrupt channel The function GetINT returns the state of the interrupt
determined by channel when the parameter val is unequal channel register. Any data bit reset to 0 indicates the
to zero. In the other case the interrupt channel is disabled. source which requested the interrupt from the card
previously.
Parameters:
int channel is the DAC98 interrupt channel. Parameters:
Valid channels are: none
0, 32 bit timer overflow
1, 16 bit counter overflow Return value:
2, end of conversion AD converter int state of the interrupt channel:
Name: Name:
ResetDDM ResetAllDDM
Description: Description:
The function ResetDDM resets a single DDM device The function ResetAllDDM resets all of the DDM
indicated by the parameter channel. devices at once.
Parameters: Parameters:
int channel is the DDM device number. none
Name: Name:
ReadDDM ReadAllDDM
Description: Description:
The function ReadDDM reads the DDM device specified The function ReadAllDDM reads all of the three DDM
by the parameter channel and stores the results to the devices and stores the results to the corresponding public
corresponding public data elements. The increment data elements. Before the read operation all the registers
counter content is returned directly. of the DDM devices are switched at the same time such
that the results belong to the same time.
Parameters:
int channel is the DDM device number. Parameters:
none
Return value:
unsigned int is the 16 bit increment counter Return value:
content of the DDM device. none
Name: Name:
ReadAnalogInt ReadAnalogVolt
int ReadAnalogInt( int channel, int mode=3 ); float ReadAnalogVolt( int channel, int mode );
Description: Description:
The function ReadAnalogInt reads the analog input The function ReadAnalogVolt reads the analog input
channel specified by channel and returns the channel specified by channel and returns the
corresponding integer value with respect to the input corresponding voltage value with respect to the input
signal range given by mode. signal range given by mode.
Parameters: Parameters:
int channel is the number of the analog input channel. int channel is the number of the analog input channel.
int mode is the mode defining the input signal range int mode is the mode defining the input signal range
according to: according to:
0, 0..5V 0, 0..5V
1,0..10V 1,0..10V
2, -5..+5V 2, -5..+5V
3, -10..+10V 3, -10..+10V
Name: Name:
WriteAnalogInt WriteAnalogVolt
void WriteAnalogInt( int channel, int value ); void WriteAnalogVolt( int channel, float value );
Description: Description:
The function WriteAnalogInt sends an analog value to The function WriteAnalogVolt operates similar to
the desired channel (0 or 1). The parameter value has to WriteAnalogInt, but the output value is taken as a
be in a range from 0 to +4095. voltage. Its value has to be in the range from -10(V) to
+10(V).
Parameters:
int channel is the number of the analog output Parameters:
channel. int channel is the number of the analog output
int value is the output value. channel.
int value is the output value in Volt.
Return value:
none Return value:
none
Basic Class:
Parameters:
none DAC98
Name: Name:
DIC ~DIC
Description: Description:
The constructor only requires the base address of the card. The destructor requires no parameters.
The field ddm_counter(3) is reset to 0 because the DAC98
contains only 3 DDM devices instead of 4 on the DIC24.
Parameters:
Parameters: none
int adress is the base address of the adapter
card in the address range of the PC.
Return value:
Return value:
none
none
Name: Name:
GetDigitalOut GetAnalogOut
Description: Description:
The function GetDigitalOut returns the content of the The function GetAnalogOut returns the integer value
shadow register for the digital outputs. previously transfered to the specified analog channel.
Parameters: Parameters:
none int channel is the analog channel number.
Name: Name:
GetDDMCounter GetDDMTimer
unsigned int GetDDMCounter( int channel ); unsigned long GetDDMTimer( int channel );
Description: Description:
The function GetDDMCounter returns the last counter The function GetDDMTimer returns a timer value of 0
content (global variable) of the DDM component for any channel because this function is not implemented
specified by the given channel number, which was read in the new DDM device. This dummy function is
by the functions ReadDDM or ReadAllDDM. For established only for compatibility reason.
channel = 3 the return value is always = 0.
Parameters:
Parameters: int channel is the number of the DDM device.
int channel is the DDM device number (0, 1, 2).
Return value:
Return value: unsigned long here always = 0.
unsigned int is the 16 bit increment counter
content of the DDM device.
Name: Name:
GetDDMStatus FilterINC
unsigned char GetDDMStatus( int channel ); void FilterINC( int channel, int val );
Description: Description:
The function GetDDMStatus returns a state value of 0 The function FilterINC is an empty function. This
for any channel because this function is not implemented dummy function is established only for compatibility
in the new DDM device. This dummy function is reason.
established only for compatibility reason.
Parameters:
Parameters: int channel is the number of the DDM device.
int channel is the number of the DDM device. int val is the desired filter state
(0==on, 1 == off)
Return value:
unsigned char here always = 0. Return value:
none
Name: Name:
TimerDirINC SetINT
void TimerDirINC( int channel, int val ); void SetINT( int channel, int val );
Description: Description:
The function TimerDirINC is an empty function. This The function SetINT adjusts the interrupt enable register
dummy function is established only for compatibility of the DAC98.
reason.
Parameters:
Parameters: int channel is the interrupt channel.
int channel is the number of the DDM device. Valid channels are:
int val is the desired count direction state 4, 32 bit timer overflow
(0==increment, 1 == decrement) 5, 16 bit counter overflow
int val is the interrupt enable flag.
Return value:
none Return value:
none
Name: Name:
SetTimer GetTimer
Description: Description:
The function SetTimer adjusts the initial value for the 32 The function GetTimer returns the current content of the
bit counter ( square wave operating mode). The upper 16 32 bit timer.
bit are written into the upper cascade of the timer register
and the lower 16 bit are written into the lower cascade. The identification procedure of the "old" DIC24 is
The resulting period time is given by the product of the simulated in addition.
upper and lower cascade settings multiplied with the
period time of the clock signal (default 1/2000000 s).
Parameters:
The identification procedure of the "old" DIC24 is none
simulated in addition.
Return value:
unsigned long is the timer content.
Parameters:
unsigned long time is the new time value for the
timer cascade.
Return value:
none
Public Data:
unsigned int ddm_counter[1] is an array containing
the increment count
of the first DDM device.
Name: Name:
PCIO ~PCIO
Description: Description:
The constructor only requires the base address of the card. The destructor requires no parameter.
Parameters: Parameters:
int adress is the base address of the adapter none
card in the address range of the PC.
Return value:
Return value: none
none
Name: Name:
DigitalOutStatus IsPCIO
Description: Description:
The function DigitalOutStatus returns the state of the The function IsPCIO calls the function Identifikation of
digital outputs. the class DAC98 to check whether the DAC98 responds
to the base address of the driver software. Any value
unequal to zero is returned when the PC plug-in card
Parameters: returns a bit string preassigned on its hardware.
none
Return value:
int Result of the test. Values unequal to zero indicate
that the hardware responded to the base address.
Name: Name:
ReadAnalogVoltMean ResetHCTL
Description: Description:
The function ReadAnalogVoltMean reads the analog The function ResetHCTL calls the function ResetDDM
input specified by channel repeat times and returns the to reset the first DDM device.
mean value as a voltage.
Parameters:
Parameters: none
int channel is the analog input channel.
int repeat is the number of read operations. Return value:
none
Return value:
float mean value of analog input in Volt.
Name: Name:
ReadHCTL SetINT
Description: Description:
The function ReadHCTL calls the function ReadDDM The function SetINT adjusts the interrupt enable register
and returns the content of the increment counter of the of the DAC98.
first DDM device.
Parameters:
Parameters: int val is the interrupt enable flag.
none
Return value:
Return value: none
int increment counter content.
OpenDriver
HDRVR hDriver = OpenDriver(szDriverName, NULL, NULL)
Parameters szDriverName is the file name of the driver, valid names are "DAC98.DRV",
"DAC6214.DRV" and "DIC24.DRV" (according to the PC adapter cards) possibly
combined with complete path names.
Description The function OpenDriver initializes the driver and returns a handle for following accesses to this
driver. If this function is called the first time the driver is loaded into the memory. Any further
calls return another handle of an existing driver. The driver handle is valid only when the return
value is unequal to NULL. In case the return value is equal to NULL, the function OpenDriver
failed meaning that further driver accesses by the functions SendDriverMessage or CloseDriver
are invalid. The parameter szDriverName of the function OpenDriver contains the DOS file
name of the driver. The file name may include the disk name as well as the complete path names
according to the 8.3 name convention but it must not exceed 80 characters. When only a single
file name is used, the drivers location is expected in the standard search path of Windows. The
other parameters are meaningless and should be equal to NULL.
The address of the PC adapter card handled by this driver is read from a specific entry of the file
SYSTEM.INI from the public Windows directory. When this entry is missing the default address
0x300 (=768 decimal) will be taken.
Return Valid driver handle or NULL.
SendDriverMessage
LRESULT result = SendDriverMessage( hDriver, DRV_USER, PARAMETER1,
PARAMETER2 )
TMainForm.ShowHint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-10
TMainForm.FormCreate . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-10
TMainForm.FormShow . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-10
TMainForm.FormClose . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-11
TMainForm.FormDestroy . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-11
TMainForm.FileMenuClick . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-11
TMainForm.OpenPIClick . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-11
TMainForm.SavePIClick . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-12
TMainForm.SavePIasClick . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-12
TMainForm.OpenFuzzyClick . . . . . . . . . . . . . . . . . . . . . . . . . . 1-12
TMainForm.LoadPlotData1Click . . . . . . . . . . . . . . . . . . . . . . . . . 1-13
TMainForm.SavePlot1Click . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-13
TMainForm.Print1Click . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-13
TMainForm.PrintSetup1Click . . . . . . . . . . . . . . . . . . . . . . . . . . 1-13
TMainForm.ExitItemClick . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-14
TMainForm.IOInterface1Click . . . . . . . . . . . . . . . . . . . . . . . . . . 1-14
TMainForm.DAC98Click . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-14
TMainForm.DIC24Click . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-15
TMainForm.DAC6214Click . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-15
TMainForm.DACSetupClick . . . . . . . . . . . . . . . . . . . . . . . . . . 1-15
TMainForm.Edit1Click . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-16
TMainForm.PIControllerSetupClick . . . . . . . . . . . . . . . . . . . . . . . 1-16
TMainForm.FuzzyControllerSetupClick . . . . . . . . . . . . . . . . . . . . . . 1-16
TMainForm.useEncoder1Click . . . . . . . . . . . . . . . . . . . . . . . . . . 1-16
TMainForm.UseTacho1Click . . . . . . . . . . . . . . . . . . . . . . . . . . 1-17
TMainForm.Run1Click . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-17
TMainForm.PIController1Click . . . . . . . . . . . . . . . . . . . . . . . . . 1-17
TMainForm.FuzzyController2Click . . . . . . . . . . . . . . . . . . . . . . . . 1-18
TMainForm.OpenLoopControl1Click . . . . . . . . . . . . . . . . . . . . . . . 1-18
TMainForm.StopController1Click . . . . . . . . . . . . . . . . . . . . . . . . 1-18
TMainForm.StartMeasuring1Click . . . . . . . . . . . . . . . . . . . . . . . . 1-19
TMainForm.SetpointGenerator1Click . . . . . . . . . . . . . . . . . . . . . . . 1-19
TMainForm.View1Click . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-19
TMainForm.PlotMeasuredData1Click . . . . . . . . . . . . . . . . . . . . . . . 1-19
TMainForm.PlotFileData1Click . . . . . . . . . . . . . . . . . . . . . . . . . 1-20
TMainForm.ParametersfromPLDFile1Click . . . . . . . . . . . . . . . . . . . . 1-20
TMainForm.Fuzzy3D1Click . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-20
TMainForm.Timing1Click . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-20
TMainForm.Contents1Click . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-21
TMainForm.SearchforHelpon1Click . . . . . . . . . . . . . . . . . . . . . . . 1-21
TMainForm.HowtoUseHelp1Click . . . . . . . . . . . . . . . . . . . . . . . . 1-21
TMainForm.About1Click . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-21
TMainForm.Timer1Timer . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-22
TMainForm.PaintBox1Click . . . . . . . . . . . . . . . . . . . . . . . . . . 1-22
TMainForm.MeasLabelClick . . . . . . . . . . . . . . . . . . . . . . . . . . 1-22
TSingleInstance.WndProc . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-23
TAboutBox.FormShow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-23
TShow3DFuzDlg.rescale . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-23
TShow3DFuzDlg.recalc . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-23
TShow3DFuzDlg.calcrot . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-24
TShow3DFuzDlg.calctrans . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-24
TShow3DFuzDlg.FormShow . . . . . . . . . . . . . . . . . . . . . . . . . . 1-25
TShow3DFuzDlg.FormHide . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-25
TShow3DFuzDlg.FuzzyCBoxChange . . . . . . . . . . . . . . . . . . . . . . . 1-26
TShow3DFuzDlg.DrawSquare . . . . . . . . . . . . . . . . . . . . . . . . . . 1-26
TShow3DFuzDlg.DrawCoors . . . . . . . . . . . . . . . . . . . . . . . . . . 1-27
TShow3DFuzDlg.DrawCoors2 . . . . . . . . . . . . . . . . . . . . . . . . . . 1-27
TShow3DFuzDlg.DrawMark . . . . . . . . . . . . . . . . . . . . . . . . . . 1-27
TShow3DFuzDlg.PaintBoxPaint . . . . . . . . . . . . . . . . . . . . . . . . . 1-27
TShow3DFuzDlg.ScrollBar1Change . . . . . . . . . . . . . . . . . . . . . . . 1-28
TShow3DFuzDlg.ScrollBar2Change . . . . . . . . . . . . . . . . . . . . . . . 1-28
TShow3DFuzDlg.PaintBoxMouseDown . . . . . . . . . . . . . . . . . . . . . . 1-28
TShow3DFuzDlg.PaintBoxMouseMove . . . . . . . . . . . . . . . . . . . . . . 1-29
TShow3DFuzDlg.PaintBoxMouseUp . . . . . . . . . . . . . . . . . . . . . . . 1-29
TShow3DFuzDlg.KoorsCBoxClick . . . . . . . . . . . . . . . . . . . . . . . . 1-29
TShow3DFuzDlg.Koors2CBoxClick . . . . . . . . . . . . . . . . . . . . . . . 1-30
TShow3DFuzDlg.ColorCBoxClick . . . . . . . . . . . . . . . . . . . . . . . . 1-30
TShow3DFuzDlg.LowResCBoxClick . . . . . . . . . . . . . . . . . . . . . . . 1-30
TShow3DFuzDlg.PrintBBtnClick . . . . . . . . . . . . . . . . . . . . . . . . 1-30
TShow3DFuzDlg.MarkCBoxClick . . . . . . . . . . . . . . . . . . . . . . . . 1-31
TShow3DFuzDlg.Timer1Timer . . . . . . . . . . . . . . . . . . . . . . . . . 1-31
TShow3DFuzDlg.HelpBtnClick . . . . . . . . . . . . . . . . . . . . . . . . . 1-31
TFuzzyParameterDlg.Big . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-31
TFuzzyParameterDlg.Small . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-32
TFuzzyParameterDlg.FormCreate . . . . . . . . . . . . . . . . . . . . . . . . 1-32
TFuzzyParameterDlg.FormDestroy . . . . . . . . . . . . . . . . . . . . . . . . 1-32
TFuzzyParameterDlg.FormShow . . . . . . . . . . . . . . . . . . . . . . . . . 1-32
TFuzzyParameterDlg.Sel1BBtnClick . . . . . . . . . . . . . . . . . . . . . . . 1-33
TFuzzyParameterDlg.Ed1BBtnClick . . . . . . . . . . . . . . . . . . . . . . . 1-33
TFuzzyParameterDlg.CancelEdBBtnClick . . . . . . . . . . . . . . . . . . . . . 1-33
TFuzzyParameterDlg.SaveEdBBtnClick . . . . . . . . . . . . . . . . . . . . . . 1-33
TFuzzyParameterDlg.OKBtnClick . . . . . . . . . . . . . . . . . . . . . . . . 1-34
TFuzzyParameterDlg.HelpBtnClick . . . . . . . . . . . . . . . . . . . . . . . . 1-34
TMeasureDlg.OKBtnClick . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-34
TMeasureDlg.HelpBtnClick . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-35
TPIParameterDlg.FormShow . . . . . . . . . . . . . . . . . . . . . . . . . . 1-35
TPIParameterDlg.OKBtnClick . . . . . . . . . . . . . . . . . . . . . . . . . . 1-35
TPIParameterDlg.HelpBtnClick . . . . . . . . . . . . . . . . . . . . . . . . . 1-35
TPLDInfoDlg.FormShow . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-36
TPLDInfoDlg.HelpBtnClick . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-36
TPlotDlg.OKBtnClick . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-36
TPlotDlg.HelpBtnClick . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-36
TPrintPlotDlg.PrinterBitBtnClick . . . . . . . . . . . . . . . . . . . . . . . . . 1-37
TPrintPlotDlg.OKBtnClick . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-37
TPrintPlotDlg.FormShow . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-37
TPrintPlotDlg.HelpBtnClick . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-37
TGeneratorDlg.OKBtnClick . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-38
TGeneratorDlg.FormShow . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-38
TGeneratorDlg.HelpBtnClick . . . . . . . . . . . . . . . . . . . . . . . . . . 1-38
TTimingForm.UpdateData . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-39
TTimingForm.HideButtonClick . . . . . . . . . . . . . . . . . . . . . . . . . 1-39
TTimingForm.HelpButtonClick . . . . . . . . . . . . . . . . . . . . . . . . . 1-39
TTimingForm.PaintBox1Paint . . . . . . . . . . . . . . . . . . . . . . . . . . 1-39
TTimingForm.PaintBox2Paint . . . . . . . . . . . . . . . . . . . . . . . . . . 1-40
TTimingForm.ResetBtnClick . . . . . . . . . . . . . . . . . . . . . . . . . . 1-40
FloatToStr2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-40
FloatToStr3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-40
FloatToStr4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-41
FloatToStr5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-41
StrToFloatMinMax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-41
StrToFloatStrMinMax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-42
MinMaxi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-42
DetectNT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-42
LibMain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-48
WEP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-48
LockMemory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-48
SetDriverHandle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-49
DoService . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-49
SetParameter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-50
GetParameter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-50
GetData . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-50
GetTiming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-51
ReadFuzzy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-51
ReadPIPar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-51
WritePIPar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-52
IsDemo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-52
MeasureStart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-52
MeasureLevel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-53
MeasureStatus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-53
OpenFuzzy3D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-53
CloseFuzzy3D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-53
InfoFuzzy3D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-54
CalcFuzzy3D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-54
DR300STA::DR300STA() . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-55
DR300STA::Calc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-55
DR300STA::Reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-56
DR300STA::Load . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-56
DR300STA::Save . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-56
DR300STA::GetKr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-57
DR300STA::GetTr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-57
DR300STA::GetFileName . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-57
DR300STA::GetId . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-57
DR300STA::geterrors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-57
DR300STA::SetTa . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-58
DR300FUZ::DR300FUZ() . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-59
DR300FUZ::~DR300FUZ() . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-59
DR300FUZ::Calc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-60
DR300FUZ::Reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-60
DR300FUZ::Load . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-60
DR300FUZ::Save . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-61
DR300FUZ::getname . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-61
DR300FUZ::GetFileName . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-61
DR300FUZ::GetId . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-61
DR300FUZ::geterrors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-62
DR300FUZ::SetTa . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-62
STOREBUF::ResetBufIndex . . . . . . . . . . . . . . . . . . . . . . . . . . 1-64
STOREBUF::STOREBUF . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-64
STOREBUF::~STOREBUF() . . . . . . . . . . . . . . . . . . . . . . . . . . 1-64
STOREBUF::StartMeasure . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-65
STOREBUF::WriteValue . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-65
STOREBUF::SetOutChan . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-65
STOREBUF::ReadValue . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-65
STOREBUF::GetBufLen . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-66
STOREBUF::GetBufTa . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-66
STOREBUF::GetStatus . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-66
STOREBUF::GetBufferLevel . . . . . . . . . . . . . . . . . . . . . . . . . . 1-66
AFBUF::AFBUF() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-67
AFBUF::~AFBUF() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-67
AFBUF::NewFBuf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-68
AFBUF::ReadFBuf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-68
AFBUF::WriteFBuf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-68
TWOBUFFER::TWOBUFFER() . . . . . . . . . . . . . . . . . . . . . . . . . 1-70
TWOBUFFER::New2Buffer . . . . . . . . . . . . . . . . . . . . . . . . . . 1-70
TWOBUFFER::Write2Buffer . . . . . . . . . . . . . . . . . . . . . . . . . . 1-70
TWOBUFFER::Read2Buffer . . . . . . . . . . . . . . . . . . . . . . . . . . 1-70
SIGNAL::SIGNAL( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-71
SIGNAL::InitTime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-71
SIGNAL::MakeSignal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-72
SIGNAL::ReadNextValue . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-72
SIGNAL::SetRange . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-73
SIGNAL::WriteBuffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-73
SIGNAL::Stuetzstellen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-73
ReadPlot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-75
WritePlot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-75
Plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-76
GetPlot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-77
PrintPlot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-77
GetPldInfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-78
DICDRV::DICDRV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
DICDRV::~DICDRV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
DICDRV::ReadASpeed . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
DICDRV::ReadISpeed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3
DICDRV::ReadTime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3
DICDRV::ReadDriveCurrent . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3
DICDRV::ReadLoadCurrent . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4
DICDRV::SetControlSignals . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4
DICDRV::CheckSystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4
DICDRV::CheckFree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4
DICDRV::TopSwitch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5
DICDRV::StartInterrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5
DICDRV::TriggerEndstufe . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5
DICDRV::CalcModel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5
DICDRV::WinDelay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5
WDAC98::ReadAnalogVolt . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6
WDAC98::WriteAnalogVolt . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7
WDAC98::ReadDigital . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7
WDAC98::ReadAllDigital . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7
WDAC98::WriteDgital . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7
WDAC98::GetCounter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8
WDAC98::SetCounter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8
WDAC98::GetTimer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8
WDAC98::SetTimer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8
WDAC98::ReadDDM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8
WDAC98::ResetDDM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9
WDAC98::ResetAllDDM . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9
3.2.3 References of the Classes, their Data and Element Functions . . . . . . . . . . . . . . 3-4
FuzzySet::FuzzySet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4
FuzzySet::FuzzySet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4
FuzzySet::FuzzySet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5
FuzzySet::FuzzySet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5
FuzzySet::~FuzzySet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5
FuzzySet::getname . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5
FuzzySet::cleary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-6
FuzzySet::getxvector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-6
FuzzySet::getyvector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-6
FuzzySet::getstuetzen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-6
FuzzySet::insert . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-6
FuzzySet::normalize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-7
FuzzySet::coa . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-7
FuzzySet::crisp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-7
FuzzySet::conclude . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-7
FuzzySet::tout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-8
FuzzySet::= . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-8
FuzzySet::*= . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9
FuzzySet::+= . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9
FuzzySet::<< . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9
FuzzyVar::FuzzyVar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-10
FuzzyVar::~FuzzyVar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-10
FuzzyVar::getname . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-11
FuzzyVar::getsetname . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-11
FuzzyVar::getsetcount . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-11
FuzzyVar::add . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-11
FuzzyVar::check . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-12
FuzzyVar::norm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-12
FuzzyVar::getmode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-12
FuzzyVar::getmaxx . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-12
FuzzyVar::getminx . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-12
FuzzyVar::get . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-13
FuzzyVar::set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-13
FuzzyVar::clear . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-13
FuzzyVar::out . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-13
FuzzyVar::getval . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-14
FuzzyVar::setval . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-14
FuzzyVar::vsort . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-15
FuzzyVar::<< . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-15
FuzzyRule::FuzzyRule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-16
FuzzyRule::~FuzzyRule . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-16
FuzzyRule::getname . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-16
FuzzyRule::addIn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-17
FuzzyRule::addOut . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-17
FuzzyRule::Do . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-17
FuzzyRule::tout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-17
FuzzyRule::<< . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-18
Fuzzy::Fuzzy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-20
Fuzzy::Fuzzy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-20
Fuzzy::~Fuzzy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-20
Fuzzy::read . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-21
Fuzzy::write . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-21
Fuzzy::generate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-21
Fuzzy::calc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-22
Fuzzy::getinputcount . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-22
Fuzzy::getoutputcount . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-22
Fuzzy::geterrors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-22
Fuzzy::getrulecatch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-23
Fuzzy::speed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-23
Fuzzy::Get3DInfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-24
Fuzzy::getname . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-24
Fuzzy::tout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-24
Fuzzy::parser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-27
Fuzzy::calcsetup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-27
Fuzzy::gettoken . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-28
Fuzzy::defvar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-28
Fuzzy::defset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-29
Fuzzy::defrule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-29
Fuzzy::deflabel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-29
Fuzzy::getlabel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-30
Fuzzy::killstructures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-30
Fuzzy::killfuzzybase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-30
Fuzzy::killlabel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-30
Fuzzy::out . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-31
Fuzzy::<< . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-31
Fuzzy::>> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-31
Version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2
CreateSimplePlotWindow . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2
ShowPlotWindow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3
ClosePlotWindow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4
UpdatePlotWindow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4
GetValidPlotHandle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4
AddPlotTitle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4
AddAxisPlotWindow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-5
AddXData: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-6
AddTimeData: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-6
AddYData: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-6
SetCurveMode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-7
SetPlotMode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-7
PrintPlotWindow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-9
CreateEmptyPlotWindow . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-10
LibMain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-1
SetService . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2
SelectDriver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2
StartTimer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3
IsTimerActive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3
StopTimer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4
GetMinMaxTime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4
GetSimTime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4
SetupDriver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-5
OpenDriver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-1
SendDriverMessage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2
CloseDriver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4
1.1 General
The program is a 16-bit application, which may be started only once by the operating systems Windows 3.1 or
Windows95/98. The desktop is created by means of the program language ’Pascal’, while the actual controller is
realized by a DLL developed with the program language ’C++’. Both program parts are available in source
completely. The program package is completed by
Generating a new executable program is possible only by means of the development systems ’Delphi’ version 1.0
for the desktop and ’Borland C++’ version 4.52 for the controller-DLL. The last may be generated using another
16-bit-C++ compiler in case a suitable project file can be created.
Prior to generating the program the first time please copy the complete content of the enclosed floppy disk to a new
directory of your harddisk by keeping the directory structure (i.e. using the ’Explorer’ to copy to the new directory
DR300).
Where DR300DSK contains the Delphi Project File DR300W16.DPR together with all the accompanying Pascal
source files to generate the desktop, CONTRDLL contains the Borland Project File DR300.IDE with all the
accompanying C++ source files to create the controller-DLL (DRSRV16.DLL). Finally the subdirectory EXE
contains all the additional files required by the executable program as can be seen from the following list:
A DEMO version of the program (simulation of the mathematical model of the Speed Control system instead of
accessing the PC adapter card) may be obtained simply by setting the macro __SIMULATION__ in the include file
DRDEFINE.H and generating a new DRSRV16.DLL. Because the resulting DLL has the same name as the DLL
controlling the real system, it should be copied together with all the required files (DUMMY.DRV is recommended
instead of DAC98.DRV, DAC6214 or DIC24.DRV)to a different subdirectory (i.e. DEMO) afterwards.
The file DRDEFINE.H contains some definitions to clarify the readability of the source code and to adjust the
program mode as well as the fixed sampling period. When __SIMULATION__ is defined all program functions
except for selecting the IO-interface and for viewing timing values are available for a simulated Speed Control
system. The PC adapter card is not required in this program mode. To control the real system the macro
__SIMULATION__ must not be defined!
Used definitions:
#define __FUZZY__
#define __SIMULATION__ //to create Demo version
#define ScopeBufSize 8
#define SIMTIME 0.005
The file DR300DAT.H contains global data structures which are used in different instances of the software. These
structures are saved in the data files used to store measurements.
// Data structures:
struct PROJECT{
char number[10]; // P340 for speed control system
char name[10]; // DR300
char Titel[10]; // SPD CTRL
char Version[10]; // last version
char Date[10]; // last modification
char Dummy[10]; // Reserve
};
CTRLSTATUS {
short controller; // type of active controller
double ta_ms; // adjusted sampling period in [ms]
char fuzname[80]; // "Fuzzy controller" file name
short dummy;
long timeofmeasure; // Date and time of the measurement acquisition
};
struct DATASTRUCT { // Structure to reconstruct the measured data
short nchannel; // Length of the stored measurement vectors (number of channels)
short nvalues; // Number of the measurement vectors (number of samples)
float deltatime; // Time between two samples
};
Measured data stored in a data file are reloadable and may be output in a graphic representation. In addition the
system settings (CTRLSTATUS) which were active during the start of the data acquisition are stored in this file.
They are displayable in a separate window.
The data file contains data in binary format stored in the following order:
The size of the data array is defined in the structure DATASTRUCT. With the DR300 speed control system the
number of the stored channels is always 8 (the length of the measurement vector is 8, i.e. equal to 32 bytes).
The number of the stored measurement acquisitions (vectors) depends on the adjusted values for the sampling
period and the measuring time. The maximum number of measurings is 1024. The time distance between two
successive acquisitions is an integral multiple of the sampling period used by the controller.
The programs desktop is written in the program language Pascal. The main window with its menu bar as well as all
of the following dialogs and message boxes are realized by the following files.
SavePIClick(Sender : TObject)
SavePIasClick(Sender : TObject)
OpenFuzzyClick(Sender : TObject)
LoadPlotData1Click(Sender : TObject)
SavePlot1Click(Sender : TObject)
Print1Click(Sender : TObject)
PrintSetup1Click(Sender : TObject)
ExitItemClick(Sender : TObject)
IOInterface1Click(Sender : TObject)
DAC98Click(Sender : TObject)
DIC24Click(Sender : TObject)
DAC6214Click(Sender : TObject)
DACSetupClick(Sender : TObject)
Edit1Click(Sender : TObject)
PIControllerSetupClick(Sender : TObject)
FuzzyControllerSetupClick(Sender : TObject)
useEncoder1Click(Sender : TObject)
UseTacho1Click(Sender : TObject)
Run1Click(Sender : TObject)
PIController1Click(Sender : TObject)
FuzzyController2Click(Sender : TObject)
OpenLoopControl1Click(Sender : TObject)
StopController1Click(Sender : TObject)
StartMeasuring1Click(Sender : TObject)
SetpointGenerator1Click(Sender : TObject)
View1Click(Sender : TObject)
PlotMeasuredData1Click(Sender : TObject)
PlotFileData1Click(Sender : TObject)
ParametersfromPLDFile1Click(Sender : TObject)
Fuzzy3D1Click(Sender : TObject)
Timing1Click(Sender : TObject)
Contents1Click(Sender : TObject)
SearchforHelpon1Click(Sender : TObject)
HowtoUseHelp1Click(Sender : TObject)
About1Click(Sender : TObject)
Timer1Timer(Sender : TObject)
PaintBox1Click(Sender : TObject)
MeasLabelClick(Sender : TObject)
FuzzyCBoxChange(Sender : TObject)
DrawSquare( can : TCanvas; j, i, z0, z1, z2, z3 : Integer )
HelpBtnClick(Sender : TObject)
FormCreate(Sender : TObject)
FormDestroy(Sender : TObject)
FormShow(Sender : TObject)
Sel1BBtnClick(Sender : TObject)
Ed1BBtnClick(Sender : TObject)
CancelEdBBtnClick(Sender : TObject)
SaveEdBBtnClick(Sender : TObject)
OKBtnClick(Sender : TObject)
HelpBtnClick(Sender : TObject)
OKBtnClick(Sender : TObject)
HelpBtnClick(Sender : TObject)
DetectNT : Boolean
The file DLLS.PAS contains besides the global data definitions the interface definitions for the DLL’s DRSRV16
and TIMER16.
Global Data:
param : ServiceParameter ;
data : ServiceData;
tim : ServiceTiming;
cardNo : WORD;
TMainForm.ShowHint
ShowHint(Sender : TObject)
TMainForm.FormCreate
FormCreate(Sender : TObject)
TMainForm.FormShow
FormShow(Sender : TObject)
TMainForm.FormClose
FormClose(Sender : TObject; var Action : TCloseAction)
TMainForm.FormDestroy
FormDestroy(Sender : TObject)
TMainForm.FileMenuClick
FileMenuClick(Sender : TObject)
Description The procedure FileMenuClick is an event handler activated by clicking once on the menu item
"File". The menu item "Save Recorded Data" is enabled when the memory contains data from a
measurement acquisition. Otherwise this menu item is disabled.
TMainForm.OpenPIClick
OpenPIClick(Sender : TObject)
TMainForm.SavePIClick
SavePIClick(Sender : TObject)
TMainForm.SavePIasClick
SavePIasClick(Sender : TObject)
Description The procedure SavePIasClick is an event handler activated by clicking once on the menu item
"File/Save PI Controller as...". A Windows system dialog appears to select a new file name
(extension *.PI) for storing (WritePIPar) the parameters of the PI controller contained in the
memory. An error message will appear, when the data could not be written successfully to this
file.
TMainForm.OpenFuzzyClick
OpenFuzzyClick(Sender : TObject)
TMainForm.LoadPlotData1Click
LoadPlotData1Click(Sender : TObject)
TMainForm.SavePlot1Click
SavePlot1Click(Sender : TObject)
Description The procedure SavePlot1Click is an event handler activated by clicking once on the menu item
"File/Save Recorded Data". A Windows system dialog appears allowing for the selection of a file
name of a so-called documentation file (extension *.PLD), to which measured data contained in
the memory are to be written (WritePlot). An error message will appear, when the data could not
be written successfully to the selected file.
TMainForm.Print1Click
Print1Click(Sender : TObject)
TMainForm.PrintSetup1Click
PrintSetup1Click(Sender : TObject)
TMainForm.ExitItemClick
ExitItemClick(Sender : TObject)
TMainForm.IOInterface1Click
IOInterface1Click(Sender : TObject)
Description The procedure IOInterface1Click is an event handler activated by clicking once on the menu
item "IO-Interface". The following three menu items to select an adapter card driver for the
DAC98, DIC24 or DAC6214 are enabled only, when the corresponding driver exists in the current
directory. The menu item to select the dialog for adjusting the adapter card address is enabled
only, when one of the above drivers is marked.
TMainForm.DAC98Click
DAC98Click(Sender : TObject)
Description The procedure DAC98Click is an event handler activated by clicking once on the menu item
"IO-Interface/DAC98". The name of the driver file DAC98.DRV is written to the file DR300.INI.
After stopping the timer (StopTimer) controlling the sampling period of the controller the driver
DAC98.DRV is selected for the DRSRV16.DLL (SelectDriver). Error messages will appear,
when stopping the timer or selecting the driver failed. The check marks of the corresponding menu
item are set accordingly and the dialog DACSetupClick to adjust the adapter card address is
called automatically.
TMainForm.DIC24Click
DIC24Click(Sender : TObject)
TMainForm.DAC6214Click
DAC6214Click(Sender : TObject)
TMainForm.DACSetupClick
DACSetupClick(Sender : TObject)
TMainForm.Edit1Click
Edit1Click(Sender : TObject)
TMainForm.PIControllerSetupClick
PIControllerSetupClick(Sender : TObject)
Description The procedure PIControllerSetupClick is an event handler activated by clicking once on the
menu item "Edit/PI Controller Setup". The modal dialog (PIParameterDlg) will appear to display
and adjust the parameters of the PI controller.
TMainForm.FuzzyControllerSetupClick
FuzzyControllerSetupClick(Sender : TObject)
Description The procedure FuzzyControllerSetupClick is an event handler activated by clicking once on the
menu item "Edit/Fuzzy Controller Setup". The modal dialog (FuzzyParameterDlg) will appear
to display and adjust all the parameters of the fuzzy controller.
TMainForm.useEncoder1Click
useEncoder1Click(Sender : TObject)
TMainForm.UseTacho1Click
UseTacho1Click(Sender : TObject)
TMainForm.Run1Click
Run1Click(Sender : TObject)
Description The procedure Run1Click is an event handler activated by clicking once on the menu item "Run".
At first all its sub menu items except for "Stop Controller" are enabled. As long as no controller
is selected the menu items to select the PI controller and the fuzzy controller remain enabled in
case of correct controller parameters and the menu item to stop a controller is disabled. In case
of parameter errors the corresponding menu item will be disabled. The menu item to stop a
controller will be enabled when one of the controllers is active.
TMainForm.PIController1Click
PIController1Click(Sender : TObject)
TMainForm.FuzzyController2Click
FuzzyController2Click(Sender : TObject)
TMainForm.OpenLoopControl1Click
OpenLoopControl1Click(Sender : TObject)
TMainForm.StopController1Click
StopController1Click(Sender : TObject)
TMainForm.StartMeasuring1Click
StartMeasuring1Click(Sender : TObject)
TMainForm.SetpointGenerator1Click
SetpointGenerator1Click(Sender : TObject)
Description The procedure SetpointGenerator1Click is an event handler activated by clicking once on the
menu item "Run/Setpoint Generator" or by pressing "F5". The conditions for the speed setpoint
or the control signal of the motor as well as the control signal of the generator are adjusted by
means of the following dialog GeneratorDlg.
TMainForm.View1Click
View1Click(Sender : TObject)
TMainForm.PlotMeasuredData1Click
PlotMeasuredData1Click(Sender : TObject)
TMainForm.PlotFileData1Click
PlotFileData1Click(Sender : TObject)
TMainForm.ParametersfromPLDFile1Click
ParametersfromPLDFile1Click(Sender : TObject)
TMainForm.Fuzzy3D1Click
Fuzzy3D1Click(Sender : TObject)
Description The procedure Fuzzy3D1Click is an event handler activated by clicking once on the menu item
"View/Fuzzy 3D". The following dialog Show3DFuzDlg will present a plot window containing
the 3-dimensional characteristic of a selectable fuzzy description file.
TMainForm.Timing1Click
Timing1Click(Sender : TObject)
TMainForm.Contents1Click
Contents1Click(Sender : TObject)
TMainForm.SearchforHelpon1Click
SearchforHelpon1Click(Sender : TObject)
TMainForm.HowtoUseHelp1Click
HowtoUseHelp1Click(Sender : TObject)
Description The procedure HowtoUseHelp1Click is activated by clicking once on the menu item "Help/How
to Use Help" to start the Windows dialog displaying hints how to use the help function.
TMainForm.About1Click
About1Click(Sender : TObject)
TMainForm.Timer1Timer
Timer1Timer(Sender : TObject)
TMainForm.PaintBox1Click
PaintBox1Click(Sender : TObject)
TMainForm.MeasLabelClick
MeasLabelClick(Sender : TObject)
TSingleInstance.WndProc
WndProc(var Msg : TMessage)
Parameters: var Msg is the current Windows system message received by this virtual window.
Description The procedure WndProc is a Windows message handler for the virtual window of type
SingleInstance, which determines by checking the parameters Msg, wParam and lParam if an
instance of this application was called already. In this case this application is terminated.
TAboutBox.FormShow
FormShow(Sender : TObject)
Description The procedure FormShow is called, when the object of type TAboutBox is displayed on the
screen. Short information about the program (name, version, copyright, required PC adapter card)
are presented in a window.
TShow3DFuzDlg.rescale
rescale
Description The procedure rescale calculates the scaling factors as well as initial values for the axes X, Y and
Z such that the value ranges of the 3 fuzzy variables may be displayed in a cube with an edge
length of 255.
TShow3DFuzDlg.recalc
recalc
Description The procedure recalc calculates the values of the fuzzy output variable for the complete value
ranges of the fuzzy input variables with respect to the currently selected step width and based on
the fuzzy object contained in the memory. The calculated vales are stored to the byte field dat.
TShow3DFuzDlg.calcrot
calcrot
Description The procedure calcrot calculates the values of the Euler rotation matrix depending on the rotation
angles a and b. The angle a defines the rotation around the X-axis while the angle b defines the
rotation around the Y-axis.
TShow3DFuzDlg.calctrans
calctrans( ix,iy,iz : double; var ox,oy,oz : double )
TShow3DFuzDlg.FormShow
FormShow(Sender : TObject)
TShow3DFuzDlg.FormHide
FormHide(Sender : TObject)
TShow3DFuzDlg.FuzzyCBoxChange
FuzzyCBoxChange(Sender : TObject)
TShow3DFuzDlg.DrawSquare
DrawSquare( can : TCanvas; j, i, z0, z1, z2, z3 : Integer )
Description The procedure DrawSquare draws the partial area defined by its edge points (zo, z1, z2, z3) taken
as base points with respect to the Z-axis and defined by the indexes (j, i) along the X- and Y-axis
as a polygon on the projection plane, which is identified by the device context can. The appearance
of the polygon depends on the setting of further checkboxes. The polygon gets a black coloured
frame, when "Grid" (GridCBox) is set, is displayed as a surface, when "Surface" (SurfaceCBox)
is set, the surface is drawn with a grey scale with decreasing darkness for increasing Z-values or
with a colour changing from red to blue, when "Colour" (ColorCBox) is set in addition.
TShow3DFuzDlg.DrawCoors
DrawCoors( can : TCanvas )
TShow3DFuzDlg.DrawCoors2
DrawCoors2( can : TCanvas )
TShow3DFuzDlg.DrawMark
DrawMark( can : TCanvas )
TShow3DFuzDlg.PaintBoxPaint
PaintBoxPaint(Sender : TObject)
TShow3DFuzDlg.ScrollBar1Change
ScrollBar1Change(Sender : TObject)
TShow3DFuzDlg.ScrollBar2Change
ScrollBar2Change(Sender : TObject)
Description The procedure ScrollBar2Change maps the current position of the scroll mark to an angle in the
range from 0 to 360, which is taken as a rotation angle around the Y-axis. If the absolute change
of the rotation angle is greater than 18, the characteristic is updated by means of PaintBoxPaint.
TShow3DFuzDlg.PaintBoxMouseDown
PaintBoxMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState;
X, Y: Integer);
TShow3DFuzDlg.PaintBoxMouseMove
PaintBoxMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
TShow3DFuzDlg.PaintBoxMouseUp
PaintBoxMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState;
X, Y: Integer);
TShow3DFuzDlg.KoorsCBoxClick
KoorsCBoxClick(Sender : TObject)
TShow3DFuzDlg.Koors2CBoxClick
Koors2CBoxClick(Sender : TObject)
TShow3DFuzDlg.ColorCBoxClick
ColorCBoxClick(Sender : TObject)
Description The procedure ColorCBoxClick is an event handler activated by clicking once on the checkbox
"Colour". The output of the characteristic is with grey or coloured partial areas according to the
new setting of the checkbox.
TShow3DFuzDlg.LowResCBoxClick
LowResCBoxClick(Sender : TObject)
Description The procedure LowResCBoxClick is an event handler activated by clicking once on the checkbox
"Low resolution". The updated output displays the characteristic with smaller (step width = 12)
or greater (step width = 25) partial areas according to the new setting of the checkbox.
TShow3DFuzDlg.PrintBBtnClick
PrintBBtnClick(Sender : TObject)
TShow3DFuzDlg.MarkCBoxClick
MarkCBoxClick(Sender : TObject)
TShow3DFuzDlg.Timer1Timer
Timer1Timer(Sender : TObject)
Description The procedure Timer1Timer is called by a timer every 200ms, as long as this timer is enabled.
The state of the timer is set equal to the setting of the checkbox "Mark". The output of the
characteristic is updated.
TShow3DFuzDlg.HelpBtnClick
HelpBtnClick(Sender : TObject)
Description The procedure HelpBtnClick is an event handler activated by clicking once on the "Help" button
in the "Show Fuzzy 3D" dialog. The corresponding section of the help file DR300.HLP will be
displayed in a window on the screen.
TFuzzyParameterDlg.Big
Big
Description The procedure Big expands the dialog by another edit field below the dialog and two additional
button. The content of the edit field is erased.
TFuzzyParameterDlg.Small
Small
Description The procedure Small removes the edit field and its accompanying two buttons from the lower
part of the dialog. The content of the edit field is erased. The name of the fuzzy description file
belonging to the edit field is reset to NONAME.FUZ.
TFuzzyParameterDlg.FormCreate
FormCreate(Sender : TObject)
TFuzzyParameterDlg.FormDestroy
FormDestroy(Sender : TObject)
TFuzzyParameterDlg.FormShow
FormShow(Sender : TObject)
TFuzzyParameterDlg.Sel1BBtnClick
Sel1BBtnClick(Sender : TObject)
TFuzzyParameterDlg.Ed1BBtnClick
Ed1BBtnClick(Sender : TObject)
Description The procedure Ed1BBtnClick is an event handler activated by clicking once on one of the "Edit"
buttons of the "Fuzzy Controller Parameters" dialog. The dialog will be expanded by an edit field
and two additional buttons ("Save", "Abort"). If the fuzzy description file with the name displayed
at the left side in the field of the activated "Edit" button exists its content is shown in the edit field
(variable Memo1). Typical edit functions are now allowed inside the edit field.
TFuzzyParameterDlg.CancelEdBBtnClick
CancelEdBBtnClick(Sender : TObject)
TFuzzyParameterDlg.SaveEdBBtnClick
SaveEdBBtnClick(Sender : TObject)
TFuzzyParameterDlg.OKBtnClick
OKBtnClick(Sender : TObject)
TFuzzyParameterDlg.HelpBtnClick
HelpBtnClick(Sender : TObject)
Description The procedure HelpBtnClick is an event handler activated by clicking once on the "Help" button
in the "Fuzzy Controller Parameters" dialog. The corresponding section of the help file
DR300.HLP will be displayed in a window on the screen.
TMeasureDlg.OKBtnClick
OKBtnClick(Sender : TObject)
Description The procedure OKBtnClick is an event handler for clicking once on the "Ok" button from the
dialog "Setup Measuring Function" to adjust the conditions for the measurement acquisition. The
contents of three input fields are converted to numbers for the total measuring time (time = 0 to
1000 sec), for the time before reaching the trigger condition (prestore = 0 to measuring time) and
for the trigger level (trigger = -3000 to 3000, or -10 to 10 in case of open loop control) only when
none of the numbers exceeds the valid range. Two further groups of radio buttons are used to
determine the trigger channel tchannel as well as the trigger condition slope. The trigger condition
is either not existing or defined as a slope, meaning that the measured value of the trigger channel
has to exceed the trigger level either in positive or in negative direction. The measuring is started
directly after terminating the dialog. Trigger values are the setpoint for the motor speed position,
the measured values for the speed and the current of motor/generator as well as the control signals.
TMeasureDlg.HelpBtnClick
HelpBtnClick(Sender : TObject)
TPIParameterDlg.FormShow
FormShow(Sender : TObject)
Description The procedure FormShow is called, when the object of type TPIParameterDlg is displayed on
the screen. The edit fields for the PI controller parameters are filled with the strings obtained from
converting the corresponding parameters of the structure param. An exception message will
appear, when the conversions failed.
TPIParameterDlg.OKBtnClick
OKBtnClick(Sender : TObject)
TPIParameterDlg.HelpBtnClick
HelpBtnClick(Sender : TObject)
TPLDInfoDlg.FormShow
FormShow(Sender : TObject)
TPLDInfoDlg.HelpBtnClick
HelpBtnClick(Sender : TObject)
Description The procedure HelpBtnClick is an event handler activated by clicking once on the "Help" button
in the "PLD Information" dialog. The corresponding section of the help file DR300.HLP will be
displayed in a window on the screen.
TPlotDlg.OKBtnClick
OKBtnClick(Sender : TObject)
Description The procedure OKBtnClick is an event handler for clicking once on the "Ok" button from the
dialog "Select Plot Data" to select the channels of a measuring which are to be represented in a
plot window. The selectable channels are the measured value and setpoint of the motor speed, the
measured speed and current of motor/current as well as the control signals for the two devices.
The selected channel is presented in a graphic on the screen by calling PlotMeas.
TPlotDlg.HelpBtnClick
HelpBtnClick(Sender : TObject)
Description The procedure HelpBtnClick is an event handler activated by clicking once on the "Help" button
in the dialog "Select Plot Data" to select the channels of a measuring which are to be represented
in a plot window. The corresponding section of the help file DR300.HLP will be displayed in a
window on the screen.
TPrintPlotDlg.PrinterBitBtnClick
PrinterBitBtnClick(Sender : TObject)
TPrintPlotDlg.OKBtnClick
OKBtnClick(Sender : TObject)
Description The procedure OKBtnClick is an event handler for clicking once on the "Ok" button from the
dialog to select previously created plot windows. All of the plot windows selected from the list
box are printed directly to the current output device (by means of the function PrintPlotMeas).
When multiple plot windows are selected an offset of 150 mm (counted from the upper margin
of a DIN A4 page) is added before every second print output and a form feed follows this output.
TPrintPlotDlg.FormShow
FormShow(Sender : TObject)
TPrintPlotDlg.HelpBtnClick
HelpBtnClick(Sender : TObject)
TGeneratorDlg.OKBtnClick
OKBtnClick(Sender : TObject)
TGeneratorDlg.FormShow
FormShow(Sender : TObject)
Description The procedure FormShow is called, when the object of type TGeneratorDlg is displayed on the
screen. The input fields as well as the radio buttons to adjust the generators for the motor speed
setpoint (or control signal in the open loop case) as well as the control signal for the generator are
preset according to the parameters of the global parameter structure param.
TGeneratorDlg.HelpBtnClick
HelpBtnClick(Sender : TObject)
TTimingForm.UpdateData
UpdateData
Description The procedure UpdateData is called periodically with the update rate of the main window (timer
in TMainForm). The structure tim (type ServiceTiming) is read (GetTiming) from
DRSRV16.DLL. Its elements number of sampling periods as well as the minimum and maximum
values of the real sampling period are displayed in the "DR300 Timing" dialog. The graphic with
the statistic values of the sampling periods is updated in addition.
TTimingForm.HideButtonClick
HideButtonClick(Sender : TObject)
TTimingForm.HelpButtonClick
HelpButtonClick(Sender : TObject)
TTimingForm.PaintBox1Paint
PaintBox1Paint(Sender : TObject)
TTimingForm.PaintBox2Paint
PaintBox2Paint(Sender : TObject)
TTimingForm.ResetBtnClick
ResetBtnClick(Sender : TObject)
Description The procedure ResetBtnClick is an event handler activated by clicking once on the "Reset" button
in the "DR300 Timing" dialog. The number of sampling periods in the structure tim is reset to -1
which in advance will reset the minimum and maximum as well as the statistic values by calling
UpdateData and with this calling GetTiming.
FloatToStr2
FloatToStr2( f : Single ) : string
FloatToStr3
FloatToStr3( f : Single ) : string
FloatToStr4
FloatToStr4( f : Single ) : string
FloatToStr5
FloatToStr5( f : Single ) : string
Description The function FloatToStr5 converts a floating point value (4 bytes for single) to its string
representation with a maximum of 7 significant digits and 5 digits behind the decimal point.
Return Is the string representation of the floating point value.
StrToFloatMinMax
StrToFloatMinMax( s : string; min,max : double ) : double
StrToFloatStrMinMax
StrToFloatStrMinMax( s : string; var val : double; min,max : double ) : string
MinMaxi
MinMaxi( val, min, max : Integer ) : Integer
DetectNT
DetectNT : Boolean
Description The function DetectNT returns TRUE, when the file NTOSKRNL exists in the Windows system
directory, otherwise it returns FALSE. An error message is presented if the Windows system
directory does not exist. It is assumed that the existence of the file means an operating NT system
and a 16 bit application will not run with a NT system.
Return Returns TRUE, when NTOSKRNL.EXE exists, else FALSE.
Global Data:
typedef struct{
WORD controller; // controller type (PI, fuzzy controller, open loop, none)
WORD encoder; // type of active speed sensor (encoder or tacho)
double kr; // proportional coefficient of PI controller
double tr; // integral coefficient of PI controller
char name[80]; // name of active fuzzy description file
WORD spshape; // shape of signal for motor (setpoint/control signal)
double spoffset; // offset of signal for motor (setpoint/control signal)
double spamplitude; // amplitude of signal for motor (setpoint/control signal)
double spperiod; // period of signal for motor (setpoint/control signal)
WORD splshape; // shape of control signal for generator (load)
double sploffset; // offset of control signal for generator (load)
double splamplitude; // amplitude of control signal for generator (load)
double splperiod; // period of control signal for generator (load)
WORD PIError; // error flag of PI controller
WORD fuzzyError; // error flag of fuzzy controller
}ServiceParameter ;
typedef struct{
double sdrive; // speed setpoint or control signal (open loop) for motor
double sload; // control signal for generator
double aspeed; // measured value of motor speed from tacho (analog)
double ispeed; // measured value of motor speed from encoder (incremental)
double curdrive; // measured value of motor current
double curload; // measured value of generator current
double odrive; // control signal for motor
double oload; // control signal for generator
double acc; // calculated acceleration of motor (for fuzzy controller)
WORD state; // state of controller (changed or stopped)
}ServiceData;
typedef struct{
longint n; // number of sampling periods
double min; // minimum value of sampling periods
double max; // maximum value of sampling periods
double v[20]; // array of statistic values of sampling periods
}ServiceTiming;
struct Fuzzy3DInfo{
long size; // current size of this structure
int idx; // index for the first input variable
LibMain
int CALLBACK LibMain( HINSTANCE hInstance, WORD wDatenSeg, WORD
cbHeapSize, LPSTR lpCmdLine )
Description The function LibMain is the entry function of the 16 bit DRSRV16.DLL. None of the parameters
is used directly. New objects for the driver, the scope buffer, the signal generators and the
controllers are created and assigned to the corresponding global pointers. The elements of the
global structure param for the controllers as well as for the generator are initialized.
Return Is TRUE in case of successful initialization, else FALSE.
WEP
int CALLBACK WEP( int nParameter )
Description The function WEP is the exit function of the 16 bit DRSRV16.DLL. None of the parameters is
used directly. When the code and data memory of the complete DRSRV16.DLL is locked, it will
be unlocked. The objects for the driver, the scope buffer, the signal generators and the controllers
are deleted.
Return Is TRUE in case of successful operations, else FALSE.
LockMemory
BOOL CALLBACK LockMemory( BOOL bStart, HDRVR hDrv )
SetDriverHandle
BOOL CALLBACK SetDriverHandle( HDRVR hDrv )
DoService
BOOL CALLBACK DoService( DWORD counter )
Description The function DoService is the service routine called with periodic timer events (see also
TIMER16.DLL). Timer events occur with a (nearly) constant sampling period as long as they are
enabled. The following operations are carried-out in sequence:
SetParameter
BOOL CALLBACK SetParameter( WORD wSize, LPSTR lpData )
Parameters wSize is the size (in bytes) of the data structure pointed to by lpData.
lpData is a pointer to a data structure of type ServiceParameter.
Description The function SetParameter copies the data structure pointed to by lpData to the global structure
par (type ServiceParameter ) only when the size of the source structure is less than or equal to the
size of the destination structure. In this case the parameters of the PI controller as well as the signal
generators are set accordingly. The flag locked is set during this operation.
Return Is equal to TRUE when the size of the source structure is less than or equal to the size of the
destination structure, else return is equal to FALSE.
GetParameter
BOOL CALLBACK GetParameter( WORD wSize, LPSTR lpData )
Parameters wSize is the size (in bytes) of the data structure pointed to by lpData.
lpData is a pointer to a data structure of type ServiceParameter.
Description The function GetParameter at first copies the current parameters of the PI controller as well as
the name of the fuzzy description file to the global structure par (type ServiceParameter) then it
copies this structure to the destination structure pointed to by lpData. The last copy procedure is
carried-out only, when the size of the source structure par is equal to the size of the destination
structure. The flag locked is set during this operation.
Return Is equal to TRUE when the size of the source structure is less than or equal to the size of the
destination structure, else return is equal to FALSE.
GetData
BOOL CALLBACK GetData( WORD wSize, LPSTR lpData )
Parameters wSize is the size (in bytes) of the data structure pointed to by lpData.
lpData is a pointer to a data structure of type ServiceData.
Description The function GetData at first copies the content of the measurement-vector scopebuf to the global
structure dat (type ServiceData). Then dat is copied to the data structure pointed to by lpData
only when the size of the source structure is less than or equal to the size of the destination
structure. Bit 1 and 2 of the controller state are set according to the settings of stopped and changed.
The flag locked is set during this operation.
Return Is equal to TRUE when the size of the source structure is less than or equal to the size of the
destination structure, else return is equal to FALSE.
GetTiming
BOOL CALLBACK GetTiming( WORD wSize, LPSTR lpData )
Parameters wSize is the size (in bytes) of the data structure pointed to by lpData.
lpData is a pointer to a data structure of type ServiceTiming.
Description The function GetTiming copies the global structure tim (type ServiceTiming) to the data structure
pointed to by lpData only when the size of the source structure is less than or equal to the size of
the destination structure. When on entry the element tim.n, the number of sampling periods, is set
to -1, the complete structure is reset to default values before the copy operation is carried-out.
The flag locked is set during the run-time of this function.
Return Is equal to TRUE when the size of the source structure is less than or equal to the size of the
destination structure, else return is equal to FALSE.
ReadFuzzy
BOOL CALLBACK ReadFuzzy( void )
Description The function ReadFuzzy reads the fuzzy description file and generates the accompanying fuzzy
object. The name of the fuzzy description file is read from the global parameter structure par. The
current controller type in par is set equal to FUZZYCONTROLLER only, when a fuzzy controller
was active previously and the new fuzzy object generation was error-free. In case of a previously
active fuzzy controller but errors occurred during the fuzzy object generation the controller type
is set equal to NOCONTROLLER. In any other case the controller type remains as it has been
before this function was called.
Return Is equal to TRUE when the new fuzzy object generation was successful, else FALSE is returned.
ReadPIPar
BOOL CALLBACK ReadPIPar( char* name )
Parameters name is a pointer to the name of a file from which the parameters of a PI controller are to be
read.
Description The function ReadPIPar reads the parameters of a PI controller from the file with the given name
name. The current controller type in par is set equal to PICONTROLLER only, when a PI
controller was active previously and the loading procedure was successful. In case of a previously
active PI controller but errors occurred during loading the parameters the controller type is set
equal to NOCONTROLLER. In any other case the controller type remains as it has been before
this function was called.
Return Is equal to TRUE, when reloading the parameters of the PI controller was successful, else FALSE
is returned.
WritePIPar
BOOL CALLBACK WritePIPar( char* name )
Parameters name is a pointer to the name of a file to which the parameters of a PI controller are to be
written.
Description The function WritePIPar writes the parameters of the PI controller to a file with the given name
name. The current controller type in par is set equal to PICONTROLLER only, when a PI
controller was active previously and the writing procedure was successful. In case of a previously
active PI controller but errors occurred during writing the matrices the controller type is set equal
to NOCONTROLLER. In any other case the controller type remains as it has been before this
function was called.
Return Is equal to TRUE, when writing the parameters of the PI controller was successful, else FALSE
is returned.
IsDemo
int CALLBACK IsDemo( void )
Description The function IsDemo returns a 1 only when the DRSRV16.DLL is a DEMO version (generated
with the macro __SIMULATION__ , instead of the IO-adapter card a mathematical model is
accessed). Otherwise the function returns 0.
Return Is equal to 1 in case of a DEMO version, else equal to 0.
MeasureStart
int CALLBACK MeasureStart( double time, double trigger, double prestore, int tchannel, int
slope )
The functions
MeasureLevel
double CALLBACK MeasureLevel( void )
MeasureStatus
int CALLBACK MeasureStatus( void )
Description call directly the corresponding functions scope.GetBufferLevel, scope.GetStatus of the class
STOREBUF.
OpenFuzzy3D
int CALLBACK OpenFuzzy3D( char* filename )
CloseFuzzy3D
int CALLBACK CloseFuzzy3D( void )
Description The function CloseFuzzy3D removes an existing fuzzy object (fuzzy3d serving for the output of
its 3-dimensional characteristic) from the memory and resets its pointer to NULL.
Return Always 0.
InfoFuzzy3D
Fuzzy3DInfo* CALLBACK InfoFuzzy3D( void )
Description The function InfoFuzzy3D returns the structure of type Fuzzy3DInfo belonging to an existing
fuzzy object (fuzzy3d serving for the output of its 3-dimensional characteristic).
CalcFuzzy3D
double CALLBACK CalcFuzzy3D( double x, double y )
Return Output variable of an existing fuzzy object with two given values for its input variables or 0.0.
The class DR300STA provides functions to calculate the PI controller and to handle its parameters. It inherits from
the basic class CONTROLLER.
Public Data:
double time sampling period (class CONTROLLER)
Private Data:
DR300STA::DR300STA()
void DR300STA ( void ) : CONTROLLER( )
Description The constructor of the class DR300STA initializes values for the internal error, the sampling
period, the parameters of the PI controller as well as for the controller identification string. The
name of the current parameter file is set to DR300.PI. When this file could be read successfully
the parameters of the PI controller are set accordingly. The flag for resetting the controller is set.
DR300STA::Calc
void Calc( void )
Description The function Calc is the main function of this class. It carries-out the calculation of the PI
controller. The speed setpoint as well as the measured speed are read from the global scope buffer
scopebuf. Where the last operation depends on the type of the active speed sensor. The measured
speed is then limited to the range +/-3000 rpm. With reset flag start set, the PI controller output
signal as well as the measured speed from the previous sampling period are reset to zero. Then
the output of a sampled-data controller (approximated digital PI controller with respect to the
coefficients of an analog PI controller) is calculated. This output will be limited to the range
+/-1000 and stored as the control signal to the measurement-vector.
DR300STA::Reset
void Reset( void )
Description The function Reset sets the flag start to reset the initial values of the PI controller.
DR300STA::Load
int Load( char* name )
Parameters name is a pointer to the name of a file from which the parameters of the PI controller are to be
read.
Description The function Load copies the given name to filename and tries to open the corresponding file.
When the file cannot be opened, an error message is presented, the internal error errors is set to
1 and the function returns ERROR (-1) immediately. Otherwise all the parameters are read from
the file and stored in the corresponding parameters of the PI controller. The file must match a
predefined format and the sequence of the parameters separated by comment lines with a closing
"]" character. The internal error errors is reset to 0.
Return A value of 0 with a successful read operation from the file, else -1.
DR300STA::Save
int Save( char* name )
Parameters name is a pointer to the name of a file to which the parameters of the PI controller are to be
written.
Description The function Save copies the given name to filename and tries to open the corresponding file.
When the file cannot be opened, an error message is presented, the internal error errors is set to
1 and the function returns ERROR (-1) immediately. Otherwise all the parameters (sampling
period, proportional and integral coefficient) of the PI controller are written to the file with
additional comment lines. The internal error errors is reset to 0.
Return A value of 0 with a successful write operation to the file, else -1.
DR300STA::GetKr
double* GetKr( void )
Description The function GetKr returns a pointer to the proportional coefficient of the PI controller kr.
Return A pointer to proportional coefficient of the PI controller kr.
DR300STA::GetTr
double* GetTr( void )
Description The function GetTr returns a pointer to the integral coefficient of the PI controller tr.
Return A pointer to proportional coefficient of the PI controller tr.
DR300STA::GetFileName
char* GetFileName( void )
Description The inherited element function GetFileName returns a pointer to the current parameter file name.
DR300STA::GetId
char* GetId( void )
Description The inherited element function GetId returns a pointer to the current controller identification
string.
Return The a pointer to the current controller identification string id.
DR300STA::geterrors
int geterrors( void )
Description The inherited element function geterrors returns the value of the internal error errors. This
variable is set during file accesses (see also Load, Save).
Return The value of the internal error errors.
DR300STA::SetTa
void SetTa( float ta )
The class DR300FUZ provides functions to apply a fuzzy controller. It serves as an interface to the fuzzy
algorithms contained in Fuzzy.lib. It inherits from the basic class CONTROLLER.
Public Data:
double time sampling period (class CONTROLLER)
double acc acceleration of the motor.
Private Data:
DR300FUZ::DR300FUZ()
void DR300FUZ ( void ) : CONTROLLER
Description The constructor of the class DR300FUZ sets the internal sampling period to SIMTIME and
initializes the identification string to "FUZZYCONTROLLER". It assigns NULL to the pointer
to the fuzzy object, reads the "fuzzy-controller" file DR300.FUZ (see also Load) and generates
the accompanying fuzzy object. The controller reset flag start is set in addition.
DR300FUZ::~DR300FUZ()
void ~DR300FUZ ( void )
Description The destructor of the class DR300FUZ removes the fuzzy object from the memory.
DR300FUZ::Calc
void Calc( void )
Description The function Calc is the main function of this class to calculate the fuzzy controller. The speed
setpoint as well as the measured speed are read from the global scope buffer scopebuf. Where the
last operation depends on the type of the active speed sensor. The measured speed is then limited
to the range +/-3000 rpm. With reset flag start set, the fuzzy controller output signal as well as
the control error from the previous sampling period are reset to zero. The approximation of the
acceleration of the control error is then taken as a backward difference approximation. The fuzzy
controller with the two input signals control error and its approximated derivative is calculated
only, when the fuzzy object could be generated without any error. The control signal is calculated
by integrating (rectangle approximation) the fuzzy controller output and limiting the result to the
range +/-1000. At the end the control signal is stored to the measurement-vector.
DR300FUZ::Reset
void Reset( void )
Description The function Reset sets the flag start to reset the fuzzy controller output signal as well as the
control error from the previous sampling period.
DR300FUZ::Load
int Load( char* name )
DR300FUZ::Save
int Save( char* name )
DR300FUZ::getname
char* getname( void )
Description The function getname returns the name of the current "fuzzy-controller" file, meaning the content
of filename.
Return A pointer to the name of the current "fuzzy-controller" file from filename.
DR300FUZ::GetFileName
char* GetFileName( void )
Description The inherited element function GetFileName returns a pointer to the current parameter file name.
Return The a pointer to the current parameter file name filename.
DR300FUZ::GetId
char* GetId( void )
Description The inherited element function GetId returns a pointer to the current controller identification
string.
Return The a pointer to the current controller identification string id.
DR300FUZ::geterrors
int geterrors( void )
Description The inherited element function geterrors returns the value of the internal error errors. This
variable is set during file accesses (see also Load, Save).
DR300FUZ::SetTa
void SetTa( float ta )
The instance of the class STOREBUF realizes the function of data buffering. The data buffer created dynamically
looks like a matrix with a maximum of assignable rows, where each row contains an adjustable number of
components (i.e. float values from measurements). The storage in the data buffer is performed row by row, where
each row is represented by a data vector, which was filled by another routine from an upper level. In this case it is
the interrupt service routine which fills the data vector, i.e. with the setpoint value, measurements and control
signals, in every sampling period. An element function (StartMeasure) of STOREBUF starts and controls the
storage (WriteValue) of this data vector in the data buffer. With respect to the measuring time at first those
sampling periods are determined in which storage is to be performed (number of store operations * sampling
periods = measuring time). Where the number of store operations is calculated at first such that it is always less than
the maximum number of measurement vectors (= number of rows of the memory matrix). At the end of the
measuring time the store operation is terminated in case no additional trigger conditions are set. In case of an
activated trigger condition, a signal crosses a given value with a selected direction, the store operation is continued
until the end of the measuring time after the trigger condition was met. In case the signal does not meet the trigger
condition, the store operation is performed endless in a ring until the user interactively terminates this operation. In
addition a time before the trigger condition (prestore time) is adjustable in which storage in the data buffer is
performed. The time after the trigger condition is met is then the measuring time reduced by the prestore time. The
mentioned data vector will be named measurement-vector in the following.
Private Data:
float *fptr is a pointer to the start address of the dynamic data buffer.
float *sourceptr is a pointer to the measurement-vector.
float *inptr is a pointer to the actual data buffer location.
int aktiv flag for status of the dynamic data buffer.
int status flag for storage control.
STOREBUF::ResetBufIndex
void ResetBufIndex( void )
Description The private element function ResetBufIndex sets bufindex to 0 and inptr equal to fptr meaning
that the start conditions for the data buffer are set.
STOREBUF::STOREBUF
STOREBUF( int nchannel, float *indata, int maxvectors )
Parameters int nchannel is the number of float values of the external measurement-vector.
float *indata is the pointer to the start address of the measurement-vector.
int maxvectors is the maximum number of measurement-vectors.
Description The constructor of this class initializes flags (gomessung, startmessung, aktiv = FALSE) to control
the storage as well as a pointer to the measurement vector (sourceptr = indata. The maximum
number of the measurement-vectors is set ( MaxVectors = maxvectors ) where the minimum value
is limited to 1.
STOREBUF::~STOREBUF()
void ~STOREBUF( void )
Description The destructor of this class frees the dynamically allocated memory fptr in case it was created.
STOREBUF::StartMeasure
void StartMeasure( float meastime, float triggervalue, float prestoretime, int triggerdir,
float taint )
STOREBUF::WriteValue
void WriteValue( void )
Description The function WriteValue stores nchannel float values from the array indata
(measurement-vector) to the current address of the dynamically allocated array.
STOREBUF::SetOutChan
void SetOutChan(int in)
Parameters int in references the component of the measurement vector which is to be read (output).
Description The inline function SetOutChannel sets the channel number (index in the measurement-vector)
of the signal which is to be returned by the function ReadValue.
STOREBUF::ReadValue
float ReadValue( void )
Description The function ReadValue returns the value of the next storage location belonging to the channel
selected by SetOutChannel.
Return Value (float) read from measurement-vector.
STOREBUF::GetBufLen
int GetBufLen( void )
Description The function GetBufLen interrupts a current storage operation and returns the number of stored
measurement-vectors.
STOREBUF::GetBufTa
float GetBufTa( void )
Description The inline function GetBufTa returns the time between storage, which was calculated with
respect to the measuring time and the sampling period.
Return Time (float) between storage depending on measuring time and sampling period.
STOREBUF::GetStatus
int GetStatus( void )
Description The function GetStatus returns the status of the store operation.
STOREBUF::GetBufferLevel
double GetBufferLevel( void )
Description The function GetBufferLevel returns the percentage of the former measurement time with respect
to the given trigger condition (= filling ratio or level of the data buffer). The return value will stay
at 0% until the valid trigger condition is reached even when prestoretime is unequal to zero. That
means the return value will start with an initial value of prestoretime / meastime in % at the time
of a valid trigger condition.
Return The percentage of the filling ratio (double) of the data buffer.
An instance of the class AFBUF is an object that creates dynamically a data array for an assignable number of float
values. Data can be stored in this array and can be read afterwards when the data array is filled completely. The
array is handled like a ring buffer.
Private data:
float *fptr is the pointer to the start of the dynamically created data array.
float *inptr is the pointer to the current storage location ready to store a value (input).
float *outptr is the pointer to the current storage location ready to read a value (output).
int aktiv flag: dynamic memory is initialized.
int filled flag: data array is filled.
int abuflen is the number of float values in the data array.
int inbufindex is the index of the current input position.
int outbufindex is the index for the current output position.
AFBUF::AFBUF()
void AFBUF( void )
Description The constructor of this class resets the flag aktiv, which indicates a dynamically created data array.
AFBUF::~AFBUF()
void ~AFBUF( void )
Description The destructor of this class frees the initialized data memory in case it was created dynamically.
AFBUF::NewFBuf
int NewFBuf( int anzahl )
AFBUF::ReadFBuf
float ReadFBuf( void )
Description The function ReadFBuf returns the float value of the next storage location of the dynamically
created data array in case this array was filled previously.
Return Value (float) from data array.
AFBUF::WriteFBuf
int WriteFBuf( float fvalue )
The class TWOBUFFER handles two instances of the class AFBUF. One instance (write-instance) can be used to
store data while the other is used to read out data (read-instance). In case the data array of the write-instance is filled
it is handled as a read-instance in the following. This condition guarantees that the interrupt service routine has
always access to valid data.
Private objects:
Private data:
TWOBUFFER::TWOBUFFER()
void TWOBUFFER( void )
Description The constructor of this class initializes flags and counters as follows:
readbuffer = FALSE, buffer cannot be read,
buf1len = 1, length of the buffer Buf1,
buf2len = 1, length of the buffer Buf2,
buffer1 = 1, buffer Buf1 for read operation,
buffer2 = 0, buffer Buf2 for write operation,
newbuffer = 0, no buffer for read or write operation available.
TWOBUFFER::New2Buffer
void New2Buffer( int anzahl , int repeatwert, int repeatbuf )
Parameters int anzahl is the number of float values of the new array.
int repeatwert defines how often a value is to be repeated during a read operation by
Read2Buffer.
int repeatbuf defines how often the array is to be sent to the output.
Description The function New2Buffer creates data arrays dynamically with anzahl float values. With buffer1
= 0 Buf1 is created and with buffer2 = 0 Buf2 is created.
TWOBUFFER::Write2Buffer
int Write2Buffer( float wert )
Description The function Write2Buffer writes the argument value to the data array. In case the end of the
array is reached, the array is used as a source for the function Read2Buffer.
Return Total number (int) of stored (written) values.
TWOBUFFER::Read2Buffer
float Read2Buffer( void )
Description The function Read2Buffer returns the values of the read-array handling like a ring. In case the
argument repeatbuf of the function New2Buffer was equal to x, the array is read x times. After x
read operations zero is returned. In case repeatbuf is equal to 0, the read operation is cyclic.
Return Value (float), which is read from the array.
An instance of the class SIGNAL is an object to create a data array, which represents a given signal shape in case it
is read out with constant time intervals. To do this an instance of the class TWOBUFFER is used. Adjustable
signal shapes are rectangle, triangle, sawtooth and sine. In addition the amplitude, an offset and the time period is
adjustable.
Private Data:
Private objects:
SIGNAL::SIGNAL( )
void SIGNAL( void )
Description The constructor of this class initializes the variables abtastzeit, minrange and maxrange.
SIGNAL::InitTime
float InitTime( float settime )
Parameters float settime is the sampling period of the read routine (in sec.)
Description The function InitTime sets the sampling time, which is used to read out the values from the
interrupt routine, equal to the given controller sampling period.
Return Adjusted sampling period (float) in seconds.
SIGNAL::MakeSignal
int MakeSignal( int form, float offset, float ampl ,float periode , int repeatbuf)
SIGNAL::ReadNextValue
float ReadNextValue( void )
Description The function ReadNextValue reads the data from the assigned array. The value is internally
limited to the range minrange to maxrange. It is called by the interrupt service routine. Due to
the locking mechanism in TWOBUFFER, new signal shapes can be created even in case the
active interrupt outputs another one.
Return Value (float) read from the data array.
SIGNAL::SetRange
void SetRange( float min, float max )
Parameters float min is the minimum return value of the function ReadNextValue.
float max is the maximum return value of the function ReadNextValue.
Description The function SetRange adjusts the range of the base points forming the signal, i.e. the minimum
and maximum values returned by the function ReadNextValue.
SIGNAL::WriteBuffer
void WriteBuffer( float value )
SIGNAL::Stuetzstellen
int Stuetzstellen( float Periodenzeit, int form)
Included in the DRSRV16.DLL, the functions of the file PLOT.CPP provide the interfaces for graphic output of
measured data and for displaying information about the contents of documentation files (*.PLD).
Global Data:
ReadPlot
int CALLBACK ReadPlot( char *lpfName )
Parameters *lpfName is a pointer to the name of a documentation file, from which measurements are to be
read.
Description The function ReadPlot reads the structures project, ctrlstatus and datastruct as well as the
measurements from the documentation file with the given name lpfName and stores the
measurements to a new global data array pointed to by **ppData. Up to 59 characters of the file
name lpfName are copied to the global file name FileName.
Return The state of the file access:
=0, measurements read successfully,
=-1, file with the given name could not be opened,
=-2, the PROJECT structure from the file contains a wrong project number.
WritePlot
int CALLBACK WritePlot( char *lpfName )
Parameters *lpfName is a pointer to the name of a documentation file, to which measurements are to be
written.
Description The function WritePlot writes the global structures project, measctrlstatus, the local structure
DATASTRUCT mydatastruct as well as the content of the global measurement buffer scope to
a documentation file with the given name lpfName. The local structure mydatastruct contains the
number of measurement-vectors, the number of its components as well as the sampling period of
a measuring.
Return The state of the file access:
=0, measurements written successfully,
=-1, file with the given name could not be created.
Plot
int CALLBACK Plot( int command, int channel )
Description The function Plot represents the curves specified by channel with accompanying descriptions in
a graphic inside a plot window. The data sources are the global measurement buffer scope or the
global array **ppData depending on the parameter command.
Return The state of the graphic output:
=0, successful graphic output of measured curves,
=-1, invalid values for command,
=-2, invalid values for channel,
=-3, length of the global array **ppData is 0,
=-4, length of the global measurement buffer scope is 0.
See also CreateSimplePlotWindow, SetCurveMode, AddAxisPlotWindow, AddXData,
AddPlotTitle, ShowPlotWindow.
GetPlot
int CALLBACK GetPlot( int start, char *lpzName )
PrintPlot
int CALLBACK PrintPlot( int idx, HDC dcPrint, int iyOffset )
Parameters idx is the index for the global list of handles referencing existing plot windows.
dcPrint is the device context of the output device.
iyOffset is the beginning of the printout in vertical direction as a distance in [mm] from the
upper margin of a page.
Description The function PrintPlot prints the content of the plot window with the Windows handle from the
global list handlelist[idx] to the device with the device context dcPrint. The printout has a width
of 180 mm and a height of 140 mm. It is located at the left margin with a distance of iyOffset mm
from the upper margin of a (i.e. DIN A4) page.
Return Is always equal to 0.
See also PrintPlotWindow.
GetPldInfo
int CALLBACK GetPldInfo( int &controller, char **s, int &n, int &c, double &d )
Parameters &controller is a reference to the controller structure (PI controller, fuzzy controller, none).
**s is a (double) pointer to the string containing date and time of the measuring.
&n is a reference to the number of samples of each measured signal (curve).
&c is a reference to the number of measured signals.
&d is a reference to the sampling period of the measuring.
Description The function GetPldInfo reads selected elements of the structures ctrlstatus as well as datastruct
and stores these elements to the mentioned parameter references. It is assumed that the structures
were filled previously with data from a loaded documentation file (*.PLD).
Return Is the result:
=0, the structure elements have been copied,
=-1, the global data array **ppData does not exist, length = 0.
See also ReadPlot.
The class DICDRV provides the interface between the DR300W16 controller program and the driver functions of
the PC plug-in card. The class WDAC98 containing the driver functions is the basic class of DICDRV. In addition
this class contains the mathematical model of the speed control system when it is compiled with ’#define
__SIMULATION__’ (see file DRDEFINE.H). With this all program functions except for the calibration can be
carried-out for a simulated plant of the speed control system. The PC plug-in card is no longer required in this case.
This program version will be called ’DEMO-Version’ in the following.
Basic Class:
The files DICDRV.H, DICDRV.CPP contain the class DICDRV with the functions:
DICDRV( void )
~DICDRV(){}
double ReadASpeed( void )
Public Data:
DICDRV::DICDRV
DICDRV( void )
Description The constructor of the class DICDRV initializes an object of the class WDAC98 and sets an
initial value for the timer device of the PC adapter card. The two analog outputs are reset to 0.
With the DEMO-version initial values are set for the motor speed and the two control signals of
the mathematical model.
DICDRV::~DICDRV
~DICDRV( void )
Description The destructor of the class DICDRV resets the real control signal to 0.
DICDRV::ReadASpeed
double ReadASpeed( void )
Description The function ReadASpeed reads the analog input connected to the tacho, converts this value to
[rpm] and stores the result to Speed. The same variable is returned.
With the DEMO-version the motor speed Speed calculated by the mathematical model is returned.
Return The speed of the motor measured by the tacho in [rpm].
DICDRV::ReadISpeed
double ReadISpeed( void )
Description The function ReadISpeed determines the real duration of the previous sampling period (lastdt
from ReadTime) and reads the incremental encoder signal to measure the speed of the motor.
The increments are limited to a range of +/-2047. Then the increments are used to calculate the
motor speed with respect to the real duration of the previous sampling period. The result is stored
in Speed and returned.
With the DEMO-version the motor speed Speed calculated by the mathematical model is returned.
Return The speed of the motor measured by the encoder in [rpm].
DICDRV::ReadTime
double ReadTime( void )
Description The function ReadTime determines the real duration of the previous sampling period by reading
the timer of the PC adapter card. The real duration in [sec] is calculated by scaling the difference
between the current timer reading and the timer reading from the previous call. In addition the
result is converted to [msec] and used to determine the minimum or maximum value of the
previous sampling periods since the first call of this function. The last values are stored to the
global structure tim of type ServiceTiming. Its number of sampling periods is incremented and
the nearest integer to the duration value is used as an index to increment the corresponding array
element as long as this index is positive and less than 20. The elements of the global structure tim
are initialized only for the first call of this function.
With the DEMO-version the nominal sampling period is returned.
Return The real duration of the previous sampling period in [sec].
DICDRV::ReadDriveCurrent
double ReadDriveCurrent( void )
Description The function ReadDriveCurrent reads the analog input connected to the current monitor of the
motor, converts this value to [A] and stores the result to DriveCurrent. The same variable is
returned.
With the DEMO-version the motor current DriveCurrent calculated by the mathematical model
is returned.
Return The current of the motor in [A].
DICDRV::ReadLoadCurrent
double ReadLoadCurrent( void )
Description The function ReadLoadCurrent reads the analog input connected to the current monitor of the
generator, converts this value to [A] and stores the result to LoadCurrent. The same variable is
returned.
With the DEMO-version the generator current LoadCurrent calculated by the mathematical
model is returned.
Return The current of the generator in [A].
DICDRV::SetControlSignals
void SetControlSignals( double DriveControl, double LoadControl )
DICDRV::CheckSystem
int CheckSystem( void )
Description The function CheckSystem checks if the two system identification signals are equal to the mask
for a speed control system. When this condition is reached at least five times in ten successive
readings the return value is 1, else it is 0 (system lead not connected or defect?, wrong
lead/system).
Return A value of 1 for a positive system check, else 0.
DICDRV::CheckFree
int CheckFree( void )
Description The function CheckFree returns a value of 1, when the control by the PC (PCREADY) is enabled
at least five times in ten successive readings, else it returns 0.
DICDRV::TopSwitch
int TopSwitch( void )
Description The function TopSwitch is a dummy function reserved for future use.
Return Always 0.
DICDRV::StartInterrupt
void StartInterrupt( void )
Description The function StartInterrupt activates the output stage release by sending a trigger pulse and
starting a rectangle signal. Any interrupt is left unchanged.
DICDRV::TriggerEndstufe
void TriggerEndstufe( void )
Description The function TriggerEndstufe toggles the level of the rectangle signal for the output stage release.
DICDRV::CalcModel
void CalcModel( int reset )
DICDRV::WinDelay
void WinDelay( int ms )
The class WDAC98 realizes the interface between the class DICDRV and the driver functions (DIC24.DRV,
DAC98.DRV) of the PC adapter card. Calling the DRV-functions is carried-out by "SendMessage"-functions using
commands and parameters as described with the driver software (see also IODRVCMD.H).
The files WDAC98.CPP and WDAC98.H contain the class WDAC98 with the functions:
WDAC98::ReadAnalogVolt
double ReadAnalogVolt( int channel )
Parameters channel is the number of the analog input channel, which is to be read.
Description The function ReadAnalogVolt reads the analog input channel specified by channel and returns
the corresponding voltage value. The value is in the range from -10.0 to +10.0 with the assumed
unit [Volt].
Return: The input voltage of the analog channel in the range from -10.0 to +10.0.
WDAC98::WriteAnalogVolt
void WriteAnalogVolt( int channel, double val )
Parameters channel is the number of the analog output channel, to which a value is to be written.
val is the value for the analog output.
Description The function WriteAnalogVolt writes the value val in the range from -10.0 to +10.0 (with the
assumed unit [Volt]) as an analog voltage to the specified analog output channel. Values outside
of the mentioned range are limited internally.
WDAC98::ReadDigital
int ReadDigital( int channel )
Parameters channel is the number of the digital input channel, which is to be read.
Description The function ReadDigital reads the state (0 or 1 ) of the specified digital input channel and returns
this value.
WDAC98::ReadAllDigital
int ReadAllDigital( void )
Description The function ReadAllDigital reads the state of all input channels and returns this value.
Return: The state of all digital input channels.
WDAC98::WriteDgital
void WriteDgital( int channel, int val )
Parameters channel is the number of the digital output channel, to which a value is to be written.
value is the new state of the digital output.
Description The function WriteDgital writes the value val (0 or 1) to the specified digital output channel and
with this sets its state.
WDAC98::GetCounter
unsigned int GetCounter( void )
Description The function GetCounter returns the content of the 16-bit-counter register.
Return: The content of the 16-bit-counter register.
WDAC98::SetCounter
void SetCounter( unsigned int val )
WDAC98::GetTimer
unsigned long GetTimer( void )
Description The function GetTimer returns the content of the 32-bit-timer register.
WDAC98::SetTimer
void SetTimer( unsigned long val )
WDAC98::ReadDDM
unsigned int ReadDDM( int channel )
WDAC98::ResetDDM
unsigned int ResetDDM( int channel )
WDAC98::ResetAllDDM
void ResetAllDDM( void )
Description The function ResetAllDDM resets the contents of the counter register of all DDM devices
(incremental encoders) at the same time.
The fuzzy library Fuzzy.lib is constructed with a strict hierarchical structure. Since an object oriented programming
language supports this, the library was programmed using the programming language "C++".
As described in "Backgrounds of the Fuzzy Controller", the fuzzy set is the lowest level of this hierarchy. A
separate class with the name FuzzySet was defined for the fuzzy set. Since nearly all run time operations use the
class FuzzySet, the design was carried out with respect to the optimization of the run time and a definition range as
wide as possible. As these aspects compete with each other, a compromise had to be found between run time and
flexibility. The number representation "double" was chosen, because this is supported directly by the arithmetic
coprocessors. But it is recommended to use a 486DX computer, which has a good performance even with this
number representation. Without an arithmetic coprocessor the fuzzy library can only be applied to slow processes or
off-line calculations, e.g. of a lookup table. The number representation "double" provides a nearly unlimited
definition range for the fuzzy sets. The definition range of a fuzzy set should be between 0 and 1 to achieve a good
overall view, but the correct function of the library does not require this range. The class FuzzySet represents a
fuzzy set by a polygonal line. This polygonal line is stored in form of a corresponding number of x/y values. An
object of type FuzzySet could hold theoretically up to 32768 of those values. But this number will never be
reached, since the available memory is limited. The next level in the hierarchy of the fuzzy library is represented
by the linguistic variable. This variable is included in the class FuzzyVar. A linguistic variable combines a group of
fuzzy sets which have the same definition range. The purpose of the class FuzzyVar is to prepare and handle its
data elements of the type FuzzySet. The x/y values of the objects of type FuzzySet of the class FuzzyVar are
expanded automatically so that all of the fuzzy sets contain the same number of x/y values (normalizing of the sets).
The x co-ordinates of the x/y values are identical. With respect to the run time it is therefore meaningful to use as
few x/y values as possible (usually 3-5 are sufficient) and to use the same x co-ordinates in the x/y values of sets
which are grouped to one linguistic variable.
The fuzzy rules are built by object types of the class FuzzyRule. The class FuzzyRule combines the input and
output linguistic variables together with their sets with respect to the syntax of a fuzzy rule. A separate object has to
be generated for every rule. The class FuzzyRule includes functions to interpret the rules.
The class Fuzzy holds the top of the hierarchy of the fuzzy library. Functions of this class are able to read a fuzzy
description file, to detect syntax errors and to a certain extent logical errors, to generate an executable rule base by
means the above mentioned classes and to compute the mean run time for this base. The class Fuzzy is the only one
of the mentioned classes of the library, which the user calls in his program. An object of the type Fuzzy is a
complete rule base, which is configured by a fuzzy description file. It is problem-free to handle multiple objects of
type Fuzzy, which are stored together in the memory. After reading the fuzzy description file it is recommended to
check by means of corresponding functions if errors occurred during the read and interpret operations. In case of no
error a fuzzy control base can then be generated. A built-in function for computing the mean run time of the
controller in one sampling period should be called before using this control base. The controller run time strongly
depends on the rule base, the number of linguistic variables and the used computer system. The control base should
only be called from an interrupt service routine in case the run time is about 50% shorter than the sampling period
(time between two interrupts).
The library Fuzzy.lib at hand is compiled using the Borland C++ compiler version 4.2. The compiler switches code
optimization for the 386 processor as well as 16 bit, large memory model, were set.
Basic Class:
none
Public Data:
none
FuzzySet::FuzzySet
FuzzySet( char *name, int p )
FuzzySet::FuzzySet
FuzzySet( char *name, int p, double *x #following lines)
FuzzySet::FuzzySet
FuzzySet( char *name, int p, double *x, #following linesdouble *y )
FuzzySet::FuzzySet
FuzzySet( const FuzzySet& org)
FuzzySet::~FuzzySet
~FuzzySet()
FuzzySet::getname
char *getname(void)
Description The function getname returns a pointer to the name of the fuzzy set.
Return The pointer (char *) to the name of the fuzzy set.
FuzzySet::cleary
void cleary( void )
FuzzySet::getxvector
double *getxvector( void )
Description The function getxvector returns a pointer to the data array of the X vector.
FuzzySet::getyvector
double *getyvector( void )
Description The function getxvector returns a pointer to the data array of the Y vector.
Return The pointer (double *) to the Y vector.
FuzzySet::getstuetzen
int getstuetzen( void )
Description The function getstuetzen returns the number of the x/y values.
FuzzySet::insert
void insert( double x, double y )
FuzzySet::normalize
void normalize( int p, double *x )
FuzzySet::coa
double coa( void )
Description The function coa calculates a modified centre of area of the fuzzy set.
Return The value (double) of the centre of area point.
FuzzySet::crisp
double crisp( double x )
FuzzySet::conclude
void conclude( FuzzySet *a, double weight )
FuzzySet::tout
void tout( void )
Description The function tout provides online-debugging. Its output is a representation of the set in readable
text on the screen. This function is still available only to guarantee compatibility with older version
of the fuzzy library. Please use instead the operator <<.
Private Data:
char *SetName is a pointer to the name of the fuzzy set.
double *xval is a pointer to the x vector.
double *yval is a pointer to the y vector.
int sizeis the reserved number of x/y values.
int ss is the actual number of the x/y values.
none
Operators:
FuzzySet::=
FuzzySet& operator = ( const FuzzySet& org )
FuzzySet::*=
FuzzySet& operator *= ( double factor )
FuzzySet::+=
FuzzySet& operator += ( const FuzzySet& org )
Description The summation operator only operates in case the two sets have the same size. The set given by
its reference is added to the actual set.
Return FuzzySet& is a reference to the sum of the sets.
FuzzySet::<<
FuzzySet& operator<< (ostream& o, const FuzzySet& s)
Basic Classes:
none
Public Data:
none
FuzzyVar::FuzzyVar
FuzzyVar( char *name, int c, int m )
FuzzyVar::~FuzzyVar
~FuzzyVar()
Description The destructor not only erases the data defined by the constructor but also all the fuzzy sets, which
were assigned to the linguistic variable by the function add. Therefore a fuzzy set can only be
assigned to one fuzzy variable.
FuzzyVar::getname
char *getname( void )
Description The function returns a pointer to the name of the linguistic variable.
Return The pointer (char *) to the variable name.
FuzzyVar::getsetname
char *getsetname( int i)
FuzzyVar::getsetcount
int getsetcount( void )
Description The function returns the number of the fuzzy sets assigned to this variable.
Return The number (int) of sets assigned to the variable.
FuzzyVar::add
void add( int index, FuzzySet *set)
FuzzyVar::check
void check( void )
Description The function check checks the logic structure of the linguistic variable. This function is not
implemented at the moment. It is intended for a future expansion of the class.
FuzzyVar::norm
void norm( void )
Description The function norm normalizes the linguistic variable. That means every set of the variable has
the same number of x/y values at the same x co-ordinates. This is required for calculations with
the fuzzy sets.
FuzzyVar::getmode
int getmode( void )
Description The function getmode returns the operation mode of the variable i.e. its direction input (bit0= 0)
or output (bit0 = 1).
Return The operation mode (int) of the variable.
FuzzyVar::getmaxx
double getmaxx( void )
Description The function getmaxx determines the maximum X value of the definition range of the normalized
fuzzy variable.
Return The maximum value (double) of the x vector of the variable.
FuzzyVar::getminx
double getminx( void )
Description The function getminx determines the minimum X value of the definition range of the normalized
fuzzy variable.
Return The minimum value (double) of the x vector of the variable.
FuzzyVar::get
double get( int SetNo )
FuzzyVar::set
void set( int SetNo, double weight )
Parameters int SetNo is the index of the fuzzy set, which is to be overlaid.
double weight is the weighting factor.
Description The function set overlays the output set, referenced by its index SetNo, of the variable. The overlay
is weighted by the given weighting coefficient. This function is applicable only to linguistic
variables generated as output variables.
FuzzyVar::clear
void clear( void )
Description The function clear erases the output set of the variable. This is required at the beginning of every
sampling period (control period), but not for every rule. This function is only applicable to output
variables (see also the constructor).
FuzzyVar::out
double out( void )
Description The function out returns the centre of area of the output set of the variable. This function is only
applicable to output variables (see also the constructor).
Return The centre of area (double) of the output set of the variable.
FuzzyVar::getval
double getval( void )
Description The function getval returns the current input value of the variable.
Return The input value (double) of the variable.
FuzzyVar::setval
void setval( double v )
Description The function tout provides online-debugging. Its output is a representation of the linguistic
variable in readable text on the screen. This function is still available only to guarantee
compatibility with older version of the fuzzy library. Please use instead the operator <<.
Private Data:
char *VarName is the pointer to the name of the linguistic variable.
int SetCount is the number of fuzzy sets assigned to this variable.
FuzzySet **d is the pointer to the array of fuzzy sets.
double *normx is the pointer to the normalized x vector.
double value is the input value of the variable.
int mode is the operation mode of the variable:
Bit 0: =0, input variable
= 1, output variable
Bit 1-15 reserved for future expansions.
FuzzyVar::vsort
int vsort( int c, double *x )
Operators:
FuzzyVar::<<
FuzzyVar& operator<< (ostream& o, const FuzzyVar& v)
Basic Classes:
none
Public Data:
none
FuzzyRule::FuzzyRule
FuzzyRule( char *name, int i, int o )
FuzzyRule::~FuzzyRule
~FuzzyRule()
FuzzyRule::getname
char *getname( void )
Description The function getname returns the pointer to the name of the rule.
Return The pointer (char *) to the name of the rule.
FuzzyRule::addIn
void addIn( FuzzyVar *inv, int set, int op )
FuzzyRule::addOut
void addOut( FuzzyVar *outv, int set )
FuzzyRule::Do
int Do( void )
Description The function Do interprets a fuzzy rule. A value has to be assigned to the input variables
previously. The defuzzification of the output sets of the output variables is not performed since
this is only meaningful in case all the rules are interpreted. The operators of the input use the
MIN/MAX (and/or) method. The interference is carried out using the Maximum/Product method.
Return Status (int) is 0 in case the rule is not applicable.
FuzzyRule::tout
void tout( void )
Description The function tout provides online-debugging. Its output is a representation of the fuzzy rule in
readable text on the screen. This function is still available only to guarantee compatibility with
older version of the fuzzy library. Please use instead the operator <<.
Private Data:
char *RuleName is the pointer to the name of the rule.
int incount is the number of input combinations of the rule.
FuzzyVar **invars is the pointer to an array of pointers to input variables.
int *inset is the pointer to an array of index of the sets.
int *operators is the pointer to an array of operators.
int outcount is the number of output combinations of the rule.
FuzzyVar **outvars is the pointer to an array of pointers to output variables.
int *outset is the pointer to an array of index of the sets.
int iidx, oidx are index variables.
none
Operators:
FuzzyRule::<<
FuzzyRule& operator << (ostream& o, const FuzzyRule& r)
FuzzySet,
FuzzyVar,
FuzzyRule,
Basic Classes:
none
Public Data:
struct Fuzzy3DInfo{
long size; // current size of this structure
int idx; // index for the first input variable
int idy; // index for the second input variable
int idz; // index for the output variable
char xname[80]; // name of the first input variable
char yname[80]; // name of the second input variable
char zname[80]; // name of the output variable
double xmin; // minimum value of the first input variable
double xmax; // maximum value of the first input variable
double ymin; // minimum value of the second input variable
double ymax; // maximum value of the second input variable
double zmin; // minimum value of the output variable
double zmax; // maximum value of the output variable
};
Fuzzy::Fuzzy
Fuzzy()
Description The constructor prepares the fuzzy control base. All of the pointers are initialized and a mechanism
to supervise the ’new’ operator is installed. The control base can be used only after a call to the
functions parser and generate.
Fuzzy::Fuzzy
Fuzzy( char *name, ostream& eout = cout )
Description Alternatively to the a. m. standard constructor the control base can be generated using a data file
name. In this case the function read is executed besides the operations of the standard constructor.
The function read reads the file referenced by its name (*name) and prints out status/error
messages to the given stream (eout). Attention: The constructor does not return any error
information. Therefore it is strongly required to test the error status by using the function geterrors
before the program is continued.
Fuzzy::~Fuzzy
~Fuzzy()
Description The destructor has the task to free the memory, which was allocated by this object. To do this the
operator uses several help functions (see killstructures, killbase, killlabel).
Fuzzy::read
int read( char *name = NULL, ostream& eout = cout #following lines)
Parameters char *name is the name of the fuzzy description file (default: NULL)
ostream& eout is the reference to an output stream, which is to be used for status/error
messages (default: cout).
Description The function read opens the fuzzy description file referenced by its file name (*name) and
interprets its data using the function parser. Status and error messages are sent to the given stream
(eout).
Return int, is the number of errors occurred.
Fuzzy::write
int write( char *n = NULL )
Parameters char *n is the name of the fuzzy description file to be created (default: NULL)
Description The function write creates a fuzzy description file on the mass storage depending on the structure
of the fuzzy control base stored in the memory of the computer. This file is readable later on by
the function read. Its name is the given file name (*name).
Return The error status (int) (=0, no error).
Fuzzy::generate
void generate( void )
Description The function generate creates the fuzzy control base using the tree of structures generated by the
function parser. Doing this objects of type FuzzySet, FuzzyVar and FuzzyRule are created.
Existing rule bases are deleted previously (be careful in case of online calls).
Fuzzy::calc
void calc( double *in, double *out )
Parameters double *in is the vector with the values of the input variables.
double *out is the vector with the values of the output variables.
Description The function calc executes the controller function. An array of input values (format: double) is
referenced by its pointer (*in). The pointer (*out) points to an array, which is to be used to store
the output values (format: double). A sufficient size of the arrays has to be regarded. The array
sizes of the control base are known from the fuzzy description file. The order of the array items
is according to the order of their definitions in the description file.
Fuzzy::getinputcount
int getinputcount( void )
Fuzzy::getoutputcount
int getoutputcount( void )
Fuzzy::geterrors
int geterrors( void )
Description The function geterrors returns the number of errors occurred during the last call to the function
parser.
Return The number (int) of errors occurred.
Fuzzy::getrulecatch
int getrulecatch( int i )
Fuzzy::speed
double speed( long count = 1000 )
Description The function speed provides run time analysis (available only for DOS and Windows). It
determines the definition range of the input variables, generates random input values belonging
to this definition range and calculates the mean run time of the function calc. The number of passes
through the function calc, which is to be used to determine the mean value, is given by the
parameter count. The mean run time is returned in milli seconds. The function requires an
executable rule base. The longest possible run time cannot be determined, since the run time
depends on the number of the active rules and with that on the input values. Attention:
Manipulations of the timer interrupt (i.e. for the sampling period) falsify the result.
Return The mean run time (double) of the rule base in milli seconds.
Fuzzy::Get3DInfo
int Get3DInfo( Fuzzy3DInfo *info )
Fuzzy::getname
char *getname( void )
Description The function getname returns a pointer to the name of the rule base.
Return The pointer (char *) to the name of the rule base.
Fuzzy::tout
void tout( void )
Description The function tout provides online-debugging. Its output is a representation of the fuzzy rule base
in readable text on the screen. This function is still available only to guarantee compatibility with
older version of the fuzzy library. Please use instead the operator <<.
Private Data:
char *basename is the pointer to the name of the rule base.
int errorcnt is the counter for the errors occurred during run time.
FuzzyVar **vars is the pointer to an array of pointers to fuzzy variables.
int varcount contains the number of fuzzy variables in the a. m. array.
FuzzyRule **rules is the pointer to an array of pointers to fuzzy rules.
int rulecount contains the number of fuzzy rules.
int *rulecatch is the pointer to an integer array (its size is equal to the number rules) containing
information, whether the specified rule was active during the last execution
pass (!=0) or inactive (==0).
Description structures in form of trees and chained lists for loading, saving and interpreting of fuzzy knowledge
bases are described in the following. Each element of the fuzzy rule base is described by its own structure.
struct PointDes{
PointDes *next, is a pointer to the next element.
double x, is the X value of the base point (X/Y-values).
double y, is the Y value of the base point.
} is a description structure (off-line) for the base points of a fuzzy set.
struct SetDes{
SetDes *next, is a pointer to the next set of the variable.
PointDes *first, is a pointer to the first base point.
int pointcount, is the base point counter.
char *setname is a pointer to the name of the set.
} is a description structure (off-line) for the fuzzy sets of a fuzzy variable.
struct VarDes{
VarDes *next, is a pointer to the next variable.
SetDes *first, is a pointer to the first set of the variable.
int setcount, is the set counter.
char *varname, is a pointer to the name of the variable.
int mode is the operation mode of the variable.
} is a description structure (off-line) for a fuzzy variable.
struct PraeDes{
PraeDes *next, is a pointer to the next premise of the rule.
VarDes *var, is a pointer to the variable structure of the premise.
SetDes *set, is a pointer to the set structure of the a. m. variable.
int op is the operator
} is a description structure (off-line) for the premise of a fuzzy rule.
struct ConDes{
ConDes *next, is a pointer to the next conclusion of the rule.
VarDes *var, is a pointer to the variable structure of the conclusion.
SetDes *set, is a pointer to the set structure of the a. m. variable.
} is a description structure (off-line) for the conclusion of a fuzzy rule.
struct RulDes{
RulDes *next, is a pointer to the next rule.
PraeDes *firstPrae, is a pointer to the first premise of the rule.
ConDes *firstCon, is a pointer to the first conclusion of the rule.
char *rulename, is a pointer to the name of the rule.
} is a description structure (off-line) for a fuzzy rule.
struct label{
label *next, is pointer to the next label structure.
char *name, is a pointer to the label name.
char *val, is a pointer to the label definition.
} is a description structure (off-line) for a label definition.
VarDes *Varbase is the base address of the list of variables.
RulDes *Rulebase is the base address of the list of rules.
label *Labelbase is the base address of the list of labels.
int incount is the number of inputs.
int outcount is the number of outputs.
int *invars is a pointer to an index array for the input variables.
int *outvars is a pointer to an index array for the output variables.
Fuzzy::parser
int parser( istream& in, ostream& out)
Parameters istream& in is the reference to the stream from which the fuzzy description file is read.
ostream& out is the reference to the stream to which error messages are written.
Description An input stream and an output stream are given to the function parser. The function reads
characters from the input stream (in) and interprets it as a fuzzy description file for a fuzzy rule
base. Status and error messages are sent to the output stream (out). To describe the rule base a
tree structure containing chained lists is generated with respect to the description file for a fuzzy
rule base. Syntax errors and to a certain extent logical errors are detected during the interpretation
of the description file. The number of errors is returned by the function but it can be inquired
alternatively by the function geterrors. In case a tree structure for describing the fuzzy rule base
is existing before the function parser is called, this structure is deleted automatically. To interpret
the fuzzy description file the function parser uses the following help functions:
gettoken() to read ’words’ (separated by spaces)
defvar() to read and handle a variable definition
defrule() to read and handle a rule definition
deflabel() to read and handle a label definition
Return The number (int) of errors occurred.
Fuzzy::calcsetup
void calcsetup( void )
Description The function calcsetup prepares a complete rule base for calculation of its values. To do this index
arrays of inputs and outputs are installed. This function is called automatically by the function
generate.
Fuzzy::gettoken
char *gettoken( istream& in, int mode=0 )
Parameters istream& in is the reference to the stream from which the token is to be read.
int mode is the operation mode, see above (default = 0).
Description The function gettoken reads a character string from the given input stream (in) and returns it. The
character strings are separated by white spaces (i.e. spaces, tabs etc.). Comments starting with
’/*’ and ending with ’*/’ are ignored. Labels belonging to the list of labels are replaced
automatically by their definition. The second parameter of the function is assignable to the legal
values 0 or 1:
mode = 0, an arbitrary string (without spaces etc.) is read.
mode = 1, a numerical value (incl. dec. point etc.) is read,
in case of an error in the numerical input the first characters of the returned string
is -1.
Return The pointer (char *) to the token read.
Fuzzy::defvar
int defvar( istream& in, ostream& out)
Parameters istream& in is the reference to the stream from which the description of the linguistic variable
is read.
ostream& out is the reference to the stream to which the status and error messages are written.
Description The function defvar reads and handles a fuzzy linguistic variable. It is called as a help function
by the function parser. The input stream (in) for reading and the output stream (out) to which
error and status messages are written is given to the function. The function returns the number of
errors which occurred during the definition of the linguistic variable.
Return The number (int) of errors occurred.
Fuzzy::defset
int defset( VarDes *v, istream& in , ostream& out)
Parameters VarDes *v is the pointer to the descriptive structure of the linguistic variable from the higher
level.
istream& in is the reference to the stream from which the description of the fuzzy set is read.
ostream& out is the reference to the stream to which status and error messages are written.
Description The function defset reads and handles a fuzzy set. It is called as a help function by the function
defvar which reads and handles a linguistic variable. The arguments given to the function are the
descriptive structure of the linguistic variable from the higher level (*v), the input stream (in)
from which is read and the output stream (out) to which error and status messages are written.
The function returns the number of errors which occurred during the definition of the fuzzy set.
Return The number (int) of errors occurred.
Fuzzy::defrule
int defrule( istream& in, ostream& out)
Parameters istream& in is the reference to the stream from which the description of the rule is read.
ostream& out is the reference to the stream to which status and error messages are written.
Description The function defrule reads and handles a fuzzy rule. It is called as a help function by the function
parser. The arguments of the function are the input stream (in) from which is read and the output
stream (out) to which error and status messages are written. The function returns the number of
errors which occurred during the definition of the rule.
Return The number (int) of errors occurred.
Fuzzy::deflabel
int deflabel( istream& in, ostream& out )
Parameters istream& in is the reference to the stream from which the description of the label is read.
ostream& out is the reference to the stream to which status and error messages are written.
Description The function deflabel reads and handles the definition of a label. It is called as a help function
from the function parser. The arguments of the function are the input stream (in) from which is
read and the output stream (eout) to which error and status messages are written. The function
returns the number of errors which occurred during the definition of the label. Attention: This
function does not operate with gettoken (compare with numerical input)!
Return The number (int) of errors occurred.
Fuzzy::getlabel
char *getlabel( char *s)
Fuzzy::killstructures
void killstructures( void )
Description The function killstructures erases the tree of structures which was used to generate the rule base.
The rule base itself is left unchanged.
Fuzzy::killfuzzybase
void killfuzzybase( void )
Description The function killfuzzybase erases the rule base. Further calls to the function calc are no longer
permitted.
Fuzzy::killlabel
void killlabel( void )
Description The function killlabel erases a list of definitions which were constructed according to ’#define’
assignments from the description file. The rule base and its description by a tree of structures are
left unchanged.
Fuzzy::out
void out( ostream& o) const
Operators:
Fuzzy::<<
friend ostream& operator<<( ostream& o, const Fuzzy& f)
Parameters ostream& o is the reference to the stream to which the fuzzy description file is to be written.
const Fuzzy& f is the object of type Fuzzy, which is to be written.
Description The operator << writes the fuzzy rule base in readable ASCII text to the referenced stream.
Return ostream& is the reference to the stream to which the fuzzy description
Fuzzy::>>
friend istream& operator>>( istream& i, Fuzzy& f)
Parameters istream& i is the reference to the stream from which the fuzzy description file is to be read.
const Fuzzy& f is the object of type Fuzzy, which is to be read.
Description The operator >> reads the ASCII text of the fuzzy rule base from the referenced stream.
Information about syntax or logical errors are to be detected by the function geterrors.
Return ostream & is the reference to the stream from which the fuzzy description
The fuzzy description file with the extension FUZ is a file to configure a fuzzy controller. The file format is
developed by the amira GmbH and is used by several products of the amira.
The fuzzy description file is used to configure a fuzzy object, which i.e. may operate as a fuzzy controller.
The fuzzy description file is a simple ASCII file, which can be edited by a text editor. The length of a line is limited
to 255 characters. Single assignments are separated by spaces or tabulators.
It contains four types of elements, which are described in the following sections:
Comments [optional]
The file can include a comment in classical C-style (’/*’ at the beginning and ’*/’ at the end) at every position
except for the definition part of label. At least one space has to separate the comment string from the ’keywords’
’/*’ and ’*/’.
The definition of a label is limited to one line. It starts with the statement ’#define’. The next statement contains the
label name and the last statement contains the label definition. Thus a label can be defined as follows:
The definition of fuzzy sets is only allowed within the Fuzzy-Var: "temperature"
definition of variables. It is ignored in the other case. The
medium
definition of a variable starts with the statement ’var’. The 1
next statement can hold two different names, either ’input’ cold warm
Membership
fuzzy sets of the fuzzy variable are defined. Such a definition may look like the following:
The definition of a fuzzy rule is recognized from its first statement ’if’. The last statement of a fuzzy rule is named
’end’. The definition of a fuzzy rule contains two parts, the premise and the conclusion. Both parts are separated by
the statement ’then’. The premise and the conclusion are built by a series of expressions which are combined by
operators (further details are shown in the chapter of the theoretical backgrounds of a fuzzy controller). Permitted
operators of the premise are ’and’ (Min-Operator) and ’or’ (Max-Operator) whereas the conclusion requires no
operator to separate the expressions. An expression is the linkage of a fuzzy variable with one of its sets using the
statement ’is’.
The formulation of a fuzzy rule requires that all the variables in use are defined previously since the fuzzy
description file is interpreted only once from top to bottom. The syntax check of a fuzzy object tests whether the
variables are defined, whether the used sets really belong to the variable and if the expressions are used correctly
(input variables with the premise and output variables with the conclusion). A simple definition of a fuzzy rule may
look like the following:
#define NAME Defines a NAME, which is usable in the following statements and will be replaced by the
TEXT definition TEXT automatically by the pre-processor.
/* Begin of comment, ignored by the fuzzy controller kernel.
*/ End of comment.
var Begin of linguistic variable definition. The statements "input" or "output" and the name of
the variable must follow this keyword. Fuzzy sets are definable only in the following. The
definition of the variable is terminated with the statement "endvar".
input Defines the direction input for a variable.
output Defines the direction output for a variable.
endvar End of definition of a variable.
set Begin of fuzzy set definition. A set name and a series of pairs of values must follow this
keyword. The pairs of values are the base points of the set.
endset End of set definition.
Command Explanation
if Begin of fuzzy rule definition. One or multiple premises separated by operators, the
statement "then" and one or multiple conclusions must follow this keyword. The rule
definition is terminated by the statement "end". A premise consists of a name of an input
variable, the statement "is" and the name of the set belonging to this input variable. The
conclusion is built in a similar way but the input variable is replaced by the output variable.
is Separates variable and set in a premise or conclusion.
then Separates the condition and the assignment part of a fuzzy rule.
and Is the Minimum-Operator.
or Is the Maximum-Operator.
end End of rule definition.
Remark
The status and error messages which occur during the interpretation of the fuzzy description file are written to the
file ERROR.OUT or appear on the screen.
During loading and interpreting of a fuzzy description file status and possible error messages are written to the file
ERROR.OUT. This file has the following format:
The simple temperature control of an electrical heating requires two variables, the temperature and the heating
current. Here the temperature is the input variable and the heating current is the output variable. The description of a
fuzzy controller for this system may look like the following:
/* End of File */
As can be seen from the file, the heating operates with a heating current between 0A and 4A. The rules shall control
a temperature of 20°C.
As usual the file name of the fuzzy description file ends with the extension ’fuz’. In this example we choose the file
name ’SIMPLE.FUZ’.
After the fuzzy description file was created according to 3.4.1, it has to be included in a C++ program. The
following example briefly shows the solution:
#include "iostream.h"
#include "ferror.h"
#include "fuzzy.h"
int SetCurveMode(HWND HWnd, WORD idCurve, LPSTR title, WORD AxisId, WORD LineStyle,
DWORD Colour , WORD MarkType )
int SetPlotMode( HWND HWnd, WORD TitlePosition, DWORD TitleColour, LPSTR Title, WORD
WithLineStyleTable, WORD WithAxisFrame, WORD WithPlotFrame, DWORD FrameColour,
WORD WithDate, long OldDate, LPSTR FontName, int MaxCharSize )
void PrintPlotWindow( HWND HWnd, HDC printerDC, int xBegin, int yBegin, int xWidth, int yHeight,
BOOL scale )
HWND CreateEmptyPlotWindow(HWND parentHWnd)
Version
int Version( void )
Description: The function Version returns the version number (at this time = 19 for the version 1.2 dated 01.
April 1999) of this DLL.
Return The version number of this DLL.
CreateSimplePlotWindow
HWND far _pascal CreateSimplePlotWindow (HWND parentHWnd,
WORD NumberOfCurves, WORD NumberOfPoints, double far** data)
The 5 different linestyles, 6 marking types and 8 colours are repeated serially. The curve handles
(identifiers) are set automatically equal to the curve numbers. A standard drawing title will be
added below the axes frame.
Return The Windows handle of the plot object window for a successful windows creation. Otherwise
NULL is returned.
ShowPlotWindow
void far _pascal ShowPlotWindow(HWND HWnd, BOOL bflag );
ClosePlotWindow
void far _pascal ClosePlotWindow(HWND HWnd)
UpdatePlotWindow
void far _pascal UpdatePlotWindow(HWND HWnd)
GetValidPlotHandle
HWND far _pascal GetValidPlotHandle( int index )
Description The function GetValidPlotHandle determines the Windows handle HWnd of that plot object
window which is referenced by the given index. Starting with an index of 0 the handle of each
previously created plot object window is determinable. The function returns the value 0, when a
plot object window with the given index does not exist.
Return The handle HWnd of the plot object window referenced by index if it exists else 0.
AddPlotTitle
void far _pascal AddPlotTitle( HWND HWnd, int Position, LPSTR title)
title. However the overall length of this windows title is limited to 79 characters. The drawing
title must not exceed 255 characters. Line wrapping is carried-out automatically if necessary but
the drawing title will be truncated if it exceeds a third of the drawing height.
AddAxisPlotWindow
WORD far _pascal AddAxisPlotWindow( HWND HWnd, WORD AxisID, LPSTR title,
WORD Position, WORD ScalingType, double ScalMin, double ScalDelta, double ScalMax
)
AddXData:
void far _pascal AddXData(HWND HWnd, WORD XCount, double far* XData )
AddTimeData:
void far _pascal AddTimeData(HWND HWnd, WORD XCount, double StartTime,
double SamplingPeriod )
Description: The function AddTimeData adds new data with a number of XCount time values for the X-axis
to a previously created plot object window with the Windows handle HWnd. The time values start
with StartTime and end with (XCount - 1) * SamplingPeriod. Any existing data of a X-axis in
this plot object are replaced by the new data.
AddYData:
WORD far _pascal AddYData(HWND HWnd, WORD nYCount, double far* YData )
Return Is equal to the automatically generated reference (idCurve) of the added Y-curve, when the plot
object window exists, else equal to 0.
See also CreateSimplePlotWindow.
SetCurveMode
int far _pascal SetCurveMode( HWND HWnd, WORD idCurve, LPSTR title,
WORD AxisId, WORD LineStyle, DWORD Colour, WORD MarkType)
Description The function SetCurveMode changes the attributes of a Y-curve referenced by idCurve
belonging to a previously created plot object window with the Windows handle HWnd. The
describing text title for the linestyle table, the assignment AxisId to the Y- or Y2-axis, the linestyle
LineStyle, the colour Colour as well as the marking type MarkType are assignable.
Remark: When a Y2-axis is not existing but a curve is assigned to this axis the linestyle table
demonstrates this fact by displaying only the describing text for this curve without the short piece
of a straight line. The number of characters in the describing text should be short with respect to
the number of curves.
Return Is equal to 1, when the Y-curve with idCurve exists, else equal to 0.
SetPlotMode
int far _pascal SetPlotMode( HWND HWnd, WORD TitlePosition, DWORD TitleColour,
LPSTR Title, WORD WithLineStyleTable, WORD WithAxisFrame,
WORD WithPlotFrame, DWORD FrameColour, WORD WithDate, long OldDate,
LPSTR FontName, int MaxCharSize )
Description: The function SetPlotMode changes the general layout of a plot object window with the Windows
handle HWnd previously created i.e. by CreateSimplePlotWindow.
As described with the function AddPlotTitle a new drawing title title is inserted at the position
Position . The position is either the upper part of the drawing frame (TITLETEXT_TOP) or the
lower part (TITLETEXT_BOTTOM). If the macro TITLETEXT_APPEND is defined in addition
the title is appended also to the windows title. However the overall length of this windows title
is limited to 79 characters. The drawing title must not exceed 255 characters. Line wrapping is
carried-out automatically if necessary but the drawing title will be truncated if it exceeds a third
of the drawing height. The drawing title is displayed using the colour TitleColor and the character
set FontName with a maximum character height MaxCharSize (for a maximum size of the plot
window). The character set as well as the maximum character height are also used for the other
text outputs.
If the flag WithLineStyleTable is set to TRUE a linestyle table is inserted above the axes frame
containing a short piece of a straight line for each Y-curve with the accompanying attributes
linestyle, colour and marking type followed by a short describing text in the standard form "Curve
#xx" or defined by the function SetCurveMode.
When the flag WithAxisFrame is set to TRUE, a frame is drawn around the axes crossing using
the colour FrameColour only at those margins, which are not occupied by an axis.
When the flag WithPlotFrame is set to TRUE, an additional frame is drawn around the complete
drawing using the colour FrameColour only in case the plot window is output to a Windows Meta
File or to a raster device.
The parameter WithDate determines the display mode of the date in the upper left part of the
drawing. With WithDate set to FALSE the date output is missing. With WithDate set to
NEW_DATE the current date (day, month, year and time during drawing the plot) is inserted
while WithDate set to OLD_DATE will display the date given by the parameter OldDate.
Return Is equal to 1, when the plot window with the handle HWnd exists, else equal to 0.
See also CreateSimplePlotWindow, AddPlotTitle, SetCurveMode.
PrintPlotWindow
void far _pascal PrintPlotWindow( HWND HWnd, HDC printerDC, int xBegin, int yBegin,
int xWidth, int yHeight, BOOL scale )
Description: The function PrintPlotWindow generates an output (typically a hardcopy) of a previously created
plot object window with the Windows handle HWnd. The output device is defined by its device
context handle printerDC. The position and the size of the hardcopy are determined by the
parameters xBegin, yBegin, xWidth and yHeight. These parameters are interpreted as [mm], when
the parameter scale is set to TRUE. Otherwise these parameters are taken as pixel numbers.
CreateEmptyPlotWindow
HWND far _pascal CreateEmptyPlotWindow(HWND parentHWnd)
LibMain
int LibMain( HINSTANCE , WORD, WORD, LPSTR )
SetService
UINT SetService( LPSTR lpServiceName )
Parameters lpServiceName is a pointer to the name of the "Service"-DLL which contains the controller
and is to be called periodically.
Description The function SetService stores the given name (including the extension "DLL") to the variable
szServiceName and tries to load the DLL with this name. In case a DLL with the given name
cannot be loaded, an error message ("SetService ’ServiceName’ LoadLibrary failed!") is
presented and the function returns 0 immediately. Otherwise the addresses of the functions
DoService, SetParameter, GetData, LockMemory, IsDemo and SetDriverHandle which
should be contained in the DLL are determined. If one of these addresses cannot be determined
an error message ("SetService - GetProcAddress ’function name’ failed!") appears on the screen
and the function returns 0 immediately.
Attention: It is strongly recommended to call this function as the first function of the
TIMER16.DLL. Furthermore it has to be called before any function of the "Service"-DLL is
called!
Return Is equal to 1 in case of successful loading the "Service"-DLL and correct address determination,
else equal to 0.
SelectDriver
int SelectDriver( LPSTR lpDriverName)
Parameters lpDriverName is a pointer to the name of the new driver for the PC adapter card.
Description The function SelectDriver stores the given name (including the extension "DRV") to the variable
szDRiverName, which determines the driver for the PC adapter card, only when no timer is
running and no other card driver is open.
Attention: It is strongly recommended to call this function for the first time directly after calling
SetService!
Return Error state :
TERR_OK (0) on successful operations,
TERR_RUNNING (1), when a timer is still running,
TERR_FAIL (99), when another card driver is open.
StartTimer
UINT StartTimer( double Time)
IsTimerActive
UINT IsTimerActive( void )
Description The function IsTimerActive returns the state of the timer controlling the sampling period.
StopTimer
UINT StopTimer( void )
Description The function StopTimer stops the currently running multi-media timer, unlocks the memory of
this DLL as well as of the "Service"-DLL and closes the current adapter card driver.
GetMinMaxTime
GetMinMaxTime( DWORD &min , DWORD &max, BOOL res)
Parameters &min is a reference to the minimum sampling period/calculation time in ms. If this value is
equal to 0 at entry the calculation time of DoService function is returned, else the sampling
period.
&max is a reference to the maximum sampling period/calculation time in ms.
res is a flag to reset the minimum and maximum value of the sampling period/calculation time.
Description The function GetMinMaxTime returns the minimum and maximum value of the real sampling
period or the calculation time during the sampling period (when min=0 at entry) determined up
to this time. With res=1 the minimum and maximum value are set to the nominal sampling period
or a calculation time of 0.
GetSimTime
float GetSimTime( void )
Description The function GetSimTime returns the (simulation) time passed since the last start of a multi-
media timer. This value is calculated by the product of the nominal sampling period and the
number of calls of the function DoService.
Return Time in seconds since the last call of StartTimer.
SetupDriver
UINT SetupDriver( void )
Description The function SetupDriver opens the PC adapter card driver with the name given by the global
variable szDriverName (see also SelectDriver) and starts the dialog to adjust the base address
only when no multi-media timer is running and in case no card driver is open. The driver is closed
again at the end of the dialog. If opening or closing the driver or carrying-out the dialog fails
corresponding messages will appear on the screen.
Return Error state :
TERR_OK (0) on successful operations,
TERR_RUNNING (1), when a timer is still running,
TERR_FAIL (99), when a driver is open or opening and closing the driver fails.
OpenDriver
HDRVR hDriver = OpenDriver(szDriverName, NULL, NULL)
Parameters szDriverName is the file name of the driver, valid names are "DAC98.DRV",
"DAC6214.DRV" and "DIC24.DRV" (according to the PC adapter cards) possibly
combined with complete path names.
Description The function OpenDriver initializes the driver and returns a handle for following accesses to this
driver. If this function is called the first time the driver is loaded into the memory. Any further
calls return another handle of an existing driver. The driver handle is valid only when the return
value is unequal to NULL. In case the return value is equal to NULL, the function OpenDriver
failed meaning that further driver accesses by the functions SendDriverMessage or CloseDriver
are invalid. The parameter szDriverName of the function OpenDriver contains the DOS file
name of the driver. The file name may include the disk name as well as the complete path names
according to the 8.3 name convention but it must not exceed 80 characters. When only a single
file name is used, the drivers location is expected in the standard search path of Windows. The
other parameters are meaningless and should be equal to NULL.
The address of the PC adapter card handled by this driver is read from a specific entry of the file
SYSTEM.INI from the public Windows directory. When this entry is missing the default address
0x300 (=768 decimal) will be taken.
Return Valid driver handle or NULL.
SendDriverMessage
LRESULT result = SendDriverMessage( hDriver, DRV_USER, PARAMETER1,
PARAMETER2 )