====== Euromüntide sorteerija ====== ===== Meeskond ===== * Alari Õis * Alvar Pällo * Mihkel Tedremaa * Siim Haas ===== Nädalaaruanded ===== - Nädal 1-2: {{:et:projects:tudengid11:aruanne_myndisorteerija_i.pdf|}} - Nädal 2-4: {{:et:projects:tudengid11:aruanne_myndisorteerija_ii.pdf|}} - Nädal 4-6: {{:et:projects:tudengid11:euromyndid:aruanne3_2.pdf|}} ===== Eesmärk ===== Luua seade, mis suudab eraldada euromünte erinevatesse topsidesse ning kuvab seejärel lcd-le kogusumma. ===== Idee ===== Müntide eraldamiseks otsustasime kasutada eraldusplaate, kus alumisele plaadile on puuritud euromüntide diameetritele vastavad augud ning ülemine plaat veab münte nende aukude kohal. Augud on järjestatud väiksemast suuremaks, selleks et vältida väiksemate müntide kukkumist suurematesse aukudesse. Esimene prototüüp: {{:et:projects:tudengid11:i_ehitatud_prototyyp.jpg|}} ===== Süsteemi üldine mudel ===== {{:et:projects:tudengid11:euromyndid:plokkskeem.png?581x320|}} ===== Algoritmi skeem ===== {{:et:projects:tudengid11:euromyndid:block_diagram.jpg?473x522|}} ===== CADi mudel ===== {{:et:projects:tudengid11:sorteerija_3dmudel.jpg|}} {{:et:projects:tudengid11:euromyndid:uus_sorteerija_drwng.jpg|}} ===== LCD ===== {{:et:projects:tudengid11:euromyndid:lcd.jpg|}} ===== Nädal 4-8: ===== {{:et:projects:tudengid11:euromyndid:sorteerija_ehitus.jpg|}} ===== IR andurite ühendus ja kontrollimine ===== {{:et:projects:tudengid11:euromyndid:led_skeem.jpg|}} ===== Main Kood ===== int main(void) { int8_t press_key_separation[3] = {1, 1, 10}; uint16_t vilguta = 0; uint8_t coins[8]; for(uint8_t i = 0; i < 8; i++) {coins[i] = 0;} DDRB = (1 << PB4)|(1 << PB6); PORTB |= (1 << PB5); TCCR0 = (1 << WGM01)|(1 << CS00)|(1 << COM00); OCR0 = 193; DDRF |= (1 << PF2);//LEDid DDRF &= ~((1 << PF1)|(1 << PF0)); //Lülitid ADCSRA &= ~(1 << ADEN); lcd_gfx_init(); // LCD ekraani algseadistamine lcd_gfx_clear(); // Ekraani puhastamine lcd_gfx_backlight(true); // Taustavalgustuse tööle lülitamine lcd_clear_buffer(BUFFER); lcd_intro(BUFFER); TCCR1B = (1 << WGM13); TCCR1A = (1 << WGM11)|(1 << COM1A0)|(1 << COM1A1)|(1 << COM1B0)|(1 << COM1B1)|(1 << COM1C0)|(1 << COM1C1); OCR1B = 18471; ICR1 = 19820; sei(); ETIMSK |= (1 << TOIE3); TCCR3B &= ~((1 << CS32)|(1 << CS30)); while( !(PINF & ((1 << PF0)|(1 << PF1)))) { lcd_clear_buffer_area(BUFFER, 1, 38, LCD_GFX_X_RES - 2, LCD_GFX_Y_RES - 2); lcd_write_string_to_buffer(BUFFER, LCD_GFX_X_RES/2, 38, "Press any key", LCD_FONT_MIDDLE, circle8(press_key_separation, -2, 5, 4)); lcd_print_frame(BUFFER); } lcd_print_frame(background); while (true) { if(PINF & (1 << PF0)) {TCCR1B &= ~(1 << CS11); vilguta &= ~(1 << 15); PORTF &= ~(1 << PF2); TCCR3B |= ((1 << CS32)|(1 << CS30));} if(PINF & (1 << PF1)) {TCCR1B |= (1 << CS11); vilguta |= (1 << 15); TCCR3B &= ~((1 << CS32)|(1 << CS30)); TCNT3 = 0;} if(vilguta & (1 << 15)) vilguta++; if(vilguta > LEDSAGEDUS + (1 << 15)) { PORTF ^= (1 << PF2); vilguta = (1 << 15); } if(PINB & (1 << PB5)) { lcd_clear_buffer_area(background, 31, 1, 45, 7); if(++coins[0] < 10) lcd_write_char_to_buffer(background, 31, 1, coins[0] + 48); else { lcd_write_char_to_buffer(background, 31, 1, coins[0]/10 + 48); lcd_write_char_to_buffer(background, 38, 1, coins[0]%10 + 48); } lcd_draw_horisontal_line(background, 47 - coins[0], 64, 68); lcd_print_frame(background); _delay_ms(300); } } } ===== Komponentide Nimekiri ===== {{:et:projects:tudengid11:euromyndid:komponentide_nimekiri_2_.jpg|ide_nimekiri_.jpg|}} ===== Kasulikud lingid ja muud materjalid ===== 1. [[http://www.upload.ee/files/1257187/kood.7z.html|Siit leiad kogu koodi]] \\ 2. [[http://www.atmel.com/dyn/resources/prod_documents/doc2467.pdf|ATmega128 Datasheet]] \\ {{youtube>large:zVFhvQGDc4E}}