Machines Drive 4
Machines Drive 4
Drives
Dr. Arsalan Arif
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
• MicroChip,
• Atmel,
• Intel
Micro Controller
Micro Controller
Micro Controller
Micro Controller
What is
Arduino?
• A microcontroller board, contains
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
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
/