SArduino Training 2018 cho THPT Saigon Institute of Technology

Slides:



Advertisements
Similar presentations
Lab7: Introduction to Arduino
Advertisements

Servo Background Servos provide control of rotary position Servos are used extensively in the remote control hobby world for: Aircraft (flaps, ailerons,
Servos The material presented is taken from a variety of sources including:
Panasonic EVE-KC2F2024B 24 pulses per revolution 6mm diameter flattened output shaft output type: quadrature (incremental) minimum life: 15,000 rotations.
Available at: – Program Optical Quad Encoders in Autonomous Mode Program optical quad encoders in autonomous mode.
 Main Components:  Sensors  Micro controller  Motor drivers  Chasis.
1 Ultrasonic Distance Sensor. 2 How it Works The distance sensor emits short bursts of sound and listens for this sound to echo off of nearby objects.
Basic Circuits – Lab 2 Arduino and Sensors Xmedia Spring 2011.
In this PPT, all the materials covered up for the PIC microcontroller set-up would be studied. Preliminary skills: Knowing of basic C grammar and basic.
1 Servo Motor. 2 Overview A servo motor is a motor that is only capable of rotating 180 degrees A servo motor is controlled by giving it an angle to proceed.
Objectives: Lead Switching Circuitry/Control Analog to Digital Converter Write to Computer.
The George Washington University Electrical & Computer Engineering Department ECE 002 Dr. S. Ahmadi Class 2.
Arduino. What is it? A open-source software suite and single-board microcontroller. Allows easy and affordable prototyping of microcontroller applications.
Pulse Width Modulation (PWM). 100% Pulse Width Modulation (PWM) 0% On the chipKIT there are 490 periods per second. Use analogWrite(pin, value) to control.
Material taken from Robotics with the Boe-Bot
ALL TERRAIN ROBOT 1 Wilmer Arellano. The Client’s Need  Verbally presented at class time.  Modify the All Terrain Manual Robot into an autonomous Gripper.
Servos The material presented is taken from a variety of sources including:
Microprocessors Tutorial 2: Arduino Robotics. Agenda 1. Robot Anatomy 2. Sensor Review 3. PWM 4. MAKE: Fade 5. Motors 6. H Bridge 7. Robot Control library.
ARDUINO 1. Basics  Comments  /* * Blink * * The basic Arduino example. Turns on an LED on for one second, * then off for one second, and so on... We.
The George Washington University Electrical & Computer Engineering Department ECE 002 Dr. S. Ahmadi Class3/Lab 2.
Photoresistor resistance changes dramatically with light level living with the lab Using Photoresistors with an Arduino © 2011 LWTL faculty team.
:Blink Blink: Er. Sahil Khanna
Istituto Tecnico Industriale A.Monaco EURLAB Moving a robot simple example program to control a DC-Motor Next - Press the button (left)
Electronic instrumentation Digitization of Analog Signal in TD
Pulse-Width Modulation: Simulating variable DC output
Microcontroller basics Embedded systems for mortals.
Arduino Application: Speed control of small DC Motors
Robotics Grant Agreement No LLP UK-LEONARDO-LMP Project acronym: CLEM Project title: Cloud services for E-Learning in Mechatronics Technology.
Having fun with code, using Arduino in a middle school CS classroom
simple example program to control a DC-Motor
Microcontroller basics
Servo Motor.
Using servos.
Microcontroller basics
UTA010 : Engineering Design – II
Get Your Project Started with Arduino
Callback TYWu.
Arduino Part 1 Topics: Microcontrollers Programming Basics
INC 161 , CPE 100 Computer Programming
Arduino.
Въведение в Arduino.
Arduino - Introduction
SArduino Training 2018 cho THPT Saigon Institute of Technology
Omni-directional Robot
SArduino Training 2018 cho THPT Saigon Institute of Technology
Roller Coaster Design Project
What is an Arduino ? Open Source electronic prototyping platform based on flexible easy to use hardware and software.
Schedule 8:00-11:00 Workshop: Arduino Fundamentals
Điều khiển LED và Động cơ DC
Arduino Week 2 Lab ECE 1020 Prof. Ahmadi.
Servos and Stepper Motors
Welcome to Digital Electronics using the Arduino Board
CS4101 Introduction to Embedded Systems Lab 8: Arduino DAC and PWM
Implementing Switches Using Interrupts
Chapter 1 Introduction of Arduino
Interfacing a Rotary Encoder with an Arduino
Arduino : Introduction & Programming
Arduino Practice: Photoresistors, PWM, Potentiometers, Motors
CTY SAR FCPS Shawn Lupoli, Elliot Tan
Arduino Motor Lab Inspired by NYU ITP project
Robotics System Lecture 11_12: DC Motor
Lab #1: Getting Started.
Arduino Uno circuit basics
Programming Concepts (Part B) ENGR 10 Introduction to Engineering
SAURABH GINGADE.
Arduino程式範例.
Introduction to Arduino IDE and Software
Pulse-Width Modulation: Simulating variable DC output
Servo Motor.
Presentation transcript:

SArduino Training 2018 cho THPT Saigon Institute of Technology Control LED and Motor SArduino Training 2018 cho THPT Saigon Institute of Technology Biên soạn: IT SaigonTech - 2018

Control LED Arduino intergrates 1 LED and being hard- wired to pin 13 and GND as below: For LED to lit must output HIGH to pin 13, for LED to dim must output LOW to pin 13 LED Chân số 13 Điện trở R GND (LOW)

Sample code using Pascal (Must us with SArduino IDE download here: http://srobot.saigontech.edu.vn/phan-mem-sarduino/) uses STArduino; const     PIN = 13; procedure setup; begin     pinMode(PIN, OUTPUT); {Declare type of pin} end; procedure loop;     digitalWrite(PIN, HIGH); {Lit the LED}     delay(500); {Do nothing and wait 500 milli-second}     digitalWrite(PIN, LOW); {Dim the LED}     setup;     loop; end.

Sample code for Arduino IDE (C/C++) #define PIN 13 void setup(){     pinMode(PIN, OUTPUT); //{Declare type of pin} } void loop(){     digitalWrite(PIN, HIGH); // Lit the LED     delay(500); // Do nothing and wait 500 milli-second     digitalWrite(PIN, LOW); // Dim the LED

Control the motor In order to control the motor, need to control direction through pin IN1, IN2, IN3, IN4, IN5 and IN6. And Speed through pin EN1, EN2, and EN3. Note: EN1, EN2, EN3 need to be connected to PWM pins of Arduino (Which are indicated by the printed PWM label on the board)

Sample code using Pascal (Must us with SArduino IDE download here: http://srobot.saigontech.edu.vn/phan-mem-sarduino/) {Rotate motor 2s in 1 direction Then reverse in 2s. Looping the task forever} uses STArduino; const IN1=22; IN2=23; EN1=5; procedure setup; begin pinMode(IN1,OUTPUT); pinMode(IN2,OUTPUT); pinMode(EN1,OUTPUT); end; procedure loop; begin digitalWrite(IN1,HIGH); digitalWrite(IN2,LOW); analogWrite(EN1,200); delay(2000); digitalWrite(IN1,LOW); digitalWrite(IN2,HIGH); end; setup; loop; end.

Sample code Arduino IDE (C/C++) #define IN1 22 #define IN2 23 #define EN1 5 void setup(){ pinMode(IN1,OUTPUT); pinMode(IN2,OUTPUT); pinMode(EN1,OUTPUT); } void loop(){ digitalWrite(IN1,HIGH); digitalWrite(IN2,LOW); analogWrite(EN1,200); delay(2000); digitalWrite(IN1,LOW); digitalWrite(IN2,HIGH); } /* Rotate motor 2s in 1 direction Then reverse in 2s. Looping the task forever */

Encoder quadrature -Including 1 transparent disk that imprinted black/white stripes and 2 sensors naming channel A/B. -When sensor (channel) passes through the black stripes the signal is 0, and 1 for vice versa 1 2 3 4 5 6 pulse

How it works and implementation -Channel A and B will be arranged ninety electrical degrees out of phase. Due to the signal reading from both channel we can determine the direction and number of stripes has passed through the sensors. Ví dụ: Motor GA25 has 374 Stripes on the disk, therefore we can count 374 pulse after 1 revolution. -Implementation: Let GA25 rotate in a specific period, we can count a pulse. That equals to (a/374) revolutions . Then according to the circumference of the wheel we can calculate the distance has been traveled. With the distance and the traveling time, we can calculate the speed.

Using library Encoder.h -Arduino IDE (C/C++) and SArduino support library to read encoder. -The function to be used is encRead()

Pascal Sample code begin pos:= encRead(encoder); {Read the encoder, only show on the PC screen if the value change} uses STArduino, STEncoder; var encoder: Sencoder; curPos: longint; procedure setup; Begin serialBegin(9600); curPos := -1; {Declare the channel A/B pins 2, 30} encInitialize(encoder, 2, 30) end; procedure loop; var pos: longint; begin pos:= encRead(encoder); {Below code to make sure the value only shows when being changed} if pos <> curPos then curPos := pos; serialPrintLong(pos); end; setup; loop; end. (Notes: In order to see the changing value, students must manually rotate the motor or combine the rotate code mentioned previously).

Sample code Arduino IDE (C/C++) /* Read the encoder, only show on the PC screen if the value change */ #include <Encoder.h> // Declare the channel A/B pins 2, 30 Encoder myEnc(2, 30); long curPos = -1; void setup() { Serial.begin(9600); } void loop(){ long pos = myEnc.read(); /* Below code to make sure the value only shows when being changed */ if (pos != curPos){ curPos = pos; Serial.println (pos); } Notes: In order to see the changing value, students must manually rotate the motor or combine the rotate code mentioned previously Download library Encoder here: https://github.com/PaulStoffregen/Encoder

Motor Arduino pin connected Functions 1 22 Transmitting signals from the arduino to the H-Bridge to determine the direction the motor will rotate. Digital Output: HIGH / LOW 23 5 Deciding motor speed (PWM). Analog Output Type: 0-255 2 Read the pulse of channel A (Encoder). Digital Input: HIGH / LOW 30 Reads the B channel signal (Encoder) to know the rotational direction of the motor. Digital Input: HIGH / LOW 24 25 6 3 32 26 27 7 18 34

Reference https://www.pjrc.com/teensy/td_libs_Encoder.html http://playground.arduino.cc/Main/RotaryEncoders