You are on page 1of 19

Control lab note:

Experiment-01: Design and implementation of a circuit to drive a stepper motor using IC’s and
discrete components
Stepper motor: A stepper motor is an electric motor whose main feature is that its shaft rotates by
performing steps; moving by a fixed amount of degrees in response to each input current pulse received by
its controller.
Function: speed control, position control.

Step angle: the angle through which the motor shaft rotates for each command pulse is called the step
angle(β)
Common step angle: 1.8, 2.5, 7.5, 15
Range: 0.72-90 degrees
𝑁𝑠−𝑁𝑟
Step angle, β= 𝑁𝑠𝑁𝑟 ∗ 360

Ns= no of teeth on shaft


Nr = No of teeth on rotor
360
Another equation, β=
𝑚.𝑁𝑟
m= No of stator phase.

Resolution: No of states required to complete one rotation.


smaller the step angle- higher the no of steps per revolution- better resolution- better accuracy
360
Resolution=
𝛽
𝛽.𝑓
Motor shaft speed, n=360 𝑟𝑝𝑠

Four modes of stepper mode driving technique:


a) Wave mode
b) Full step mode
c) Half step mode
d) Micro stepping mode

Wave mode: Only one phase at a time is energized.

Full step mode: Two phases are energized at the same time.

Half step mode: Combination of wave and full step mode. The step size is reduced to half.

Micro stepping mode:

• Enhanced version of half step mode.


• Step size can be smaller than half step
• Constant output torque
Experiment-02: Implement an LED brightness control circuit using an Arduino UNO board.
Arduino-Microcontroller
Software name- Arduino IDE (IDE- Integrated development environment)- Write and upload the code to the
physical board.

Features of Arduino:
1. It is able to read program from different sensors and turn it into desirable output. Such as: turning a
motor, Turning on/off switch, connect to the cloud and many other actions

2. Board functions can be controlled using a set of instructions to the microcontroller.

3. Arduino does not need an extra piece of hardware to load a new code. USB cable can simply be used to
load the code to the hardware

4. Arduino Ide uses a simplified version of C++. So, it is easier to code.

5. Arduino provides a standard form factor that breaks the functions of the microcontroller into a more
accessible package.

Board description:

Total no of pin- 28
total no of port- 3(B, C, D)
Digital I/O port-14 (among them 6 are PWM of 8 bit resolution)
Analog Input port- 6(Ao-A5) (10 bit of resolution)
8-BIT microcontroller
Powering- Directly powered by computer usingUSB
Directly powered by AC main source using Barrel JACK

Voltage regulator(7805 IC): Helps to control the DC voltage input to the Arduino board used by the
processor and other elements
Crystal oscillator(pin-9, 10): helps Arduino I dealing with time issues. Frequency of the crystal oscillator is
16MHz.

Reset(pin no – 01) : WE can start the program from beginning.

VCC- 3.3V, 5V
Vin- Can be used to provide power from external power source(6-18V).

ICSP in- VCC, GND, RESET, MOSI, MISO,SCK.

LED: Power- when power connected to the Arduino device


TX- When data is transmitted from the Arduino
RX- when data is received to the Arduino
LED brightness control technique: We can provide 5 volt or 0 volt to the output. And output is a square
wave. By changing the on/off state with high frequency we can create a variable voltage in between. And
the light can be dimmed with this variable voltage.

A built in function “analogwrite()” can be used to generate pulse width modulation signal. Example:

Analogwrite(0)- 0%duty cycle


analogwrite(127)-50% duty cycle
analogwrite(255)- 100% duty cycle

LED control code:

LED=5(Digital PWM) ; is used to introduce pin-5 as output port.

Circuit diagram:
Experiment-03

Specification of Nema 17 stepper motor:


a) Hybrid stepping mode with stepping angle 1.8 degree(200 steps/revolution)
b) Each phase draws 1.2A at 4V.
c) Holding torque is 3.2 kg.cm

What does void loop () do?

The void loop() is a function that executes indefinitely until you power off the Arduino.

Three basic types of stepper motor:

a) Variable reluctance stepper motor


b) Permanent magnet stepper motor
c) Hybrid stepper motor

Variable resistance stepper motor:

• This type of motor consists of soft iron multi toothed rotor and a one stator
• Direction of rotation is independent of the polarity of stator current
• The reluctance of the magnetic circuit formed by the rotor and stator teeth varies with the angular position
of the rotor

Parmanent magnet stepper motor:

