Vous êtes sur la page 1sur 48

BITS Pilani

Pilani Campus
ACTUATORS

BITS Pilani
Pilani Campus
Actuators
Hardware devices that convert a controller command signal into a change in a physical parameter
• The change is usually mechanical (e.g., position or velocity)
• An actuator is also a transducer because it changes one type of physical quantity into some alternative form
• An actuator is usually activated by a low-level command signal, so an amplifier may be required to provide
sufficient power to drive the actuator

BITS Pilani, Pilani Campus


Types of Actuators
1. Electrical actuators
– Electric motors
• DC servomotors
• AC motors
• Stepper motors
– Solenoids

2. Hydraulic actuators
– Use hydraulic fluid to amplify the controller command signal

3. Pneumatic actuators
– Use compressed air as the driving force

BITS Pilani, Pilani Campus


DC Motor
• A DC motor is any of a class of rotary electrical machines that converts direct current electrical energy into
mechanical energy.

• The working of DC motor is based on the principle that when a current-carrying conductor is placed in a
magnetic field, it experiences a mechanical force.

• A DC motor's speed can be controlled over a wide range, using either a variable supply voltage or by
changing the strength of current in its field windings.

• The direction of this force is given by Fleming’s left hand rule and magnitude is given by:
F = BIL Newtons

BITS Pilani, Pilani Campus


DC Motor
• DC motors are one of the commonly used motors in different applications like electronic toys, power tools,
portable fans, etc.

• Driving a DC Motor
Since DC motors are generally associated with small to medium applications, where the system mainly
consists of a Microcontroller as the main processing unit, controlling and driving a DC motor is very
important. This is because, driving a motor directly using the microcontroller is not advised (sometimes
not possible) as the current from the Microcontroller is very small (usually less than 30mA)

• We are using here L298 Bridge Motor Driving IC.


This dual bidirectional motor driver is based on the very popular L298 Dual H-Bridge Motor Driver IC.
This IC can help us to control two motors of up to 2A each in both directions

BITS Pilani, Pilani Campus


DC Motor Internal

BITS Pilani, Pilani Campus


L298 Bridge IC
• Motor driver is a little current amplifier. It takes a low current signal and gives out a high current signal
which can drive a motor. It can also control the direction of motor.

• L298N is an integrated circuit multi watt 15 package and capable of giving high voltage. It is a high current
dual full-bridge driver which is designed as to accept standard TTL logic levels.

BITS Pilani, Pilani Campus


L298 Bridge IC

BITS Pilani, Pilani Campus


L298 Bridge IC

BITS Pilani, Pilani Campus


L298 Bridge IC

BITS Pilani, Pilani Campus


L298 Bridge IC

BITS Pilani, Pilani Campus


What we need

BITS Pilani, Pilani Campus


DC Motor Interfacing with Aurdino

BITS Pilani, Pilani Campus


DC Motor Interfacing with Aurdino

BITS Pilani, Pilani Campus


DC Motor Interfacing with Aurdino

BITS Pilani, Pilani Campus


DC Motor Interfacing with Aurdino

BITS Pilani, Pilani Campus


DC Motor Interfacing with Aurdino

BITS Pilani, Pilani Campus


DC Motor Interfacing with Aurdino

BITS Pilani, Pilani Campus


DC Motor Interfacing with Aurdino

BITS Pilani, Pilani Campus


DC Motor Interfacing with Aurdino

BITS Pilani, Pilani Campus


DC Motor Interfacing with Aurdino

BITS Pilani, Pilani Campus


Pulse Width Modulation

• PWM, or pulse width modulation is a technique which allows us to adjust the average value of the voltage
that’s going to the electronic device by turning on and off the power at a fast rate.

• The average voltage depends on the duty cycle, or the amount of time the signal is ON versus the amount of
time the signal is OFF in a single period of time.

• So depending on the size of the motor, we can simply connect an Arduino PWM output to the base of
transistor or the gate of a MOSFET and control the speed of the motor by controlling the PWM output.

BITS Pilani, Pilani Campus


DC Motor Control with Aurdino

BITS Pilani, Pilani Campus


DC Motor Control with Aurdino

Aurdino Interfacing
with DC Motor
using L298

BITS Pilani, Pilani Campus


DC Motor Controlling Code
#define enA 9
#define in1 6
#define in2 7
#define button 4

int rotDirection = 0;
int pressed = false;

