VI. Fan Speed Control - Electrical and Computer Engineering

advertisement
Real-time Application Exercises
Electrical and Computer Engineering
VI. Fan Speed Control
By Prawat Nagvajara
Synopsis
Controlling the speed of a direct-current motor
such as an electronic device cooling fan is a
well-suited task for real-time application. The
system consists of the fan (plant) and the
controller. The input to the system is the
desired speed (set point). Based theory of
feedback control, the controller senses the fan
speed and adjusts the amount of power
delivered to the fan changes the speed toward
the set point. The implementation uses a
control algorithm similar to the Proportion and
Integration (PI) control in which the new value
of power to be delivered is a linear function of
the power past value, the difference between
the present speed and the set point defined as
the error, and the error past value (linear
difference equation).
Fig. 1 PSoC Creator Schematic
This note guides reader through the design
components which include
1. Fan speed measurement
2. Input via the CapSense slider and the
fan PWM drive
3. PI control application
Specification
Figure 1 shows a block diagram of the system.
The fan (motor denoted by M) is powered by a
12V power supply (red wire). The amount of
power delivered – the speed is controlled by
the pulse width (percent duty cycle) of a 25 KHz
PWM signal (3.3V and 0V). Figure 2 shows the
San Ace 120 fan datasheet information on the
tested speed v. % duty cycle. The speed of the
fan is measured from the period of the
tachometer pulse signal where a revolution is
equal to 2 pulses.
Fig. 2 Speed v. PWM Duty Cycle [1]
Design Components
1. Fan Speed Measurement
The design uses interrupt on rising edge capture
to measure the period of the tachometer signal
(see pulse sensor in datasheet [1]) to derive the
1
Real-time Application Exercises
speed (rpm or min-1). The timer clock is 1MHz
and a timer count is 1μs.
where, VSP: Set-Point value and VM: Measured
value. The output u(t) is the signal controlling
the plant - a linear equation of e(t), the
integration of e(t) and the derivative of e(t) with
the constants (gains) Kp, Ki and Kd, respectively.
2. CapSense Slider Input and PWM Drive
The design uses the CapSense component for
the fan speed set-point. Reader can refer to a
note [2] on CapSense slider design. Figure 3
shows the CapSense slider configuration, where
the API resolution is set to 100.
The difference equation of the PID controller
using backward Euler method is given in [3] as
u(k) = 1u(k-1) – 2u(k-2) +
0e(k) + 1e(k-1) + 2e(k-2),
(2)
where, the coefficients are derived in terms of
the sampling period TS, Kp, Ki and Kd.
With the PI controller, the transfer function is
given by,
U(z)/E(z) = Kp + KiTS z[z-1]-1
Fig. 3 CapSensense Slider Configuration
From (3) the difference equation is
The PWM period register value is configured to
100 counts. With 2.4MHz clock (Clock_2 in Fig.
1) the effective frequency of the PWM signal
(connected to Pin_1) is equal to 24 KHz. Pin_1
drive mode is Strong Drive. Note that, Clock_2 is
configured to 2.4MHz to avoid a warning on the
accuracy not within the specified tolerance.
u(k) = u(k-1) + [KiTS + Kp]e(k) - Kpe(k-1)
The control application code is based on (4).
Code
The PWM compare register value can be
configured to 50 initially in the schematic. The
application code uses the PWM_WriteCompare
API to change the compare value and effectively
changes the fan speed during the run time.
3. PI Control Application Code
e(t)
Controller
u(t)
Fig. 4 PID Controller
Proportion Integration and Derivative (PID)
controller [3] is based on linear system
controller (Fig. 4) whose input is the error
e(t) = VSP – VM
(3)
(1)
2
(4)
Real-time Application Exercises
3
Real-time Application Exercises
Fig. 5 Tachometer Pulses Signal
Running Application
The implementation uses the San Ace 120 fan
and the PSoC 4 Pioneer kit, the CapSense slider
provides a variable setting for the set-point
speed. Figure 4 shows the UART serial terminal
prints of the set-RPM, the measured RPM and
the error. Figure 5 shows the measured
tachometer pulses with 118.2Hz which
corresponds to 3,546 RPM (2 pulses per
revolution). Figure 6 shows the PWM control
signal with 59.4% Duty Cycle and approximately
at 24 KHz operating frequency.
Fig. 6 PWM Signal
Step Response Logging
A modification of the design by adding a switch
GPIO interrupt with its interrupt routine that
applies a step set RMP and sets a flag such that
the main code prints to the UART for a given
number of times (similar in [2]), can log the step
response of the measured RPM.
In this case the code does not print during the
adjustPWM(void) function, however, only prints
after the switch is pressed. The next paragraphs
describe modifications made.
Fig. 4 Prints: Set-RPM, Measured-RPM and Error
Comment the prints in adjustPWM(void)
4
Real-time Application Exercises
…
Add switch interrupt routine (Digital Input name
is Pin_3).
Logged Data
A step response from 3000RPM to 4500RPM
with E0 = 1 and E1 = 1/10 (Fig. 7) is a typical
step response of a linear first order system. The
vertical axis is the measured RPM and the
horizontal axis is the discrete time.
5000
4000
3000
Series1
2000
…
1000
In the main code add the switch interrupt
routine external start and modify the control
loop.
1
14
27
40
53
66
79
92
0
Fig. 7 Step Response Data
Conclusions
Real-time application in control systems is
ubiquitous. The fan speed control design
comprises the sensing and calculation of the
measured speed, application of linear control
theory and implemented code, and the
actuation of fan speed using the PWM signal.
Sensing, control and actuating are the basic
components of the systems. Sensing, control
and actuating require signal conditioning and
signal processing using analog and digital
hardware and real-time application codes.
Sophisticate systems such as aircraft control
5
Real-time Application Exercises
and self-driving cars require these design
components.
Last, reader can use the step response data
logging method to experiment changing the
parameters E0 and E1 – tuning, to eliminate the
overshoot.
References
1. San Ace 120 fan Datasheet www.sanyodenki.com/currentcooling/cooling_fans/onlinec
atalog/index.pdf
2. Real-Time Application Exercises, Section VI
Exercise – CapSense Driving RGB-LEDs and Data
Logging, Prawat Nagvajara, 2015.
3. Discrete-Time PID Controller Implementation
http://controlsystemslab.com/discrete-timepid-controller-implementation/
6
Download