• It has a wound stator poles but its rotor poles are permanently magnetized
• The rotor no longer has teeth in it unlike VR motor.
• It’s direction of rotation depends on the polarity of the stator current.

Hybrid stepper motor:


• It has multi tooted rotor like VR motor and contains an axially magnetized concentrated permanent magnet.
• Typical step angle range is from .92 to 3.6 degrees.

Experiment-04: Find overall transfer function of the system given in block diagrams. Also find the poles
and zeroes of the transfer function.

Block diagram- Block diagram is a pictorial representation of a control system. It is used to make a
mathematical model of a control system which can be implemented on a computer.

Pole: A pole is a point in the complex plane where the transfer function of the system approaches infinity.

Zero: A zero is a point in the complex plane where the transfer function of the system approaches zero.

clc; close all; clear all;


% define transfer function for all blocks individually
numg1=[1 0 0]; %define numerator of G1(s)
deng1=[5 -3];%define denominator of G1(s)
g1=tf(numg1,deng1);%G1(s)
numg2=[2 1];%define numerator of G2(s)
deng2=[2 0 0];%define denominator of G2(s)
g2=tf(numg2,deng2);%G2(s)
numg3=[1]; %define numerator of G3(s)
deng3=[1 1];%define denominator of G3(s)
g3=tf(numg3,deng3);%G3(s)
numg4=[1 2]; %define numerator of G4(s)
deng4=[1 0 2];%define denominator of G4(s)
g4=tf(numg4,deng4);%G4(s)
numh=[1 0 -5];%define numerator of H(s)
denh=[1 3];%define denominator of H(s)
h=tf(numh,denh);%H(s)
%system reduction

sys1=series(g2,g3);
sys2=parallel(g1,sys1);
sys3=series(sys2,g4);
finalsys=feedback(sys3,h);
Cs=minreal(finalsys) %cancel common terms

[num,den]=tfdata(Cs, 'v')

%Determination of poles and zeroes of the system


[zero, pole] = tf2zp(num, den)

Experiment-05: Obtain step response of a unity feedback for a given forward transfer function and find ζ,
ωn, Ts, Tp, Tr, %OS.
clc; close all; clear all;
% define transfer function for blocks
num=25; %Define numerator of G(s)
den=[1 5 0];%Define denominator of G(s)
g=tf(num,den);%G(s)
T=feedback(g,1);%Find T(s)
[numt,dent]=tfdata(T,'v');%Extract numerator and denominator of T(s)

wn=sqrt(dent(3)) %Find natural frequency


z=dent(2)/(2*wn) %Find Damping Ratio
Ts=4/(z*wn) %Find Settling Time
Tp=pi/(wn*sqrt(1-z^2))%Find Peak Time
pos=exp(-z*pi/sqrt(1-z^2))*100 %Find percent overshoot
step(T)% Generate Step Response

𝑨𝒄𝒕𝒖𝒂𝒍 𝒅𝒂𝒎𝒑𝒊𝒏𝒈 𝒄𝒐𝒏𝒔𝒕𝒂𝒏𝒕


