September, 2007ENGR 6806 1 Low-Level Robot Control Mechatronics: Motors, sensors & embedded controls.

Slides:



Advertisements
Similar presentations
MICROPROCESSORS AND MICROCONTROLLERS
Advertisements

EMS1EP Lecture 8 Pulse Width Modulation (PWM)
MOTION CONTROL ECE 105 Industrial Electronics Engr. Jeffrey T. Dellosa College of Engineering and Information Technology Caraga State University Ampayon,
What is Arduino?  Arduino is a ATMEL 168 micro-controller kit designed specially for small projects  User friendly IDE(Integrated Development Environment)
Basic DC Motor Circuits
Indian Institute of Technology Hyderabad ROBOTICS LINE FOLLOWER HARI KISHAN TANDEY – ES12B1008 DILIP KONDAPARTHI – ES12B1010 SAI KARTIK – CE12B1015.
Term 8 Electrical and Computer Engineering Project Course January 2002 Mark Simms Steven Taylor PIC Development, The Easy Way.
EML 2023 – Motor Control Lecture 4 – DAQ and Motor Controller.
ELECTRICAL. Circuits Outline Power Hub Microcontroller Sensor Inputs Motor Driver.
Lecture 9: D/A and A/D Converters
EET 2261 Unit 13 Controlling Stepper Motors and Servos  Read Almy, Chapter 21.  Lab #13 due next week.  Final Exam next week.
L.
Digital Tachometer ENGR 4803 Electromechanical Systems & Mechatronics.
Coordinate Based Tracking System
SENIOR DESIGN 10/16.
ECGR-6185 Advanced Embedded Systems University Of North Carolina at Charlotte A. Srinivas Reddy Stepper/Servo/DC Motors.
DC Motor Drives Dr. Ahmad Harb.
Digital I/O Connecting to the Outside World
Micromouse Meeting #3 Lecture #2 Power Motors Encoders.
 Main Components:  Sensors  Micro controller  Motor drivers  Chasis.
