|
|
(4 medziľahlé úpravy od jedného ďalšieho používateľa nie sú zobrazené) |
Riadok 1: |
Riadok 1: |
| Tester logických obvodov 7400 a 7493. Diagnostický report cez sériové rozhranie
| | ToDo |
| | |
| | |
| Záverečný projekt predmetu MIPS / LS2023 - '''Erik Szegi'''
| |
| | |
| | |
| == Zadanie ==
| |
| | |
| Tester logických obvodov- testovali sme, ako rýchlo dokážeme stlačiť tlačidlo po bliknutú kontrolky LED.
| |
| [[Obrázok:ard.jpg|400px|thumb|center|Vývojová doska ACROB.]]
| |
| | |
| '''Literatúra:'''
| |
| * [http://ap.urpi.fei.stuba.sk/sensorwiki/index.php/Acrob_technical_description Dokumentácia k doske Acrob]
| |
| * [http://www.humanbenchmark.com/tests/reactiontime/index.php Vyskúšajte si zmerať reakciu on-line]
| |
| | |
| | |
| __TOC__
| |
| | |
| == Analýza a opis riešenia ==
| |
| | |
| Najprv sme pripojili LCD displej s tlačidlom a LED diódou
| |
| | |
| [[Súbor:schema.png|400px|thumb|center|Schéma zapojenia LCD displeja.]]
| |
| | |
| | |
| === Algoritmus a program ===
| |
| | |
| Algoritmus programu je....
| |
| | |
| | |
| <tabs>
| |
| <tab name="AVR C-code"><source lang="c++" style="background: LightYellow;">
| |
| #include <avr/io.h>
| |
| | |
| #define F_CPU 16000000UL
| |
| #include <avr/io.h>
| |
| #include <avr/interrupt.h>
| |
| #include <util/delay.h>
| |
| #include "lcd_ch.h"
| |
| | |
| #define SW1 PD6 // tlacitko
| |
| #define LED1 PD7 // LED
| |
| | |
| #define set_bit(ADDRESS,BIT) (ADDRESS |= (1<<BIT))
| |
| #define clear_bit(ADDRESS,BIT) (ADDRESS &= ~(1<<BIT))
| |
| | |
| #define LED1_ON set_bit(PORTD,LED1) //zapni LED
| |
| #define LED1_OFF clear_bit(PORTD,LED1) //vypni LED
| |
| | |
| static volatile int M_Sec = 0; //integer pocíta v milisekundách
| |
| int Random_Number = 0; //generuje random cislo
| |
| int Rychlost = 0; //cas rychlost
| |
| | |
| //**spustenie casovaca**//
| |
| void TIMER_START(void){
| |
| TCNT1 = 0xFFF0;
| |
| TCCR1B = 0b00000101;
| |
| TIMSK1 = (1<<TOIE1);
| |
| sei();
| |
| TCCR0A = (1 << COM0A0)
| |
| | (1 << WGM01);
| |
| TCCR0B = (1 << CS02);
| |
| }
| |
| | |
| //** output a input port**//
| |
| void Start(void){
| |
| DDRD =0b10000000;
| |
| PORTD =0b01000000;
| |
| }
| |
| | |
| | |
| int main(void)
| |
| {
| |
| Start();
| |
| ini_ports();
| |
| lcd_init();
| |
|
| |
| while(1){
| |
|
| |
| if(bit_is_set(PIND,LED1)){
| |
| goto jump1;
| |
| }
| |
|
| |
| Random_Number=rand(); //generovanie random cisiel pomocou preddefinovanej funkcie
| |
| _delay_ms(200); //Kvôli rýchlej generovanie čakáme, aby led nebliklo veľmi rýchlo
| |
|
| |
| if ((Random_Number>1) && (Random_Number<1500)){
| |
| PORTD |= (1<<LED1);
| |
| M_Sec=0;
| |
| def_Clear_spec_znaky();
| |
| TIMER_START();
| |
|
| |
| jump1:
| |
| if ( !(PIND & (1<<SW1)) ){ // Ak tlacitko je stlacene tak vypni led
| |
| Rychlost = M_Sec;
| |
| char riadok[]= {""};
| |
| sprintf(riadok,"%d ms",Rychlost);
| |
| def_Clear_spec_znaky();
| |
| lcd_puts("Rychlost:");
| |
| lcd_command(0xC0+5);
| |
| lcd_puts(riadok);
| |
| PORTD &= ~(1<<LED1);
| |
| }
| |
|
| |
| }
| |
| }
| |
| }
| |
| | |
| ISR (TIMER1_OVF_vect)
| |
| {
| |
| char riadok[]= {" "};
| |
| TCNT1 = 0xFFF0;
| |
| M_Sec++;
| |
|
| |
| }
| |
| | |
| </source></tab>
| |
| <tab name="lcd_ch.h"><source lang="c++" style="background: LightYellow;">
| |
| #ifndef F_CPU
| |
| #define F_CPU 16000000UL /* Define CPU frequency here 16MHz */
| |
| #endif
| |
| | |
| #ifndef LCD_CH_H_
| |
| #define LCD_CH_H_
| |
| | |
| #include <avr/io.h>
| |
| #include <util/delay.h>
| |
| | |
| extern unsigned char kon_vyp;
| |
| | |
| #ifdef _Shield_LCD
| |
| #define LCD_CTRL_DDR DDRB
| |
| #define LCD_CTRL_PORT PORTB
| |
| | |
| #define LCD_DATA_DDR DDRD
| |
| #define LCD_DATA_PORT PORTD
| |
| | |
| // Riadiaca zbernica display-a
| |
| #define LCD_RS_pin 0
| |
| //#define LCD_RW_pin = 0
| |
| #define LCD_EN_pin 1
| |
| // Datova zbernica
| |
| #define LCD_D4_pin 4
| |
| #define LCD_D5_pin 5
| |
| #define LCD_D6_pin 6
| |
| #define LCD_D7_pin 7
| |
| | |
| #else
| |
| // LCD klasik yapojenie vid. MIPS
| |
| #define LCD_CTRL_DDR DDRD
| |
| #define LCD_CTRL_PORT PORTD
| |
| | |
| #define LCD_DATA_DDR DDRB
| |
| #define LCD_DATA_PORT PORTB
| |
| #define LCD_DATA_PIN PINB
| |
| | |
| #define LCD_RS_pin 2
| |
| #define LCD_RW_pin 3
| |
| #define LCD_EN_pin 4
| |
| | |
| #define LCD_D4_pin 1
| |
| #define LCD_D5_pin 2
| |
| #define LCD_D6_pin 3
| |
| #define LCD_D7_pin 4
| |
| | |
| #endif
| |
|
| |
| | |
| | |
| | |
| // Oneskorenie 6 SC
| |
| #define NOP() asm("nop")
| |
| #define LCD_DELAY NOP();NOP();NOP();NOP();NOP();NOP();
| |
| | |
| #ifdef _Shield_LCD
| |
| // formatovanie dat
| |
| #define PORT_DATA_WR_H(x) LCD_DATA_PORT &=0b00001111; LCD_DATA_PORT |= (x & 0xF0 )
| |
| #define PORT_DATA_WR_L(x) LCD_DATA_PORT &=0b00001111; LCD_DATA_PORT |= (x & 0x0F )<<4
| |
| #else
| |
| | |
| #define PORT_DATA_WR_H(x) LCD_DATA_PORT &=0b11100001; LCD_DATA_PORT |= (x & 0xF0 )>>3
| |
| #define PORT_DATA_WR_L(x) LCD_DATA_PORT &=0b11100001; LCD_DATA_PORT |= (x & 0x0F )<<1
| |
| | |
| #define PORT_DATA_RD_H ((LCD_DATA_PIN & ((1<<LCD_D4_pin)|(1<<LCD_D5_pin)|(1<<LCD_D6_pin)|(1<<LCD_D7_pin)))<<3)
| |
| #define PORT_DATA_RD_L ((LCD_DATA_PIN & ((1<<LCD_D4_pin)|(1<<LCD_D5_pin)|(1<<LCD_D6_pin)|(1<<LCD_D7_pin)))>>1)
| |
| | |
| | |
| #endif
| |
| | |
| /* Public functions for your use */
| |
| #ifndef _Shield_LCD
| |
| int8_t lcd_read_AC(void);
| |
| void def_spec_znaky_AC(void);
| |
| #endif
| |
|
| |
| void lcd_init(void);
| |
| void lcd_data(unsigned char );
| |
| void lcd_command(unsigned char );
| |
| // void lcd_puts(const char *s); /* deklaracia funkcie */
| |
| | |
| | |
| | |
| void ini_ports(void);
| |
| void En_imp(void);
| |
| | |
| void wr_data (unsigned char );
| |
| unsigned char busy_flag(void);
| |
| | |
| void zob_text(char *);
| |
| void def_Clear_spec_znaky(void);
| |
| | |
| | |
| void def_znak(unsigned char *,unsigned char );
| |
| void def_spec_znaky(void);
| |
| | |
| #endif /* LCD_CH_H_ */
| |
| unsigned int adc_read(char a_pin);
| |
| </source></tab>
| |
| </tabs>
| |
| | |
| Kompletný projekt:
| |
| Zdrojový kód: [[Médiá:MIPS-ErikSzegi-TesterLogickýchObvodov.zip|projekt.zip]]
| |
| | |
| === Overenie ===
| |
| | |
| Na používanie našej aplikácie stačia dve tlačítka a postup používania je opísaný v sekcii popis riešenia.
| |
| Na konci uvádzame fotku záverečnej obrazovky pred resetom. Vypísaný je tu priemerný čas a najlepší čas.
| |
| | |
| [[Súbor:fotka.jpg|400px|thumb|center|Aplikácia.]]
| |
| | |
| '''Video:'''
| |
| <center><youtube>_l02MBu41n0</youtube></center>
| |
| | |
| Kľúčové slová 'Category', ktoré sú na konci stránky nemeňte.
| |
| | |
| [[Category:AVR]] [[Category:MIPS]]
| |