0% found this document useful (0 votes)
6 views18 pages

Machines Drive 4

The document discusses the fundamentals of electrical machines and microcontrollers, including various types of flip-flops and their functions. It introduces Arduino as a microcontroller board that simplifies control system design and provides coding examples for LED blinking and stepper motor control. Additionally, it offers references and tutorial links for further learning on Arduino and microcontrollers.

Uploaded by

hashim shabbir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views18 pages

Machines Drive 4

The document discusses the fundamentals of electrical machines and microcontrollers, including various types of flip-flops and their functions. It introduces Arduino as a microcontroller board that simplifies control system design and provides coding examples for LED blinking and stepper motor control. Additionally, it offers references and tutorial links for further learning on Arduino and microcontrollers.

Uploaded by

hashim shabbir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 18

Electrical Machine and

Drives
Dr. Arsalan Arif

Electrical machinery Fundamentals


Stephen J. Chapman

Lecture #4

Microcontroller
NOR
Flip Flops X GateY O/P
• Set-Reset (SR) flip-flop or Latch 0 0 1
• JK flip-flop 0 1 0
• D (Data or Delay) flip-flop 1 0 0
• T (Toggle) flip-flop 1 1 0
Case
When we remove the I/P, O/P will be
unchanged 2, 4 0 0 Memory
NOR SR Latch 1 0 1 0 1
SR Latch 3 1 0 1 0
NAND SR Latch 5 1 1 Not Used

NAND Gate
X Y O/P 0 0 Not Used
0 0 1
0 1 1 0
0 1 1
1 0 0 1
1 0 1
1 1 0 1 1 Memory
Flip Flops

NAND Gate NOR


X Y O/P S R O/P X Gate
Y O/P
0 0 1 0 0 No Change 0 0 1
0 1 1 0 1 0 0 1 0
1 0 1 1 0 1 1 0 0
1 1 0 1 1 Don’t Care 1 1 0
Micro Controller
• It is a micro-computer. As any computer it has
internal CPU, RAM, Inputs/Outputs interface.

• It is used for control purposes, and for data analysis.

• A microcontroller is a fairly simple computer


integrated onto a single microchip.

• This single chip will contain a Central Processing


Unit (CPU), memory and other peripherals. Having
everything integrated on a single chip greatly
simplifies designing with microcontrollers compared
to microprocessors.

Famous microcontroller manufacturers are

• MicroChip,
• Atmel,
• Intel
Micro Controller
Micro Controller
Micro Controller
Micro Controller
What is
Arduino?
• A microcontroller board, contains

 On-board power supply


 USB port to communicate with PC,
 Atmel microcontroller chip.

• It simplifies the process of creating any control system UNO


by providing the standard board that can be
programmed and connected to the system without the
need to any sophisticated PCB design and
implementation.

• It is an open-source hardware, any one can get the


details of its design and modify it or make his own one
himself.

• Arduino is not a micro controller rather it is a board


having microcontroller and other components.
MEGA
Arduino IDE

• The program/software used to write code and uploading it to


arduino boards is called Arduino IDE.

Arduino IDE link:


• http://arduino.cc/en/Main/Software
Arduino Coding
• In Arduino Coding there are normally two portions

Void setup(){}
• Used to indicate the initial values of system on starting.

Void loop(){}
• Contains the statements that will run whenever the system is
powered after setup
LED Blinking Example

Example : BLINKING A LED


Turn an LED on for one second, off for one second
and repeat forever.

ARDUINO CODE:
void setup()
{
pinMode(13, OUTPUT); // declaring pin 13 as output pin
}
void loop()
{
digitalWrite(13, HIGH); // Turn on the LED
delay(1000); // Wait for one second
digitalWrite(13, LOW); // Turn off the LED
delay(1000); // Wait for one second
}
Stepper motor control
Example: Sketch to control a stepper motor with TB6560 stepper motor driver and Arduino

TB6600 stepper motor driver with Arduino UNO and stepper motor wiring diagram
Stepper motor control
// Define stepper motor connections and steps per delayMicroseconds(1000);
revolution:
}
#define dirPin 2
delay(1000);
#define stepPin 3
// Set the spinning direction counterclockwise:
#define stepsPerRevolution 200
digitalWrite(dirPin, LOW);
void setup() {
// Spin the stepper motor 1 revolution:
// Declare pins as output:
for (int i = 0; i < stepsPerRevolution; i++) {
pinMode(stepPin, OUTPUT);
// These four lines result in 1 step:
pinMode(dirPin, OUTPUT);
digitalWrite(stepPin, HIGH);
}
delayMicroseconds(1000);
void loop() {
digitalWrite(stepPin, LOW);
// Set the spinning direction clockwise:
delayMicroseconds(1000);
digitalWrite(dirPin, HIGH);
}
// Spin the stepper motor 1 revolution :
for (int i = 0; i < stepsPerRevolution; i++) {
// These four lines result in 1 step:
digitalWrite(stepPin, HIGH);
delayMicroseconds(1000);
digitalWrite(stepPin, LOW);
References and Tutorial Links

http://arduino.cc/en/Reference/HomePage

https://www.makerspaces.com/15-simple-arduino-uno-breadboard-projects/

https://predictabledesigns.com/introduction-to-microcontrollers/

https://www.makerguides.com/tb6600-stepper-motor-driver-arduino-tutorial
/

Easy tutorials on Arduino:


https://www.makerspaces.com/15-simple-arduino-uno-breadboard-projects/
Stepper motor control
// Define stepper motor connections and steps per delayMicroseconds(1000); digitalWrite(stepPin, HIGH);
revolution:
} delayMicroseconds(15000);
#define dirPin 2
delay(1000); digitalWrite(stepPin, LOW);
#define stepPin 3
// Set the spinning direction counterclockwise: delayMicroseconds(15000);
#define stepsPerRevolution 200
digitalWrite(dirPin, LOW); }
void setup() {
// Spin the stepper motor 1 revolution quickly: delay(1000);
// Declare pins as output:
for (int i = 0; i < stepsPerRevolution; i++) { // Set the spinning direction counterclockwise:
pinMode(stepPin, OUTPUT);
// These four lines result in 1 step: digitalWrite(dirPin, LOW);
pinMode(dirPin, OUTPUT);
digitalWrite(stepPin, HIGH); // Spin the stepper motor 5 revolutions fast:
}
delayMicroseconds(1000); for (int i = 0; i < stepsPerRevolution; i++) {
void loop() {
digitalWrite(stepPin, LOW); // These four lines result in 1 step:
// Set the spinning direction clockwise:
delayMicroseconds(1000); digitalWrite(stepPin, HIGH);
digitalWrite(dirPin, HIGH);
} delayMicroseconds(15000);
// Spin the stepper motor 1 revolution slowly:
delay(1000); digitalWrite(stepPin, LOW);
for (int i = 0; i < stepsPerRevolution; i++) {
// Set the spinning direction clockwise: delayMicroseconds(15000);
// These four lines result in 1 step:
digitalWrite(dirPin, HIGH); }
digitalWrite(stepPin, HIGH);
// Spin the stepper motor 5 revolutions fast: delay(1000);
delayMicroseconds(1000);
for (int i = 0; i < stepsPerRevolution; i++) { }
digitalWrite(stepPin, LOW);
// These four lines result in 1 step:

You might also like