Engineering 1040: Mechanisms & Electric Circuits Fall 2011 Introduction to Embedded Systems.
1 Motors & Motor Controllers ECE AC or DC Motors AC –Few robots use AC except in factories –Most of those that use AC first convert to DC DC –Dominates.
Dean Brock, Rebecca Bruce and Susan Reiser, CCSC SE 2009 Using Arduino Material taken from Todbot blog Bionic Arduino Todbot blog Bionic ArduinoTodbot.
Microcontroller Hands-on Workshop #3 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers November 7, 2009.
ENGR 6806 – Motor Control Prepared By: Rob Collett September 15, Office: EN2074.
Digital to Analogue Converter
RS232 #use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7
10/10/ Controlling YOUR ROBOT. 10/10/2015 Basic Stamp  Basic Stamp Input - output pins Interpreter Chip Power supply: 5 Volts voltage Memory: EEPROM.
CS 478: Microcontroller Systems University of Wisconsin-Eau Claire Dan Ernst Hybrid I/O – Pulses.
By: Khalid Hawari Muath Nijim Thaer shaikh Ibrahim Supervisor: Dr. Jamal Kharousheh Dr. Nasser Hamad 27 December 2010.
MICROCONTROLLER SYSTEMS Part 1. Figure 1.1Elements of a digital controller CPU Central Processing Unit Input Peripherals Output Peripherals ROM Read Only.
Electrical Actuation System Lecture 9 (Chapter 9).
STEPPER MOTORS Name: Mr.R.Anandaraj Designation: Associate. Professor Department: Electrical and Electronics Engineering Subject code :EC 6252 Year: II.
1 Lecture on Lab 6 Lab 7 Lab 8. 2 Lab 6: Open Loop Controller As you learned in lab 5, there are two kinds of control systems: open loop and closed loop.
CCP MODULES  The CCP module (Capture/Compare/PWM) is a peripheral which allows the user to time and control different events.  Capture Mode provides.
Embedded Systems Design: A Unified Hardware/Software Introduction 1 Chapter 4 Standard Single Purpose Processors: Peripherals.
Automatic accident avoiding system PROJECT MEMBERS MUTHUKUMAR.K (05ME33) SAKTHIDHASAN.S (05ME39) SAKTHIVEL.N (05ME40) VINOTH.S (05ME56) PROJECT GUIDE:
CS224 I/O. Timers Timer1 is 16-bit timer 2^16-1 or 65,535 SYSCLK = 40MHz, Prescalers – 1:1, 1:8, 1:64, and 1:256 – Use T1CONbits.TCKPS=3 for 1:256 scaling.
Microcontroller Applications ELEC 421 Dr. Ron Hayne Images Courtesy of Ramesh Gaonkar and Delmar Learning.
Components of a typical full-featured microcontroller.
CONTENTS Objective Software &Hardware requirements Block diagram Mems technology Implementation Applications &Advantages Future scope Conclusion References.
MICROCONTROLLER INTERFACING WITH STEPPER MOTOR MADE BY: Pruthvirajsinh Jadeja ( ) COLLEGE:DIET BRANCH:EC.
Servo Motor Control Using Arduino Instructor: Dr Matthew Khin Yi Kyaw.
Istituto Tecnico Industriale A.Monaco EURLAB Moving a robot simple example program to control a DC-Motor Next - Press the button (left)
DC motor principles Speed control Direction Stepper motor principles
Electronic instrumentation Digitization of Analog Signal in TD
Pulse-Width Modulation: Simulating variable DC output
Wireless Bluetooth Controller For DC Motor. Introduction Wireless becoming more and more available and widely used Bluetooth is one of the major players.
Microcontroller basics Embedded systems for mortals.
1. PIC ADC  PIC18F877 has 8 analog input channels i.e. port A pins(RA0 to RA5) and port E pins(RE1 and RE2). These pins are used as Analog input pins.
Components of Mechatronic Systems AUE 425 Week 2 Kerem ALTUN October 3, 2016.
Motors & Motor Controllers
Application Case Study Christmas Lights Controller
Introduction to Motors, servos and steppers
Outline Introduction to digital-to-analog converter (DAC)
Application Case Study Security Camera Controller
Introduction to Servos
Microcontroller Applications
Overview Basic PIC Circuits Development in C using CCS
Pulse Width Modulation (PWM) Motor Feedback - Shaft Encoder
Programming Concepts (Part B) ENGR 10 Introduction to Engineering
ARDUINO     What is an Arduino? Features 14 Digital I/O pins 6 Analogue inputs 6 PWM pins USB serial 16MHz Clock speed 32KB Flash memory 2KB SRAM.
CBC Fundamentals Lecture is based on material from Robotic Explorations: A Hands-on Introduction to Engineering, Fred Martin, Prentice Hall, 2001.
ECE 354 Computer Systems Lab II
Servos and Stepper Motors
Controlling YOUR ROBOT
EET 2261 Unit 12 Controlling Stepper Motors and Servos
UNIT 11: RC-SERVOMOTOR CONTROL
Robotics System Lecture 11_12: DC Motor
Presentation transcript:

September, 2007ENGR Low-Level Robot Control Mechatronics: Motors, sensors & embedded controls

September, 2007ENGR Outline PIC Board Electro-Mechanical Components: Motor, PWM, Encoder, R/C Servo Sample C Programming Motor Control

September, 2007ENGR Basic PIC Circuits based around the PIC16F877, a mid-range microcontroller that supports: –8kB of flash program memory –Interrupts –In-circuit programming –Hardware timers –Capture/Compare/PWM modules –10-bit A/D conversion (up to 8 channels) –Built-in USART for serial communication

September, 2007ENGR PIC Board for 6806 PIC 16F877 and: –I/O terminations –Max 232 Serial Communications –2 x LMD18200T H-Bridges reconfigurable –1 x L298N Stepper Motor controller

September, 2007ENGR

September, 2007ENGR Schematics

September, 2007ENGR Motor Basics

September, 2007ENGR An inductor with resistance

September, 2007ENGR Remember this Waveform! Note how the current levels off. This will provide a steady speed.

September, 2007ENGR H-Bridge Basics control the speed and direction of a motor use Power Electronics… MOSFET (DMOS) as a switching device App. Notes: National Semiconductor –AN 694 (H-Bridge) –AN 558 (Power MOSFET)

September, 2007ENGR Direction Control The H-Bridge Chip has a “Direction Pin” that can be set using digital logic High/Low controls flow through the motor in the forward or reverse configuration:

