carrera racetrack experiment
play

Carrera Racetrack Experiment Daniel Richter Embedded Operating - PowerPoint PPT Presentation

Carrera Racetrack Experiment Daniel Richter Embedded Operating Systems Operating Systems & Middleware Group Carrera Digital 132 2 Embedded Operating Systems | Lukas Pirl & Daniel Richter | November 15, 2018 Basics lanes (scale


  1. Carrera Racetrack Experiment Daniel Richter Embedded Operating Systems Operating Systems & Middleware Group

  2. Carrera Digital 132 2 Embedded Operating Systems | Lukas Pirl & Daniel Richter | November 15, 2018

  3. Basics ▪ lanes (scale 1:24) ▪ car models (scale 1:32) ▪ central control station ▪ Control Unit ▪ Black Box ▪ handset control (cable/wireless) ▪ set the speed ▪ turn the light on/off ▪ change the lane 3 Embedded Operating Systems | Lukas Pirl & Daniel Richter | November 15, 2018

  4. Control Unit & Controllers 4 Embedded Operating Systems | Lukas Pirl & Daniel Richter | November 15, 2018

  5. Our T ask: Change of Control Actuators Control Unit/ Handset Control Board Black Box USB Sensors Race Track PC (Lane Sensor) Sensor Position Sensor Position Sensor Management Position Sensor USB Board Anti-Collision S. Position Sensor Position Sensor 5 Embedded Operating Systems | Lukas Pirl & Daniel Richter | November 15, 2018

  6. Designing Hardware Change of Control: Part 1 6 Embedded Operating Systems | Lukas Pirl & Daniel Richter | November 15, 2018

  7. Emulation of Handset Controls Data Format & Block Diagram 7 Embedded Operating Systems | Lukas Pirl & Daniel Richter | November 15, 2018

  8. Emulation of Handset Controls Printed Circuit Board 8 8 Embedded Operating Systems | Lukas Pirl & Daniel Richter | November 15, 2018

  9. Emulation of Handset Controls Linearity of D-A-Converters 9 Embedded Operating Systems | Lukas Pirl & Daniel Richter | November 15, 2018

  10. Sensors Position Sensors ▪ detect the pulsed identification signal of each car ▪ photo sensors 10 Embedded Operating Systems | Lukas Pirl & Daniel Richter | November 15, 2018

  11. Sensors Position Sensors 11 Embedded Operating Systems | Lukas Pirl & Daniel Richter | November 15, 2018

  12. Sensors Anti-collision Sensors ▪ deactivates the lane change if another car is within the security region at the other lane ▪ at each switch point 12 Embedded Operating Systems | Lukas Pirl & Daniel Richter | November 15, 2018

  13. Sensors Lane Sensor ▪ detect the Manchester encoded control signal at the lane ▪ generated by the Control Unit or Black Box 13 Embedded Operating Systems | Lukas Pirl & Daniel Richter | November 15, 2018

  14. Sensors Sensor Management Board 14 Embedded Operating Systems | Lukas Pirl & Daniel Richter | November 15, 2018

  15. Sensors Car ID Signal Timing 15 Embedded Operating Systems | Lukas Pirl & Daniel Richter | November 15, 2018

  16. Sensors Lane Signal Timing 16 Embedded Operating Systems | Lukas Pirl & Daniel Richter | November 15, 2018

  17. Writing Firmware for Microcontrollers Change of Control: Part 2 17 Embedded Operating Systems | Lukas Pirl & Daniel Richter | November 15, 2018

  18. AVR XMEGA A3 Microcontroller + Sensor Management Board An Electrical Engineer’s View ▪ 8/16-bit AVR XMEGA A3 microcontroller [XMEGA A [MANUAL] 3 8077I – AVR – 11/2012] 18 Embedded Operating Systems | Lukas Pirl & Daniel Richter | November 15, 2018

  19. AVR XMEGA A3 Microcontroller + Sensor Management Board A Software Engineer’s View Concept: ▪ Ports & Pins ▪ port A…F: 8 pins ▪ port R: 2 pins [AVRxmegaA3 Datasheet 8068U – AVR – 06/2013] 19 Embedded Operating Systems | Lukas Pirl & Daniel Richter | November 15, 2018

  20. AVR XMEGA A3 Microcontroller + Sensor Management Board Hello World Microcontroller 20 Embedded Operating Systems | Lukas Pirl & Daniel Richter | November 15, 2018

  21. Hello World (Debug Pins) Scenario ▪ board has 4 pins for debug purposes ▪ turn one pin on and off ▪ oscilloscope output: Debug Pin 3 Debug Pin 2 Debug Pin 1 Debug Pin 0 21 Embedded Operating Systems | Lukas Pirl & Daniel Richter | November 15, 2018

  22. Hello World (Debug Pins) Ports & Pins – Debug Pins 22 Embedded Operating Systems | Lukas Pirl & Daniel Richter | November 15, 2018

  23. Hello World (Debug Pins) Preparation ▪ Atmel Studio 6 (uses Microsoft Visual Studio 2012 Shell) ▪ create project “User Board XMEGA A”, device “ATXmega128A3” 23 Embedded Operating Systems | Lukas Pirl & Daniel Richter | November 15, 2018

  24. Hello World (Debug Pins) Approach Approach : ▪ memory mapped IO ▪ ports, port configuration, etc = registers (8 bit) ▪ debug pins: port B, pins 4..7 1. define pins as output ▪ DIR – Data Direction register 2. write to data out register ▪ OUT – Data Output Value register 24 Embedded Operating Systems | Lukas Pirl & Daniel Richter | November 15, 2018

  25. Hello World (Debug Pins) Port Base Address [XMEGA A [MANUAL] 3 8077I – AVR – 11/2012] 25 Embedded Operating Systems | Lukas Pirl & Daniel Richter | November 15, 2018

  26. Hello World (Debug Pins) Port Register Offsets [XMEGA A [MANUAL] 3 8077I – AVR – 11/2012] 26 Embedded Operating Systems | Lukas Pirl & Daniel Richter | November 15, 2018

  27. Hello World (Debug Pins) Code! #include <asf.h> int main (void) { // define port B’s pins 4..7 as output (*(volatile uint8_t *) 0x0620) |= 0b11110000; while (true) { // turn pin 7 on (*(volatile uint8_t *) 0x0624) |= 0b10000000; // turn pin 7 off (*(volatile uint8_t *) 0x0624) &= ~(0b10000000); } } 27 Embedded Operating Systems | Lukas Pirl & Daniel Richter | November 15, 2018

  28. Hello World (Debug Pins) Simplifications… ▪ iox128a3.h /* PORTB - Port B */ #define PORTB_DIR _SFR_MEM8(0x0620) #define PORTB_DIRSET _SFR_MEM8(0x0621) #define PORTB_DIRCLR _SFR_MEM8(0x0622) #define PORTB_DIRTGL _SFR_MEM8(0x0623) #define PORTB_OUT _SFR_MEM8(0x0624) #define PORTB_OUTSET _SFR_MEM8(0x0625) #define PORTB_OUTCLR _SFR_MEM8(0x0626) #define PORTB_OUTTGL _SFR_MEM8(0x0627) #define PORTB_IN _SFR_MEM8(0x0628) … ▪ sfr_defs.h #define _SFR_MEM8(mem_addr) _MMIO_BYTE(mem_addr) #define _MMIO_BYTE(mem_addr) (*(volatile uint8_t *)(mem_addr)) 28 Embedded Operating Systems | Lukas Pirl & Daniel Richter | November 15, 2018

  29. Hello World (Debug Pins) Code! #include <asf.h> #include <asf.h> int main (void) int main (void) { { // define port B’s pins 4..7 as output // define port B’s pins 4..7 as output PORTB_DIR |= PIN4_bm | PIN5_bm | PIN6_bm | PIN7_bm; (*(volatile uint8_t *) 0x0620) |= 0b11110000; while (true) while (true) { { // turn pin 7 on // turn pin 7 on PORTB_OUT |= PIN7_bm; (*(volatile uint8_t *) 0x0624) |= 0b10000000; // turn pin 7 off // turn pin 7 off PORTB_OUT &= ~(PIN7_bm); (*(volatile uint8_t *) 0x0624) &= ~(0b10000000); } } } } 29 Embedded Operating Systems | Lukas Pirl & Daniel Richter | November 15, 2018

  30. Hello World (Debug Pins) Result!? 30 Embedded Operating Systems | Lukas Pirl & Daniel Richter | November 15, 2018

  31. Hello World (Debug Pins) Meh… ▪ JTAG : IEEE Standard 1149.1-1990 Standard Test Access Port and Boundary-Scan Architecture // disable JTAG interface (uses upper 4 pins of port B) CCP = CCP_IOREG_gc; // Configuration Change Protection MCU_MCUCR = MCU_JTAGD_bm; 31 Embedded Operating Systems | Lukas Pirl & Daniel Richter | November 15, 2018

  32. Hello World (Debug Pins) Result! 32 Embedded Operating Systems | Lukas Pirl & Daniel Richter | November 15, 2018

  33. Hello World (USB) Scenario ▪ manual USB with FTDI chip [Future Technology Devices International Ltd. FT245R USB FIFO IC] 33 Embedded Operating Systems | Lukas Pirl & Daniel Richter | November 15, 2018

  34. Hello World (USB) Code: Writing to USB PORTB_DIR |= PIN0_bm|PIN1_bm; // output (USB RD, USB WR) PORTB_DIR &= ~(PIN2_bm|PIN3_bm); // input (USB RXF, USB TXE) PORTR_DIR &= ~(PIN1_bm); // input (USB PWREN) while (true) { unsigned char data = 255; while (PORTR_IN & PIN1_bm); // wait for PWREN (1=off) while (PORTB_IN & PIN3_bm); // wait for TXE (1=off) PORTA_DIR = 0xFF; // port A as output (USB DATA) PORTB_OUT |= PIN1_bm; // enable WR PORTA_OUT = data; // enable DATA PORTB_OUT &= ~PIN1_bm; // disable WR PORTA_DIR = 0x00; // port A as input } 34 Embedded Operating Systems | Lukas Pirl & Daniel Richter | November 15, 2018

  35. AVR XMEGA A3 Microcontroller + Sensor Management Board Interrupts ▪ per port : ▪ 2 interrupt service routines ▪ interrupt level ▪ per pin : ▪ which ISR ▪ trigger (falling, rising, both edges) ▪ global: ▪ enable/disable all existing interrupts ▪ enable/disable interrupt levels 35 Embedded Operating Systems | Lukas Pirl & Daniel Richter | November 15, 2018

  36. AVR XMEGA A3 Microcontroller + Sensor Management Board Interrupts int main (void) { PORTR_INT0MASK = PIN0_bm; PORTR_INTCTRL |= PORT_INT0LVL_MED_gc; PORTR_PIN0CTRL |= PORT_ISC_FALLING_gc; PMIC_CTRL |= PMIC_HILVLEN_bm | PMIC_MEDLVLEN_bm; sei(); while (true); } ISR (PORTR_INT0_vect) { DBG_OUT(PIN3_bm,0xff); DBG_OUT(PIN3_bm,0x00); } 36 Embedded Operating Systems | Lukas Pirl & Daniel Richter | November 15, 2018

  37. AVR XMEGA A3 Microcontroller + Sensor Management Board Timers ▪ various timers ▪ 16 bit ▪ prescalers for frequency ▪ interrupts ▪ overflow ▪ compare 37 Embedded Operating Systems | Lukas Pirl & Daniel Richter | November 15, 2018

Recommend


More recommend