100 likes | 242 Views
CSC-2700 – (3) Introduction to Robotics. Robotics Research Laboratory Louisiana State University. Midterm Helper - 1. What is the definition of a robot for computer scientist? Give an example for a robot in common household and why
E N D
CSC-2700 – (3) Introduction to Robotics Robotics Research Laboratory Louisiana State University
Midterm Helper - 1 • What is the definition of a robot for computer scientist? • Give an example for a robot in common household and why • Give an example for not a robot in common household and why * * * * Mark are example questions for midterm
Midterm Helper - 2 * What is size of uint8_t? • AVR-C : variable type • AVR-C : condition/Loop uint8_t : 1 Byte 0 ~ 255 uint16_t : 2 Bytes 0 ~ 65535 uint32_t : 4 Bytes 0 ~ 232 - 1 char : 1 Byte int: 2 Byte -32768 ~ 32767 double : 4 Bytes float : 4 Bytes * : pointer char[], int[], double[], … : Array, also multi- dimensional array * What is value range of uint8_t? if ( ) {} if ( ) {} else {} switch () { case: … case: … … } for ( ; ; ) { } while ( ) { } do { } while ()
* Midterm Helper - 3 What does InitHardware do? * Who is providing #include<stdio.h> liblary ? * How to provide your library • AVR-C : basic structure • #include <avr/io.h> a library provided by avrc-compiler • #include “yourLibrary.h” your library • void yourFuctions(void); Declare prototype functions first • int main(){ main of the program • InitHardware(); initialize hardware • while(1) { One main while loop • yourFunction(); call the declared function • } • } • void yourFuction(void){} functions
* Midterm Helper - 4 What happen in LED with below connection? - + * What happen in LED with below connection? • LED (Light Emitting Diode) • 3x3 LED matrix - + * What happen in LED with below connection? - + + + LED ON * What combination of outputs on cols/rows can make only led5 ON? COL1 COL2 COL3 OFF ON OFF ROW1 ON 2 1 3 ROW2 OFF 5 4 6 8 7 9 ROW3 ON
* What is PORT? * Midterm Helper - 5 What is DDRx? * What is PINx? * What is PORTx? • PORT: collection of pins for communication between microprocessor and other devices • PORT control register • PINx : to read the values of the pins in PORTx, • pins: 7 6 5 4 3 2 1 0 0 0 1 1 0 0 0 1 if (PINx == 0x31) ... • PORTx : to assign values to the pins in PORTx, PORTx = 0x31 00110001 PINx = 0x31 is meaningless • DDRx : Controls the Input/Output specification of pins in PORTx (0 intput , 1 output)
* What is value of PORTA for only LED2,3 ON? Midterm Helper - 6 PIN1,2 are high(on) PIN 0,4 are low(off) * Pull-up for input by Microcontroller What is value of DDRA for (Output:pin0 ~ 3) (input: pin 4 ~ 7) ? PIN 0 ~ 3 : Output (LED), PIN 4 ~ 7 : Input (Button) 0 0 0 0 1 1 1 1 DDRA: 0x0F in in in in out outoutout PORTA: 0xF6 1 1 1 1 0 1 1 0 * What is value of PINA If putton3,4 are pressed? 6 7 5 4 3 2 1 0 0 0 1 1 0 1 1 0 PINA : 0x36 (48) - + + - - + + - Pull-down PINA6,7 by Button3,4 pressed Button2 Button4 LED3 LED1 LED4 LED2 Button3 Button1 GND Button 1,2 : Released, Button 3, 4 : Pressed LED 1,4 : OFF , LED 2,3 : ON
Midterm Helper - 7 PWM initialization • PWM control * What does it mean? ICR3 = 40000u; // input capture register TCNT3 = 0; // interrupt flag register // Set the WGM mode & prescalar TCCR3A = ( 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); } * What does it happen when the value of count increase?
Midterm Helper - 8 • MOSFET based H-bridge DC-Motor controller * What does it happen in Motor when the number is increased? #define MOTOR_IN1_PIN 0 #define MOTOR_IN1_MASK (1 << MOTOR_IN1_PIN) #define MOTOR_IN1_DDR DDRF #define MOTOR_IN1_PORT PORTF #define MOTOR_IN2_PIN 1 #define MOTOR_IN2_MASK (1 << MOTOR_IN2_PIN) #define MOTOR_IN2_DDRDDRF #define MOTOR_IN2_PORTPORTF #define MOTOR_STANBY_PIN 1 #define MOTOR_STANBY_MASK (1 << MOTOR_STANBY_PIN) #define MOTOR_STANBY_DDR DDRF #define MOTOR_STANBY_PORT PORTF #define MOTOR_PWM OCR3A • pwm_init(); PWM initialization • DDRF = 0xFF all pins in PORTF are outputs • PORTF = 0x00 pull down for all outputs • MOTOR_PWM = 10000; pwm signal is 10000 • MOTOR_STANBY_PORT |= MOTOR_STANBY_MASK; STBY : high • MOTOR_STANBY_PORT |= (MOTOR_IN1_MASK | MOTOR_IN1_MASK ); • IN1 : high, IN2 : high (Short brake) • MOTOR_STANBY_PORT &= ~ (MOTOR_IN1_MASK | MOTOR_IN1_MASK ); • IN1 : low, IN2 : low (Short brake) • MOTOR_STANBY_PORT |= MOTOR_IN1_MASK; • MOTOR_STANBY_PORT &= ~MOTOR_IN1_MASK; • IN1 : high, IN2 : low (CCW) • MOTOR_STANBY_PORT &= ~MOTOR_IN1_MASK; • MOTOR_STANBY_PORT |= MOTOR_IN1_MASK; • IN1 : low, IN2 : high (CW) * What does it happen in Motor?
If you have any questions,stop by Robotics Research Lab (164 Coates Hall)Monday (Oct, 10) (16:00 ~ 18:00)Tuesday (Oct, 11) ( 10:00 ~ 12:00)