PPT_MagicGlow.pdf - Workshop on POV LED displays Magic Glow...

This preview shows page 1 out of 113 pages.

Unformatted text preview: Workshop on POV LED displays Magic Glow Introduction to team This man is Sir. Not us. What is Persistence of Vision ? Persistence of vision is a theory that states that the human eye always retains images for a fraction of a second. It therefore suggests that everything we see is a subtle blend of what is happening now and what happened a fraction of a second ago. We don't notice the fractional skips between images because that persistence fills in the momentary gap to make the motion seem seamless. Why 24 frames per second? An afterimage is thought to persist for approximately 0.1 second on the retina. So 24 frames per second is the most optimum Applications Advertisements Single column LCD POV Installing the drivers for Windows 7 Disable driver signature enforcement Switch off the laptop. Start again and keep pressing F8 till you get screen shown below. Select disable driver signature enforcement and press enter. Why disable? Is it safe? Installing the drivers Go to devise manager. Insert the programmer in the USB drive Right click on other devise marked with ! Exclamation mark in yellow background Installing drivers Select update driver software. Select browse my computer for driver software. Click on browse Installing the drivers Go to the location where the Magic Glow software are saved. Select folder marked with usbASP_win-driver Click on OK. Click on NEXT at the bottom of the screen. Installing drivers Wait for it for 1 minuet to install the drivers till you get the following screen. Select second option.: Install this driver software anyway Installing the drivers If you have done the steps properly then you should get this screen in devise manager: Software Instillation WinAVR (install in C: or your master drive// not in program files) 1. copy paste povf.h, povletters.h in c:winavr>>avr>>include • 2. Atmel Studio 4 3. For coding Techno Burner For burning code on the MCU Installing software Step1: Install the latest java JRE version( above 1.7) Step2: Install WinAVR-20100110 (install in C: or your master drive//outside and not in program files) Step3: copy paste povnumbers.h, povletters.h in c:winavr>>avr>>include Step4: Install AvrStudio4 by running AvrStudio4Setup.exe Steps are in the pdf in the software folder by name instructions.pdf If you get any problem feel free to call the instructors. Session 2 Designing the hardware ! Designing the Hardware I. II. Circuit Mechanical assembly Kit contains 1. 2. 3. 4. 5. 6. 7. Inventrom’s POV circuit Board IR emitter CPU fan 9V battery w/t connector Base plate 12V adapter Nut/bolts Important Placements Obtaining perfect balance Component placement on the PCB LEDs on one end in one line w/t min spacing Atmega IC and other components on other end IR emitter Place the receiver on the bottom side of PCB Important Placements IR receiver should be at the bottom side. Mechanical Assembly Fix the Fan on the base Fix the IR emitter and Adapter Battery placement Thumb rule- balance the PCB on the finger to get center of gravity. Place the POV PCB such that IR emitter receiver are in line. Microcontroller A micro-controller (also MCU or µC) is a functional computer system-ona-chip. It contains a processor core, memory and programmable input/output peripherals. Micro suggests that the device is small Controller tells you that the device might be used to control objects, processes or events. E.g: ATmega 8, PIC, ARM etc. I/0 (input/output) Ports : Every microcontroller has I/O ports. Each port is made up of n-pins ( mostly 8 pins). Each pin can be configured as either input pin or output pin. If a pin is input pin, it accepts data from the device it is connected to. If a pin is output pin, it sends the data to the device it is connected to. Thus these pins form the input/output medium for the microcontrollers. ATMEGA 88PA MICROCONTROLLER Manufacturer : ATMEL CORPORATION, USA. ATMEGA 88PA SPECIFICATIONS : 8K Bytes of In-System Self-Programmable Flash 23 Programmable I/O Lines Two 8-bit Timer/Counters with Separate Prescalers and Compare Modes One 16-bit Timer/Counter with Separate Prescaler, Compare Mode, and Capture External and Internal Interrupt Sources PIN CONFIGURATION : ATmega 88PA Microcontroler 1 1 thinks in form of Binary: and 0 means it will give 5V and 0 means Ground or 0v Digital Input Output Port ATmega 88PA has 23 I/O (Input/Output) pins grouped as B, C & D with 8 pins in each group. This group is called as PORT. PB0 - PB7 (PORTB) PC0 - PC7 (PORTC) PD0 - PD7 (PORTD) Registers All the configurations in a microcontroller is set through 8 bit (1 byte) locations in RAM of the microcontroller called as Registers. As Register size of this microcontroller is 8 bit, it called as 8 bit microcontroller. I/O Register Data Direction Register, DDRn Same pin can be used as an input and output Determines the direction of individual pins of ports. DDR is set (1) - output pin DDR is cleared (0) – input pin. Lets try and example: DDRB = 0b11110000; 4 MSB pins of PORTB are output pins 4 LSB pins of PORTB are input pins PORTn Register This is the output register The value on this port is transferred via the physical pin to the outside world DDRB = 0b00000000; //to set as O/P PORTB= 0b11110000; Circuit Designing Atmega88PA 8 LEDs 330ohms resistors 10k pull-up resistor 68ohm resistor for TSOP 38238 Microswitch 7805 voltage regulator 100uf 16V capacitor Berg connectors 2pin JST connectors PCB Session 3 Lets get coding ! Starting a new project Open 1. 2. 3. Atmel Studio 4 Project ->New Project Select AVR GCC-> give Project Name and (by default project Name) Initial file Name. Click Next. Select debug platform –AVR Dragon, Device– Atmega88PA. Finish. Click on new project 1. Select AVR GCC 2. Enter Project Name. 3. Initial File name is same as project name 4. Select location to save the file. (Remember the location) 5. Click on next Select the following: Debug Platform: AVR Dragon First one in order Devise: ATmega88PA Scroll down Click on Finish Linking Compiler 1. Select Project -> Configuration Option 2. Select Custom Option Linking Compiler 1. 2. External tools- untick use avr toolchain Avr-gcc: Click on (…) navigate to C:\WinAVR-20100110\bin 1. 3. Select avr-gcc.exe Make: : Click on (…) navigate to C:\WinAVR-20100110\utils\bin 1. 2. Select make.exe Ok Have to do the above steps for each new project/ every time you open This is how it should look Now click on OK While Loop While(Something is true) { Keep doing this; } Infinite while loop while(1) { Keep doing this; } Do not forget the Glowing an LED Imports #define F_CPU 1000000UL // change to your CPU #include <avr/io.h> frequency PORTB Data Direction Register (DDR) DDRB (for PORT B) 1 output 0 input Code int main(){ DDRB=0b11111111; while(1){ PORTB=0b10000000; } } code #define F_CPU 8000000UL // change to your CPU frequency #include <avr/io.h> int main(){ DDRB=0b11111111; while(1){ PORTB=0b10000000; } } Glowing an LED Save file (ctrl+s) F7 (build) Go to the folder where you saved the project Navigate to default folder Look for .hex file Precautions Very Important Remove battery Insert programmer properly. Check Do for the notch. not run the fan when the programmer is connected. Burning hex file Open Techno Burner Device: POV v1.2 Programmer: usbasp Search Click show Load the hex file by navigating to the project folder. Program Drawing a circle Start the fan :-P Delays Wait until later for doing something Used to set both position and time of LED on/off Need to include a delay header: #include <util/delay.h> (insert after #include <avr/io.h>) Codes to call the delay _delay_us(value); _delay_ms(value); Code with delays int main(){ DDRB=0b11111111; while(1){ PORTB=0b10000000; _delay_ms(500); //put your own PORTB=0b00000000; _delay_ms(500); } } Try it out #define F_CPU 8000000UL #include <avr/io.h> #include <util/delay.h> int main(){ DDRB=0b11111111; while(1){ PORTB=0b10000000; _delay_ms(500); PORTB=0b00000000; _delay_ms(500); } } Self assignment 1 Draw the saw cutter seen in video 2. Draw a simple one. Solution: Saw cutter PORTB=0b00000001; _delay_us(50); PORTB=0b00000011; _delay_us(100); PORTB=0b00000111; _delay_us(150); PORTB=0b00001111; _delay_us(200); PORTB=0b00011111; _delay_us(250); PORTB=0b00111111; _delay_us(300); PORTB=0b01111111; _delay_us(350); PORTB=0b11111111; _delay_us(400); One additional led glows with every step The delay is increasing with every step Lunch Break Making life easy Microsoft Excel Adjust all columns to give all the cells a square shape. Select the area till 8th row and columns till you adjusted as square Click on conditional formatting and select data bars. Enter 1 to draw the shape you want. Enter 0 everywhere else. Using Microsoft Excel Open Excel (windows 7 preffered) Select columns A-S by holding shift and clicking the head. Resize to 19-23 pixels Drag and select cells from A8-S8 Apply>Conditional formatting->Data bars> first option Insert ‘1’ where you want led to glow ‘0’ otherwise(optional to avoid confusion) Using Microsoft Excel From Top to bottom From right to left Try out PORTB=0b01100000; _delay_us(200); PORTB=0b10010000; _delay_us(200); PORTB=0b10001000; _delay_us(200); PORTB=0b01000100; _delay_us(200); PORTB=0b10001000; _delay_us(200); PORTB=0b10010000; _delay_us(200); PORTB=0b01100000; _delay_us(200); Code #define F_CPU 8000000UL // change to your CPU frequency #include <avr/io.h> #include <util/delay.h> int main(){ DDRB=0b11111111; //DDRB=0xFF; in hex while(1){ PORTB=0b01100000; _delay_us(200); PORTB=0b10010000; _delay_us(200); PORTB=0b10001000; _delay_us(200); PORTB=0b01000100; _delay_us(200); PORTB=0b10001000; _delay_us(200); PORTB=0b10010000; _delay_us(200); PORTB=0b01100000; _delay_us(200); } } Code with space #define F_CPU 8000000UL // change to your CPU frequency #include <avr/io.h> #include <util/delay.h> int main(){ DDRB=0b11111111; //DDRB=0xFF; in hex while(1){ PORTB=0b00000000; _delay_us(600); PORTB=0b01100000; _delay_us(200); PORTB=0b10010000; _delay_us(200); PORTB=0b10001000; _delay_us(200); PORTB=0b01000100; _delay_us(200); PORTB=0b10001000; _delay_us(200); PORTB=0b10010000; _delay_us(200); PORTB=0b01100000; _delay_us(200); } } Draw a flower Draw a heart Write the first letter of your name. Tea Break Interrupts Interrupts in Physical World Interrupts The signal to initiate the stopping of the running of one program in order to run another When the signal is removed the original program is continued. Interrupt is given when a special condition is reached. e.g.: Sensor detects an object or wireless data is received. The special code is written in a function called Interrupt Service Routine a.k.a ISR Interrupts in Physical World Interrupts The signal to initiate the stopping of the running of one program in order to run another When the signal is removed the original program is continued. Interrupt is given when a special condition is reached. e.g.: Sensor detects an object or wireless data is received. The special code is written in a function called Interrupt Service Routine a.k.a ISR Why interrupts for POV? Main Function #include<avr/interrupt.h> void main(void) { int main() { EICRA = 0x00; EIMSK = 0x01; // interrupt sources sei(); //re-enable interrupts DDRB=0xFF; //insert your functional code here... while(1) { -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------} } ISR ISR(INT0_vect){ EIMSK=0x00; //external interrupt on INT0 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------EIMSK=0x01; } Enabling Interrupts sei(); ---Global interrupt enable cli(); --- Global interrupt disable Interrupt Main Function int main() { sei(); //Enable interrupts DDRB=0xFF; while(1) { ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------} } Enter this line to enable interrupts in your code. Enter in the main function. External Interrupt Registers • • • • There are two interrupts available for ATmega 8 INT0 and INT1 Mark the bit as 1 to enable. EIMSK=0b00000001; //To enable INT0 Interrupt Main Function int main() { EIMSK = 0b00000001 ;//external interrupt on INT0 sei(); //Enable interrupts DDRB=0xFF; while(1) { ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------} } ISR ISR(INT0_vect){ //external interrupt on INT0 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------} When will this interrupt trigger? The sensor gives 1 under normal condition 1 when receives the modulated(TSOP) IR radiations. Modulated to avoid effect of sunlight. What is low level, High Level, Falling Edge, Rising Edge Interrupt Main Function int main() { EICRA = 0x00; EIMSK = 0x01; // interrupt sources sei(); //Enable interrupts DDRB=0xFF; //insert your functional code here... while(1) { ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------} } ISR ISR(INT0_vect){ //external interupt on INT0 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------} Include #include<avr/interrupt.h> Lets try ! Write a code for the LED to Glow when interrupt is detected Line code ISR(INT0_vect){ PORTB=0b00000001; _delay_us(200); } int main() { EICRA = 0b000000000; EIMSK = 0b00000001; // interrupt sources sei(); //re-enable interrupts DDRB=0b11111111; while(1) { PORTB=0x00; } } LEDs off till it receives interrupt What if interrupt triggers before the code in ISR is completely executed? Adha heart How to prevent? Switch off Interrupts before the start of the ISR and Start again at the end when the full code is executed. Interrupt Main Function int main() { EICRA = 0x00; EIMSK = 0x01; // interrupt sources sei(); //Enable interrupts DDRB=0xFF; //insert your functional code here... while(1) { ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------} } ISR ISR(INT0_vect){ EIMSK=0x00; //external interupt on INT0 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------} EIMSK=0x01; Lets refresh everything Main Function int main() { EICRA = 0x00; EIMSK = 0x01; // interrupt sources sei(); //Enable interrupts DDRB=0xFF; //insert your functional code here... while(1) { ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------} } ISR ISR(INT0_vect){ EIMSK=0x00; //external interupt on INT0 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------} EIMSK=0x01; Line code ISR(INT0_vect){ EIMSK=0x00; //disabled INT0 PORTB=0b11111111; _delay_us(200); EIMSK=0x01; //enabled INT0 } int main() { EICRA = 0x00; EIMSK = 0x01; // interrupt sources sei(); //re-enable interrupts DDRB=0xFF; while(1) { } } PORTB=0x00; LEDs off till it receives interrupt Try out previous codes with interrupt #define F_CPU 8000000UL // change to your CPU frequency #include <avr/io.h> #include <util/delay.h> ISR(INT0_vect){ EIMSK=0x00; PORTB=0b00000000; _delay_us(600); PORTB=0b01100000; _delay_us(200); PORTB=0b10010000; _delay_us(200); PORTB=0b10001000; _delay_us(200); PORTB=0b01000100; _delay_us(200); PORTB=0b10001000; _delay_us(200); PORTB=0b10010000; _delay_us(200); PORTB=0b01100000; _delay_us(200); EIMSK=0x01; } //continued Copy paste the code now in ISR //disabled INT0 //enabled INT0 Try out previous codes with interrupt //continued int main() { EICRA = 0x00; EIMSK = 0x01; sei(); DDRB=0xFF; while(1) { PORTB=0x00; } } // interrupt sources //re-enable interrupts Feeling drunk? Do you see 2 instead of 1? Why this problem? : Double trigger. Include a good delay. Self Assignment 2 Generate patterns Stick man Write your name. End of Day 1 Dancing Stick Man Can some one do this? This was shown in the video 1 Dancing Stick Man Here we generate two different patters one after other. Declare unsigned int count Increment and reset a counter in ISR Count++ If (count>0) {Display patter 1 } If (count >1) {Display patter 2 Count = 0 } POV Super Coder Open the application Write a sentence Write your full name Write : MSU Footprints Rocks Povf.h for numbers printp(value); colon(); Space(); to change delay open the header file Povletters.h for alphabets printl(‘alphabet in caps’); The ‘ ‘ i.e. open inverted comma send the ASCII value of the letter to the function. to change open the header file and replace the delay value Does not work as smoothly as povnumbers.h. Make changes to make it work. Tea Break Timers Timer is an up counter A register whose value goes from 0 to (2^n-1). Where n is the number of bits. The count or register value increments in sync with clock pulse internally generated (Timer) or the source can be an external trigger. (Counter) Applications: Time certain part of code For external sensors like position encoders etc. Counters in ATmega 88PA 8 bit timer/counter 0 with PWM 16 bit timer/counter 1 with PWM 8 bit timer/counter 2 with PWM and asynchronous operation Since we want a 1 sec delay we need to use a 16 bit timer as 8 bit resolution is too small. The PWM frequency for the output can be calculated by the following equation: fPWM= fclk -------------------------------N ⋅ (1 + TOP) The N variable represents the prescaler divider (1, 8, 64, 256, or 1024). Various registers involved TCCR1A – Timer/Counter1 Control Register A TCCR1B – Timer/Counter1 Control Register B Waveform Generation Mode Clock Select Bit Description TCCR1A=0b00000000; TCCR1B=0b00010100; TIMSK1 – Timer/Counter1 Interrupt Mask Register Bit 0 – TOIE1: Timer/Counter1, Overflow Interrupt Enable When this bit is written to one, and the I-flag in the Status Register is set (interrupts globally enabled), the Timer/Counter1 Overflow interrupt is enabled. The corresponding Interrupt Vector is executed when the TOV1 Flag, located in TIFR1, is set. TIMSK1=0b00000001; TIFR1 – Timer/Counter1 Interrupt Flag Register Interrupt Vector for Compare Capture This is an internal software interrupt ISR(TIMER1_CAPT_vect) { } Digital Clock Using 16bit Timers1 #include <povnumber.h> ...
View Full Document

  • Winter '18
  • PATEL SIR
  • Interrupt, Interrupt handler, Programmable Interrupt Controller, Interrupt latency, PPT OF PROJECT,  Persistence

{[ snackBarMessage ]}

Get FREE access by uploading your study materials

Upload your study materials now and get free access to over 25 million documents.

Upload now for FREE access Or pay now for instant access
Christopher Reinemann
"Before using Course Hero my grade was at 78%. By the end of the semester my grade was at 90%. I could not have done it without all the class material I found."
— Christopher R., University of Rhode Island '15, Course Hero Intern

Ask a question for free

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern