Top Banner
CSC-2700 – (3) Introduction to Robotics Robotics Research Laboratory Louisiana State University
15

CSC-2700 – (3) Introduction to Robotics

Feb 24, 2016

Download

Documents

karan

CSC-2700 – (3) Introduction to Robotics. Robotics Research Laboratory Louisiana State University. What we learned in last class. Digital Output 8 * 8 LED matrix Techniques for LEDs control on LED matrix Basic I/O operation Define pins on PORTas either input or output ( DDRx ) - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: CSC-2700 – (3)  Introduction to Robotics

CSC-2700 – (3) Introduction to Robotics

Robotics Research LaboratoryLouisiana State University

Page 2: CSC-2700 – (3)  Introduction to Robotics

Digital Output◦ 8 * 8 LED matrix◦ Techniques for LEDs control on LED matrix

Basic I/O operation ◦ Define pins on PORTas either input or output (DDRx)◦ Output control ( PORTx)◦ Input read (PINx)

Digital input◦ Button◦ Button Flag

What we learned in last class

Page 3: CSC-2700 – (3)  Introduction to Robotics

Ex) bitwise operationsLet’s assume that we add 4 buttons on PINA4 ~ 7 and 4 LEDs on PINA0~3

LED0 PIN0, LED1 1, LED2 2, LED3 3button0 PIN4, button1 PIN5, button2 PIN6,

button3 PIN7

DDRA = 0x0F (0b00001111) : PINA0 ~3= output, PIN4~7 = inputPORTA = 0xF0 (0b11110000) : pull up from PIN4 to 7 for inputPINA = 0xF0 (0b11110000) : initial status of PINA

All LEDs are off, all buttons are releasedIf LED2 is only need to be on PORTA = PORTA | 0x04 ( 0b00000100 )

PINA == 0xF4 ( 0b11110100 )

Then, if only button2 is need to be read PINA & 0x04 ( 0b01000000 ) Button2 released: PINA ( 0b11110100 )

& 0x40 ( 0b01000000 ) 0x40 (0b01000000)

How to read only specific PIN on PORT

Page 4: CSC-2700 – (3)  Introduction to Robotics

Topics for today Pulse-width Modulation

◦ What for◦ How it works◦ Applications ◦ How to make it

Servo Motor Control◦ What is servo motor◦ How it works◦ Set position of servo head

Simple Hexabot◦ Walking◦ Turning◦ Control hexbot

Page 5: CSC-2700 – (3)  Introduction to Robotics

What is it?◦ Controlling power to inertial electrical devices◦ Average voltage and current controlled by turning

switch

What for?◦ Modern electronic power switches◦ The main advantage of PWM is that power loss in

the switching devices is very low◦ Relatively low cost

Pulse-width Modulation

Page 6: CSC-2700 – (3)  Introduction to Robotics

Applications◦ Fans

◦ Pumps

◦ Robotic Servo

◦ Stepper Motor

◦ Telecommunication

Pulse-width Modulation

Page 7: CSC-2700 – (3)  Introduction to Robotics

How to make it?◦ Digital Out (PINx)◦ Special Function I/O Regiser (SFR/SFIOR)

◦ Using a main program ns_spin( int delay_time ) ; TOGGLE_PIN(PINxx)

◦ Using interrupts Timers PORTB – PINB5 (OCA1), PINB6 (OC1B), PINB7 (OC2) PORTE – PINE3 (OC3C), PINE4 (OC3B), PINE5 (OC3A)

Pulse-width Modulation

Page 8: CSC-2700 – (3)  Introduction to Robotics

How to set position of servo head◦ /home/csc2700/csc2700/10-PWM-dimLight-01

Power Control (LED brightness)

ICR3 = 40000u; // input capture register// pulse cycle (every 40 milli-second)

TCNT3 = 0; // interrupt flag register// Set the WGM mode & prescalarTCCR3A = ( 1 << WGM31 ) | ( 0 << WGM30 ) | // timer control register

( 1 << COM3A1 ) | ( 1 << COM3B1 ) | ( 1 << COM3C1 );TCCR3B = ( 1 << WGM33 ) | ( 1 << WGM32 ) | // timer control register