void setup() {
pinMode(enA, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(button, INPUT);
// Set initial rotation direction
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
}

BITS Pilani, Pilani Campus


DC Motor Controlling Code
void loop() {
int potValue = analogRead(A0); // Read potentiometer value
int pwmOutput = map(potValue, 0, 1023, 0 , 255); // Map the potentiometer value from 0 to 255
analogWrite(enA, pwmOutput); // Send PWM signal to L298N Enable pin

// Read button - Debounce


if (digitalRead(button) == true) {
pressed = !pressed;
}
while (digitalRead(button) == true);
delay(20);

// If button is pressed - change rotation direction


if (pressed == true & rotDirection == 0) {
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
rotDirection = 1;
delay(20);
}
// If button is pressed - change rotation direction
if (pressed == false & rotDirection == 1) {
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
rotDirection = 0;
delay(20);
}
} BITS Pilani, Pilani Campus
Aurdino Cooling Pad

BITS Pilani, Pilani Campus


Hardware Requirements
Since we are using only a single DC Motor for fan controlling we need:

• Aurdino Uno
• Temprature Sensor(LM35)
• L298 Bridge Motor Driving IC
• DC Motor
• Wires
• Programmer
• Plastic Box(case where we can put our DC Motor)
• Fan

BITS Pilani, Pilani Campus


Aurdino Cooling Pad
• LM35 is an analog, linear temperature sensor whose output voltage varies linearly with change in
temperature. LM35 is three terminal linear temperature sensor. It can measure temperature from-55 degree
celsius to +150 degree celsius. The voltage output of the LM35 increases 10mV per degree Celsius rise in
temperature. LM35 can be operated from a 5V supply and the stand by current is less than 60uA.

BITS Pilani, Pilani Campus


Aurdino Cooling Pad

BITS Pilani, Pilani Campus


Aurdino cooling pad
int val;
const int pwm = 2 ; //initializing pin 2 as pwm
const int in_1 = 8 ;
const int in_2 = 9 ;
int tempPin = 1;

void setup(){
pinMode(pwm,OUTPUT) ; //we have to set PWM pin as output
pinMode(in_1,OUTPUT) ; //Logic pins are also set as output
pinMode(in_2,OUTPUT) ;
}
void loop(){
val = analogRead(tempPin);
float mv = ( val/1024.0)*5000;
float cel = mv/10;
float farh = (cel*9)/5 + 32;

if(cel>=45){ //If temperature goes higher than 45 then start the fan
digitalWrite(in_1,HIGH) ;
digitalWrite(in_2,LOW) ;
}
else{
digitalWrite(in_1,HIGH) ;
digitalWrite(in_2,HIGH) ;
}
}

BITS Pilani, Pilani Campus


Arduino Robot Car Control

BITS Pilani, Pilani Campus


Arduino Robot Car Control
Hardware Requirements:

• 2 DC Motors
• L298 Driver
• Aurdino Board
• Chasis
• Joystick
• Wheels

BITS Pilani, Pilani Campus


Arduino Robot Car Control

BITS Pilani, Pilani Campus


Arduino Robot Car Control

BITS Pilani, Pilani Campus


Arduino Robot Car Control

BITS Pilani, Pilani Campus


Arduino Robot Car Control
After defining the pins, in the loop section, we start with reading the joystick X and Y axis values. The joystick
is actually made of two potentiometers which are connected to the analog inputs of the Arduino and they
have values from 0 to 1023. When the joystick stays in its center position the value of both potentiometers, or
axes is around 512.

BITS Pilani, Pilani Campus


Arduino Robot Car Control
Forward And Backward Movement

• We will add a little tolerance and consider the values from 470 to 550 as center.
So if we move the Y axis of joystick backward and the value goes below 470
we will set the two motors rotation direction to backward using the four
input pins. Then, we will convert the declining values from 470 to 0 into
increasing PWM values from 0 to 255 which is actually the speed of the motor.

• Similar, if we move the Y axis of the joystick forward and the value goes above
550 we will set the motors to move forward and convert the readings from 550
to 1023 into PWM values from 0 to 255. If the joystick stays in its center the
motors speed will be zero.

BITS Pilani, Pilani Campus


Arduino Robot Car Control
Forward And Backward Movement

// Y-axis used for forward and backward control


if (yAxis < 470) {
// Set Motor A backward
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
// Set Motor B backward
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);
// Convert the declining Y-axis readings for going backward from 470 to 0 into 0 to 255
value for the PWM signal for increasing the motor speed
motorSpeedA = map(yAxis, 470, 0, 0, 255);
motorSpeedB = map(yAxis, 470, 0, 0, 255);
}

