Euromüntide sorteerija

Meeskond

  • Alari Õis
  • Alvar Pällo
  • Mihkel Tedremaa
  • Siim Haas

Nädalaaruanded

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:

Süsteemi üldine mudel

Algoritmi skeem

CADi mudel

LCD

Nädal 4-8:

IR andurite ühendus ja kontrollimine

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

ide_nimekiri_.jpg|

Kasulikud lingid ja muud materjalid

et/projects/tudengid11/euromynt.txt · Last modified: 2020/07/20 09:00 by 127.0.0.1
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0