September, 2007ENGR Speed Control By turning our MOSFETs (switches) ON and OFF really fast, we change the average voltage seen by the motor. This technique is called Pulse-Width Modulation (PWM).

September, 2007ENGR PWM Basics The higher the voltage seen by the motor, the higher the speed We’ll manipulate the PWM Duty Cycle.

September, 2007ENGR H-Bridge Pins Pin 1: Bootstrap 1 (10nF cap to Pin 2) Pin 11: Bootstrap 2 (10nF cap to Pin 10) Pin 2: Output to Motor (M+) Pin 3: Direction Input (From PIC) Pin 5: PWM Input (From PIC) Pin 6: Power Supply (Vs) Pin 7: Ground Pin 10: Output to Motor (M-) Pin 4: Brake, normally grounded Pin 8: Current Sense Pin 9: Thermal Flag Red pins are to be connected by the user!

September, 2007ENGR Locked Anti-phase PWM: Set the PWM pin to High (100% duty) Use PWM signal on the direction pin to control duty cycle and direction: –50% forward / 50% reverse: no net current thru motor –60% forward / 40% reverse: net forward current thru motor –40% forward / 60% reverse: net reverse current thru motor

September, 2007ENGR Using The PIC for Motor Control Use the PIC to generate digital logic signals to control our H-Bridge We’ll need –A digital high/low for direction output_high(PIN_A0); –A PWM signal for speed control

September, 2007ENGR Setting the PWM Signal This can be tough because we need to use a timer to set the PWM frequency. We also need to figure out how to control the PWM duty cycle.

September, 2007ENGR Setting up a PWM Signal Step 1: Tell the PIC we want a PWM signal: –setup_ccp1(CCP_PWM); Step 2: The PIC uses a timer called “Timer2” to control the PWM frequency. We need to set this frequency: –setup_timer_2(T2_DIV_BY_X, Y, Z); But what are X, Y, and Z? We’ll go thru an example.