BITS Pilani, Pilani Campus


Arduino Robot Car Control
Right and Left Movement

• So again, first we need to convert the X axis readings into speed values from 0
to 255. For moving left, we use this value to decrease the left motor speed and
increase the right motor speed. Here, because of the arithmetic functions we use
two additional “if” statements to confine the range of the motor speed from 0 to
255.

• The same method is used for moving the car to the right.

BITS Pilani, Pilani Campus


Arduino Robot Car Control
Left and Right Movement

// X-axis used for left and right control


if (xAxis < 470) {
// Convert the declining X-axis readings from 470 to 0 into increasing 0 to 255 value
int xMapped = map(xAxis, 470, 0, 0, 255);
// Move to left - decrease left motor speed, increase right motor speed
motorSpeedA = motorSpeedA - xMapped;
motorSpeedB = motorSpeedB + xMapped;
// Confine the range from 0 to 255
if (motorSpeedA < 0) {
motorSpeedA = 0;
}
if (motorSpeedB > 255) {
motorSpeedB = 255;
}
}

BITS Pilani, Pilani Campus


Arduino Robot Car Control

BITS Pilani, Pilani Campus


Arduino Robot Car Control
#define enA 9
#define in1 4
#define in2 5
#define enB 10
#define in3 6
#define in4 7

int motorSpeedA = 0;
int motorSpeedB = 0;

void setup() {
pinMode(enA, OUTPUT);
pinMode(enB, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
}

BITS Pilani, Pilani Campus


Arduino Robot Car Control
void loop() {
int xAxis = analogRead(A0); // Read Joysticks X-axis
int yAxis = analogRead(A1); // Read Joysticks Y-axis

// Y-axis used for forward and backward control


if (yAxis < 470) {
// Set Motor A backward
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
// Set Motor B backward
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);
// Convert the declining Y-axis readings for going backward from 470 to 0 into 0 to 255 value for the PWM signal for increasing the motor
speed
motorSpeedA = map(yAxis, 470, 0, 0, 255);
motorSpeedB = map(yAxis, 470, 0, 0, 255);
}

BITS Pilani, Pilani Campus


Arduino Robot Car Control
else if (yAxis > 550) {
// Set Motor A forward
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
// Set Motor B forward
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
// Convert the increasing Y-axis readings for going forward from 550 to 1023 into 0 to 255 value for the PWM signal for increasing the
motor speed
motorSpeedA = map(yAxis, 550, 1023, 0, 255);
motorSpeedB = map(yAxis, 550, 1023, 0, 255);
}
// If joystick stays in middle the motors are not moving
else {
motorSpeedA = 0;
motorSpeedB = 0;
}

BITS Pilani, Pilani Campus


Arduino Robot Car Control
// X-axis used for left and right control
if (xAxis < 470) {
// Convert the declining X-axis readings from 470 to 0 into increasing 0 to 255 value
int xMapped = map(xAxis, 470, 0, 0, 255);
// Move to left - decrease left motor speed, increase right motor speed
motorSpeedA = motorSpeedA - xMapped;
motorSpeedB = motorSpeedB + xMapped;
// Confine the range from 0 to 255
if (motorSpeedA < 0) {
motorSpeedA = 0;
}
if (motorSpeedB > 255) {
motorSpeedB = 255;
}
}

BITS Pilani, Pilani Campus


Arduino Robot Car Control
if (xAxis > 550) {
// Convert the increasing X-axis readings from 550 to 1023 into 0 to 255 value
int xMapped = map(xAxis, 550, 1023, 0, 255);
// Move right - decrease right motor speed, increase left motor speed
motorSpeedA = motorSpeedA + xMapped;
motorSpeedB = motorSpeedB - xMapped;
// Confine the range from 0 to 255
if (motorSpeedA > 255) {
motorSpeedA = 255;
}
if (motorSpeedB < 0) {
motorSpeedB = 0;
}
}
// Prevent buzzing at low speeds (Adjust according to your motors. My motors couldn't start moving if PWM value was below value of 70)
if (motorSpeedA < 70) {
motorSpeedA = 0;
}
if (motorSpeedB < 70) {
motorSpeedB = 0;
}
analogWrite(enA, motorSpeedA); // Send PWM signal to motor A
analogWrite(enB, motorSpeedB); // Send PWM signal to motor B
}

BITS Pilani, Pilani Campus

Vous aimerez peut-être aussi