𝜻=
𝑪𝒓𝒊𝒕𝒊𝒄𝒂𝒍 𝒅𝒂𝒎𝒑𝒊𝒏𝒈 𝒄𝒐𝒏𝒔𝒕𝒂𝒏𝒕
%OS: The amount that the waveform overshoots the steady state or final value at the peak
time as a percentage of the steady state value.
Experiment-06: A plant to be controlled is described by a given transfer function. Obtain the root locus
plot.
clc; close all; clear all;
G1 = tf([1 4 2 2],[1 3 0]);
sys1=G1;
T=5;
G2 = tf([1 1],[1 4 6 4]);
sys2=T*G2;
G3 = tf([1 3 2] ,[1 2 4 10]);
H3 = tf([1 7],[1 5 6 0]);
sys3=G3*H3;
G4=tf([3 6],[1 .5 7]);
sys4=G4;
G5=tf([.5 1.3], [1 1.2 1.6 0]);
H5=tf([1 1.3], [1 1.2 1.6]);
sys5=G5*H5;
subplot(3,2,1)
rlocus(sys1)
title('System 1')
subplot(3,2,2)
rlocus(sys2)
title('System 2')
subplot(3,2,3')
rlocus(sys3)
title('System 3')
subplot(3,2,4)
rlocus(sys4)
title('System 4')
subplot(3,2,5.5)
rlocus(sys5)
title('System 5')

Root locus:
path of the closed loop poles.
Nature of the control system
Stability of the closed loop control system

Root locus definition: Root locus is the locus of the roots of the characteristics equation by varying system
gain(K) from zero to infinity.

Case-I: K = 0; Closed loop poles are equal to the open loop poles
Case-II: K = ∞; Closed loop poles are equal to the open loop zeroes

so the root locus branches ranges from open loop poles to open loop zeroes.

Angle condition: The point at which the angle of the open loop transfer function is an odd multiple of 180
degree.
Magnitude condition: The point at which the magnitude of the open loop transfer function is one

Experiment-07: Obtain bode plot for a unity feedback system with a given G(s) for different values of k.
Also, obtain gain margin, phase margin, phase crossover frequency and gain crossover frequency.

Bode plot: It is a graphical technique used to determine the stability of control system.

A bode plot maps the frequency response of the system through two graphs
-Bode magnitude plot
- Bode phase plot
Semi log graph paper is used.

Gain margin: Gain margin refers to the amount of gain which can be increased or decreased without
making the system unstable.

GM=0-G dB

Phase crossover frequency: This the frequency at which the phase curve cuts the -180 degree axis in the
Bode plot.

Phase margin: Phase margin is the amount of phase which can be increased or decreased without making
the system unstable.

PM = ɸ - (-180) degree
Gain crossover frequency: this is the amount of frequency at which the gain curve cuts the zero dB axis in
the Bode plot.

Corner frequency: the frequency at which the two asymptotes cut or meet each other is called break
frequency or corner frequency.
the corner frequency in a Bode plot of a control system is the frequency at which the magnitude
response begins to decrease significantly, and it can be found by locating the frequency where the
magnitude response crosses the -3 dB line.

Bode stability criterion:


1. Stable: GM,PM both positive or Wpc>Wgc
2. Unstable: GM, PM both negative or Wpc<Wgc
3.MErginally stable: GM,PM both are zero or Wgc=Wpc.

Code:

(i)
clc; close all; clear all;
Num= input ('Enter num=')
Den= input ('Enter den=')
G=tf(Num,Den)
[GM PM Wpc Wgc]=margin(G)
bode(G)
(ii)
clc; close all; clear all;
w=logspace(-1,2,200);

for i=1:3
if i==1
K=1;
num=[0 0 0 K];
den=[1 6 5 K];
G=tf(num,den);
[mag,phase,w]=bode(G,w);
mag1dB=20*log10(mag);
phase1=phase;
disp('gain margin, phase margin, phase crossover frequency and gain
crossover frequency for k=1')
[GM PM Wpc Wgc]=margin(G)
end
if i==2
K=10;
num=[0 0 0 K];
den=[1 6 5 K];
G=tf(num,den);
[mag,phase,w]=bode(G,w);
mag2dB=20*log10(mag);
phase2=phase;
disp('gain margin, phase margin, phase crossover frequency and gain
crossover frequency for k=10')
[GM PM Wpc Wgc]=margin(G)
end
if i==3
K=20;
num=[0 0 0 K];
den=[1 6 5 K];
disp('gain margin, phase margin, phase crossover frequency and gain
crossover frequency for k=20')
G=tf(num,den);
[mag,phase,w]=bode(G,w);
mag3dB=20*log10(mag);
phase3=phase;
[GM PM Wpc Wgc]=margin(G)
end
end

figure
semilogx(w,mag1dB(:,:)','-',w,mag2dB(:,:)','-',w,mag3dB(:,:)','-')
grid on
title('Bode Diagrams of G(s)=K/[s(s+1)(s+5)] where K=1, K=10 and K=20')
xlabel('Frequency (rad/sec)')
ylabel('Gain(dB)')
text(1.2,-31,'K=1')
text(1.1,-9,'K=10')
text(11,-31,'K=20')
figure
semilogx(w,phase1(:,:)','-',w,phase2(:,:)','-',w,phase3(:,:)','-')
grid on
xlabel('Frequency (rad/sec)')
ylabel('phase(degree)')
text(0.2,-90,'K=1')
text(0.2,-20,'K=10')
text(1.6,-20,'K=20')
Frequency response:
The combination of the magnitude and phase frequency responses is called the frequency response.

Experiment-08: The open loop transfer function G(s) of a unity feedback system is given. Draw the
Nyquist plot of G(S). Also determine the stability of the system.

Nyquist stability criterion states that the number of encirclements about the point (-1+j.0) is equal to the
difference between enclosed open loop poles and the enclosed closed loop poles.

Code:
clc; close all; clear all;
%sketch the Nyquist plot for the system
num=60;
den=conv([1 1],conv ([1 2],[1,5]));
G=tf(num,den);
nyquist(G)
b=isstable(G)
Here,
p=0
N=0
Z=P-N
Z=0-0;
since, Z=0, the value of Z indicates that there is no closed loop pole on the right half plane. So, the system
is stable.

Experiment-09: Determine the transfer function and poles of the system represented in state space as
given.
Code:
clc; close all; clear all;
A=[-2.048 0;0.83333 -2.2381];
B=[7 0.5714;-1.117 0];
C=[0 1];
D=[0 0];
[num,den]=ss2tf(A,B,C,D,2);
G=tf(num,den)%Determine transfer function

%Determination of poles and zeroes of the system


[zero,pole] = tf2zp(num,den)
zplane(zero,pole)

Experiment-10: Show the effect of addition of (a) a PD and (b) a PI controller on the system performance
of a unity feedback system with given forward path transfer function.
Code:
clc; close all; clear all;
num=[1]
den=[1 10 20];
P = tf(num,den)
T1=feedback(P,1)
figure
step(T1)
title('Step Response of given system')
grid on

clc; close all; clear all;


s = tf('s');
P = 1/(s^2 + 10*s + 20);
Kp = 500;
Ki = 400;
Kd = 50;
C4 = pid(Kp,Ki,Kd)
T5 = feedback(C4*P,1);
t = 0:0.01:2;
step(T5,t)
title('PID Control Kp=500 Ki=400 Kd=50')
stepinfo(T5)
grid on

Question-1 : Draw the block diagram (not schematic diagram) of design and implement a circuit to drive a
stepper motor using ICs and discrete components.

Question-2:How can you determine whether a stepper motor coil is center-tapped or not?

Answer: A center-tapped stepper motor has a center tap on one or more of its windings, which allows for
two independent circuits to be created. This center tap can be identified by an additional wire coming out
of the motor. The center tap wire is typically connected to ground or a power supply, depending on the
circuit configuration.
In contrast, a non-center-tapped stepper motor does not have a center tap wire and only has two wires per
winding. This type of stepper motor typically requires a different driver circuit than a center-tapped stepper
motor.

To summarize, if you see an additional wire coming out of a stepper motor, it is likely a center-tapped
stepper motor. Otherwise, if you only see two wires per winding, it is likely a non-center-tapped stepper
motor.

Question-04. How can you calculate step angle of a stepper motor?


𝑁𝑠−𝑁𝑟
Step angle, β= 𝑁𝑠𝑁𝑟 ∗ 360

Ns= no of teeth on shaft


Nr = No of teeth on rotor
360
Another equation, β=
𝑚.𝑁𝑟
m= No of stator phase.

Question-03: Draw coil arrangement for unipolar and bipolar stepper motor.

Question-05. Which software is used for Arduino programming?

There are several software options available for programming Arduino boards, but the most commonly
used software is the Arduino Integrated Development Environment (IDE).

Question-06: Write code for define e pin as output?

Answer:

Int Constant=’e’ ;
void setup()
{
pinMode(Constant, OUTPUT);
}
2𝑠+1
Question- 7. a. Write a MATLAB code for 𝐺(𝑆) =4𝑠^2+2𝑠+3
num=[2 1];
den=[4 2 3];
Sys = tf(num, den)

b) Write a MATLAB code for 𝐺(𝑆) = (2𝑠+1)(4𝑠+2) /(4𝑠 2+2𝑠+3)(𝑠+1)

s = tf('s')
Gs = ((2*s+1)*(4*s+2)/( 4*s^2+2*s+3)*(s+1))

Or
num=conv([2 1],[4 2]);
den=conv([4 2 3],[1 1]);
Gs = tf(num,den)

Question-8. Write MATLAB functions for the following terms


a. Step Response
step(T); Where T is a transfer function.
b. Different Parameters of Step Response
stepinfo(T) ; Where T is a transfer function and the command step info will generate, rise time, settling
time, setlling min, settling max, overshoot, undershoot, peak, peaktime.
c. Bode plot
[mag, phase, w]= bode(g,w);
Where,
1. w was also be defined as w = logspace(-1,2,200) which indicates a range of frequency.
2. Mag is the magnitude of the frequency response.
3. Phase is the phase of the frequency response.
4. g is the transfer function.
d. Nyquist Plot
nyquist(t)
where t is the transfer function.
e. Root locus
rlocus(T), Where T is the transfer function whose root locus diagram is to be obtained.

You might also like