CPE400 Lab8 ARCONADO DEVELLES 2 PDF
CPE400 Lab8 ARCONADO DEVELLES 2 PDF
CPE400 Lab8 ARCONADO DEVELLES 2 PDF
8
Controlling DC Motor
Actuators
Course Code: CPE400 Program: BSCPE
Course Title: Embedded Systems Date Performed: OCTOBER 30, 2021
Section: CPE41S1 Date Submitted: OCTOBER 31, 2021
Members: ARCONADO, DEVELLES Instructor: Engr. Mon Arjay Malbog
1. Objective(s):
This activity aims to introduce the concept of DC Motor Control using a microcontroller.
2. Intended Learning Outcomes (ILOs):
After performing the laboratory activity, the students should be able to:
2.1 Implement the circuit and write the program for light and temperature sensors
2.2 Graph/Plot the data being read from the sensors
3. Discussion:
Actuators convert electric signals to another form of energy.
Some of the different types of actuators you would encounter or already have encountered:
• Light Actuators
• Sound Actuators
• Force, Displacement, and Motion Actuators
• Heat Actuators
Motors are also the driving force behind lots of useful products such as water pumps, linear actuators,
and robotics systems. DC Motors are extensively used in precision position-control systems and other
electronic systems, particularly in low-power
applications. This activity will focus on DC motor control using Transistors and an Integrated Motor
Driver Circuit.
4. Materials and Equipment:
5. Procedure:
Using the LDR and Plotting Light Data
1. Implement the circuit as shown in the Breadboard below:
2. Open the Arduino IDE, and copy the code as shown below:
6. Supplementary Activity:
Tasks
1. Using the MOSFET transistor only, implement the circuit and code that would control the speed
of the Motor.
CIRCUIT:
SOURCE CODE:
// C++ code
//
const int onoffswitchstatepin = 7;
const int enablepin = 6;
const int control = A0;
int onoffswitchstate = 0;
int previousonoffswitchstate = 0;
int motorenabled = 0;
int motorspeed = 0;
void setup()
{
pinMode(enablepin,OUTPUT);
pinMode(onoffswitchstatepin, INPUT);
}
void loop()
{
onoffswitchstate = digitalRead(onoffswitchstatepin);
delay(1);
motorspeed = analogRead(control)/4;
onoffswitchstate = digitalRead(onoffswitchstatepin);
if (onoffswitchstate != previousonoffswitchstate)
{
if(onoffswitchstate == HIGH)
{
motorenabled = !motorenabled;
}
}
if (motorenabled == 1)
{
analogWrite(enablepin, motorspeed);
}
else
{
analogWrite(enablepin, 0);
}
previousonoffswitchstate = onoffswitchstate;
}
2. Using the L293D, modify the given code and circuit (remove the potentiometer) so that the
motor would be able to support two modes of modulated speed using one button only.
CIRCUIT:
SOURCE CODE:
void setup()
{
pinMode(directionSwitchPin, INPUT);
pinMode(onOffSwitchStateSwitchPin, INPUT);
pinMode(controlPin1, OUTPUT);
pinMode(controlPin2, OUTPUT);
pinMode(enablePin, OUTPUT);
digitalWrite(enablePin, LOW);
}
void loop()
{
onOffSwitchState=digitalRead(onOffSwitchStateSwitchPin);
delay(1);
directionSwitchState=digitalRead(directionSwitchPin);
motorSpeed=1;
if(onOffSwitchState != previousOnOffSWitchState)
{
if(onOffSwitchState==HIGH)
{
motorEnabled = !motorEnabled;
}
}
if(directionSwitchState != previousDirectionSwitchState)
{
if(directionSwitchState == HIGH)
{
motorDirection = !motorDirection;
}
}
if(motorDirection==1)
{
digitalWrite(controlPin1, HIGH);
digitalWrite(controlPin2, LOW);
}
else
{
digitalWrite(controlPin1, LOW);
digitalWrite(controlPin2, HIGH);
}
if(motorEnabled == 1)
{
digitalWrite(enablePin, motorSpeed);
}
else
{
digitalWrite(enablePin, 0);
}
previousDirectionSwitchState=directionSwitchState;
previousOnOffSWitchState=onOffSwitchState;
}
7. Conclusion
I therefore conclude that in this activity, there is an another type of module that an Arduino
can programmatically control is servo motors. Servo motors have a wide range of applications.
For example, you can build an RC car out of four servo motors, but you'll need at least an
NMOSFET or an L293D driver IC to fully utilize the servo motor. You can programmatically
control the state of the servo motor, the speed of rotation, and even the direction of rotation
using these servo motor drivers.