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

CSC-2700 – (3) Introduction to Robotics

Feb 24, 2016

Download

Documents

malise

CSC-2700 – (3) Introduction to Robotics. Robotics Research Laboratory Louisiana State University. What we learned in last class. Diode Zener diode, Avalanche diodes, Photodiode diode Light Emitting Diode Digital Out – pin out control LED ON LED OFF LED TOGGLE LED Matrix - 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

Diode◦ Zener diode, Avalanche diodes, Photodiode

diode◦ Light Emitting Diode

Digital Out – pin out control◦ LED ON◦ LED OFF◦ LED TOGGLE

LED Matrix◦ 3*3 LED matrix◦ 5*7 LED matrix◦ 8*8 LED matrix

What we learned in last class

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

Let make 3 * 3 LED matrix program

COL1 COL2 COL3

ROW1

ROW2

ROW3

ROW1

ROW2

ROW3

COL1 COL2 COL3

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

Make some patterns on LED matrixCOL1 COL2 COL3

ROW1

ROW2

ROW3

ON OFF OFF

OFF

ON

ON

COL1 COL2 COL3

ROW1

ROW2

ROW3

OFF ON OFF

ON

OFF

ON

COL1 COL2 COL3

ROW1

ROW2

ROW3

OFF OFF ON

ON

ON

OFF

1 2 3

4 5 6

7 8 9

1 2 3

4 5 6

7 8 9

1 2 3

4 5 6

7 8 9

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

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

◦ Buzzer (sound) Basic I/O Operation – PORT

Digital input◦ Switch◦ Button◦ Toggle button (Flag)

Topics for today

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

Digital out – 8*8 LED dot Matrix 64 LEDs

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

8 x 8 LED matrix ◦ How many pins are needed for 8x8 LED matrix

control? One LED at each frame

◦ How many frames are required for one picture?◦ What is maximum delay of one frame for one

picture? (25 frames per second) One Column or Row at each frame

◦ How many frames are required for one picture? What are different effects on LED?

Techniques for LED control on LED matrix

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

Tic-Tac noise

Siren

Sound pitch control

Play Song

Buzzer - sound

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

Port Control Registers

Basic I/O Operation - PORT

PORT Control Registers (A ~ G)

DDRxControls the I/O status

of the PORT pins

PORTxControls the output

status of pins

PINxReads the Input status

of pins

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

Defining pins on PORT as either Input or Output

DDRx Register 0 1 1 0 1 1 0 0

PORTx In out out In out out In In

Controls I/O status

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

Defining PORTx as output

PORTx Register 0 1 1 0 1 1 0 0

PORTx out out out out out out out out

Controls I/O status

DDRx Register 1 1 1 1 1 1 1 1

off on on off on on off off

Binary : 0b01101100

Hex: 0x6C

Decimal: 76

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

Defining PORTx as Input

PORTx Register 0 1 1 0 1 1 0 0

PORTx in in in in in in in in

Controls

DDRx Register 0 0 0 0 0 0 0 0vcc

Pull-up for input

0x00

0x6C

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

Read PORTx

PORTx Register 1 1 1 1 1 1 1 1

PORTx in in in in in in in in

Controls

DDRx Register 0 0 0 0 0 0 0 0vcc

PINx Register 0 1 1 0 1 1 0 0

Reads Reads

- + + - + + - -

0x6C

0xFF

0x00

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

PORTx Configuration on a stamp board

PORTD

PORTB

PORTEPORTG

PORTF

PORTA

PORTC

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

PORT setting for input/output◦ Can be configured individually ◦ Ex) PORTA = 0x00 // pins in PORTA are inputs

PORTA = 0xFF // pins in PORTA are outputs PORTA = 0X0F // 0~3 pins are outputs

// 4 ~7 pins are inputs PORTA = 0x08 // only pin3 is a output

Read PORT value (8bit) : 0 ~ 255

Digital input

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

Digital input

6 5 47 3 2 1 0

DDRA: 0x0F in in in in out out out out

PINA : 0x36 (48)- +- -- ++ +

LED4LED2

LED2LED1

Button4Button3 Button1

Button2

Button 1,2 : Released, Button 3, 4 : PressedLED 1,4 : OFF , LED 3,4 : ON

PIN 0 ~ 3 : Output (LED), PIN 4 ~ 7 : Input (Button)

PORTA: 0xF6 1 1 1 1 0 1 1 0

Pull-up for input PIN1,2 are high(on)PIN 0,4 are low(off)

0 0 1 1 0 1 1 0

GND

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

Hexa-decimal Binary Decimal0x0 0b0000 00x1 0b0001 10x2 0b0010 20x3 0b0011 30x4 0b0100 40x5 0b0101 50x6 0b0110 60x7 0b0111 70x8 0b1000 80x9 0b1001 90xA 0b1010 100xB 0b1011 110xC 0b1100 120xD 0b1101 130xE 0b1110 140xF 0b1111 15

0x6C 0b0110 1100 108

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

◦ AND ( & ) : 0 & 0 00 & 1 01 & 0 01 & 1 1

◦ OR ( | ) : 0 | 0 00 | 1 11 | 0 11 | 1 1

◦ XOR (^) : 0 ^ 0 00 ^ 1 11 ^ 0 11 ^ 1 0

◦ Bit Shifts(<< or >> ) : 1 << 3 00001000 (=8)

◦ 40 >> 1 00101000 >> 1

00010100 (=20)

40 >> 5 00000001 (=1)

Bit operations

Page 19: 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 20: CSC-2700 – (3)  Introduction to Robotics

/home/csc2700/csc27000/08-button-led-3x3-01

Let’s make a simple button program

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

Make two buttons, a plus button and a minus button

Whenever the plus button is pushed, a number of LEDs turned on are increased all LEDs are on

Whenever the minus button is pushed, a number of LEDs turned on are decreased until all LEDs are off

Make a simple LED increment program

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

Create an animation player which has two buttons, a play button and a selection button◦ Selection button is for selecting different LED

animations ( at least three LED animations )◦ Play button is for controlling stop/play selected

LED animations

Homework-4