TIMER3_CLOCK_SEL_DIV_8;DDRE |= (( 1 << 3 ) | ( 1 << 4 ) | ( 1 << 5 )); // I/O control register

uint16_t count = 0;while (1){

OCR3A = count++; // 0 ~ 65535 (pulse width), PINE3 us_spin(200);

}

Page 9: CSC-2700 – (3)  Introduction to Robotics

What is it?◦ Robotic Arms, RC-Airplane, etc.◦ Mechanical position change

How does it work?◦ Position Reader (Potentiometer)◦ DC-Motor◦ PWM DC-Motor Controller◦ Body Frame◦ Gears◦ Servo Head

Servo Motor Control

Page 10: CSC-2700 – (3)  Introduction to Robotics

How to set position of a servo head◦ /home/csc2700/csc2700/10-PWM-Servo-01

Servo Motor Control

int count = 0;while (1){ switch (count++ % 4){ case(0): OCR3A = 1000; break; // OCR3A is PINE3 , 1000 is 1ms == left (0 degree) case(1): OCR3A = 3000; break; // OCR3A is PINE3 , 3000 is 3ms == middle (90 degree) case(2): OCR3A = 5000; break; // OCR3A is PINE3 , 5000 is 5ms == right (180 degree) case(3): OCR3A = 3000; break; // OCR3A is PINE3 } ms_spin(1000);}

Page 11: CSC-2700 – (3)  Introduction to Robotics

Let’s make a servo move likes windshield wiper

Page 12: CSC-2700 – (3)  Introduction to Robotics

How to make it◦ ATmega128 Stamp Board◦ Three servo motors◦ 3 wires (18 or 19 gauge, 12’ * 3)◦ Battery (V 5.0)

Simple Hexabot

Page 13: CSC-2700 – (3)  Introduction to Robotics

Let’s make it walk◦ /home/csc2700/csc2700/10-PWM-HexaBot-01/

Simple Hexabot

int count = 0;while (1){ LED_OFF(COL0_3x3);LED_OFF(COL1_3x3);LED_OFF(COL2_3x3); switch (count++ % 4){ case(0): SetPWM( PWM_PINE3, RIGHT_FRONT); SetPWM( PWM_PINE4, LEFT_BACK); SetPWM( PWM_PINE5, MID_RIGHT); break; case(1): SetPWM( PWM_PINE3, RIGHT_BACK); SetPWM( PWM_PINE4, LEFT_FRONT); SetPWM( PWM_PINE5, MID_RIGHT); break; case(2): SetPWM( PWM_PINE3, RIGHT_BACK); SetPWM( PWM_PINE4, LEFT_FRONT); SetPWM( PWM_PINE5, MID_LEFT); break; case(3): SetPWM( PWM_PINE3, RIGHT_FRONT); SetPWM( PWM_PINE4, LEFT_BACK); SetPWM( PWM_PINE5, MID_LEFT); break; } ms_spin(100);}

void SetPWM( uint8_t pwmNum, uint16_t pulseWidthUSec ){uint16_t pulseWidthTicks = pulseWidthUSec * 2; // Convert to ticks;switch ( pwmNum ){

case PWM_PINE3: OCR3A = pulseWidthTicks; break;case PWM_PINE4: OCR3B = pulseWidthTicks; break;case PWM_PINE5: OCR3C = pulseWidthTicks; break;

}} // SetPWM

#define PWM_PINE3 0#define PWM_PINE4 1#define PWM_PINE5 2

#define MID_RIGHT 1300#define MID_LEFT 1700#define RIGHT_FRONT 1700#define RIGHT_BACK 1300#define LEFT_FRONT 1300#define LEFT_BACK 1700

Page 14: CSC-2700 – (3)  Introduction to Robotics

What is a motion in robotics?◦ Sequence of specific poses with duration ㄴ

What motions the simple hexabot can take?◦ Forward◦ Backward◦ Left turn◦ Right turn◦ ???

Motion planning of simple hexabot

Page 15: CSC-2700 – (3)  Introduction to Robotics

Create a LED brightness control program, which has a plus button and a minus button◦ The plus button is for increasing brightness of LEDs◦ The minus button is for decreasing brightness of LEDs

(bonus) make a simple hexabot control program using 4 buttons◦ Forward button, backward button, left turn button right

turn button

Homework-5