September, 2007ENGR Setting up a PWM Signal Step 3: Set the PWM Duty Cycle and hence the speed of the motor. So, to start the motor, we could say: –set_pwm1_duty(#); (0 < # < 1024) To stop the motor, we could say: –set_pwm1_duty(0);

September, 2007ENGR Motor Encoders Motor Encoders allow for us to track how far our robot has travelled. The encoders count wheel revolutions using optical sensors. These sensors count notches on the Drive Shaft of the motor.

September, 2007ENGR Some Encoder Details… There are 512 notches on the drive shaft. There is a 59:1 gear ratio. (This means the drive shaft spins 59x faster than the wheel.) The top gear-down speed is around rpm.

September, 2007ENGR Some Electrical Details… The encoders we’ll be using have 4 wires: –5V Power Supply (Red) –GND (Black) –Channel A a.k.a. CHA (Blue) –Channel B a.k.a. CHB (Yellow) Channels A&B will give us the signals to count wheel revolutions.

September, 2007ENGR How Encoders Work CHA and CHB are actually square waves separated by 90 0.

September, 2007ENGR Counting Encoder Cycles So, if we know the current encoder state and the last encoder state, we can tell which direction we’re going. By counting the number of times we’ve changed states, we can tell how far we’ve gone. Just remember that there are 4 encoder states per notch!

September, 2007ENGR RC Servo Basic 1 ms: servo is positioned at extreme left 1.5 ms: servo position at Centre 2 ms: servo is positioned at extreme right RC servo is controlled by Pulse code Modulation at 50 Hz (20ms period):

September, 2007ENGR RC Servo Basic Continued 3 wires: red: (+4.5 to 6.0 V), black: ground, white: PCM Control Can be controlled by a PIC I/O pin Sample Analog test driver (

September, 2007ENGR Sample Program Written in C, using CCS-C compiler Read the IR detector output –Approx V, 10 bit resolution Use digitized IR output to modulate a PWM signal Use the PWM to drive an H-Bridge connected a motor Ref: Tom Pike’s demo program

September, 2007ENGR // This program reads the input from the IR sensor on pin A0 and puts the // value on the PWM ports to vary the motor speed. It also sends the value to // the serial port. #include #device adc=10;//Set ADC to 10 bit #fuses HS,NOWDT,NOPROTECT,NOBROWNOUT,NOPUT //Configuration Fuses #use delay(clock= ) //20Mhz Clock for wait functions #use rs232(baud=9600,xmit=PIN_c6,rcv=PIN_C7,PARITY=N,BITS=8)//set up RS-232 #org 0x1F00,0x1FFF{}//Reserve Memory for Bootloader long ADC_Result;//unsigned 16 bit number to hold ADC result void main() { puts("PIC16F877 - ADC Test\r\n");//Print a message to serial port. setup_adc_ports(ANALOG_RA3_REF);//all analog with Vref on pin AN3 setup_adc(ADC_CLOCK_DIV_32);//Set ADC conversion clock speed. set_adc_channel(0);//set ADC channel to port 0 (pin 2, AN0). setup_ccp1(CCP_PWM);//Set up PWM on CCP1. setup_ccp2(CCP_PWM);//Set up PWM on CCP2. setup_timer_2(T2_DIV_BY_4,254,10);//set up Timer2 for 4901Hz PWM Period … set_pwm1_duty(0);//Start with duty cycle of 0%. set_pwm2_duty(0);//Start with duty cycle of 0%. output_high(pin_D1);//set direction for motor1. output_high(pin_D2);//set direction for motor2. while (true) { ADC_Result = read_ADC(); set_pwm1_duty(ADC_Result);//Vary motor speed with ADC result. set_pwm2_duty(ADC_Result);//Vary motor speed with ADC result. printf("ADC = %4Lu\r",ADC_Result);//Send adc result to serial port. delay_ms(200); }

September, 2007ENGR Headers #include // Tell Compiler that we’re using This PIC // #device adc=10; //Set ADC to 10 bit // #fuses HS,NOWDT,NOPROTECT,NOBROWNOUT,NOPUT //Configure Fuses: // HS: Using High Speed Crystal/Resonator for clock // NOWDT: No watchdog timeout // NOPROTECT: no code protection from illegal copying // NOBROWNOUT: no low VDD protection // NOPUT: No Power Up Timer (72ms delay)

September, 2007ENGR Configuration … #use delay(clock= ) //20Mhz Clock for wait functions // #use rs232(baud=9600,xmit=PIN_c6,rcv=PIN_C7,PARITY=N,BITS=8) // set up RS-232 // For communicating with HyperTerminal from the PC // #org 0x1F00,0x1FFF{} // Reserve Memory for Bootloader // For in-circuit programming // long ADC_Result; // unsigned 16 bit number to hold ADC Result //

September, 2007ENGR Setup ADC void main() { puts("PIC16F877 - ADC Test\r\n"); // Print a message to serial port. setup_adc_ports(ANALOG_RA3_REF); // all analog with Vref on pin RA3 // use voltage divider to put 2.5V for full scale setup_adc(ADC_CLOCK_DIV_32); //Set ADC conversion clock speed // TAD (per bit) = 1/ 20MHz x 32 = 0.16 microsecond // Requires min. 12 TAD for 10 bit // Min. conversion time approx. 2 microsecond set_adc_channel(0); //set ADC channel to port 0 (pin 2, AN0).

September, 2007ENGR Setup PWM setup_ccp1(CCP_PWM); //Set up PWM output on CCP1. setup_ccp2(CCP_PWM); //Set up PWM output on CCP2. setup_timer_2(T2_DIV_BY_4,254,10); // set up Timer2 for 4921Hz PWM Period // T2 clock speed = 20 MHz / 4 / 4, period = 0.05 x 16 = 0.8 µsec // 254 x 0.8µsec = msec, or KHz // the duty cycle will change every msec x 10 = 2.03 msec

September, 2007ENGR Initialize PWM set_pwm1_duty(0); //Start with duty cycle of 0% on H-Bridge 1 set_pwm2_duty(0); //Start with duty cycle of 0% on H-Bridge 2 output_high(pin_D1); //set direction for motor1. output_high(pin_D2); //set direction for motor2.

September, 2007ENGR Main Loop while (true) { ADC_Result = read_ADC(); set_pwm1_duty(ADC_Result); set_pwm2_duty(ADC_Result); // Vary speeds of Motors 1 and 2 with ADC result. printf("ADC = %4Lu\r",ADC_Result); // Send ADC result to serial port. delay_ms(200) // do this 5 times per second }

September, 2007ENGR The Demo