Differences

This shows you the differences between two versions of the page.

Link to this comparison view

pm:prj2025:eradu:alexandru.ionita03 [2025/05/25 20:05]
alexandru.ionita03 [Cod]
pm:prj2025:eradu:alexandru.ionita03 [2025/05/25 20:15] (current)
alexandru.ionita03 [Bibliografie/Resurse]
Line 63: Line 63:
  
 <note warning> ​ <note warning> ​
-#include <​avr/​io.h>​ +#include <​avr/​io.h> ​ \\ 
-#include <​avr/​interrupt.h>​ +#include <​avr/​interrupt.h> ​ \\ 
-#include <​util/​delay.h>​ +#include <​util/​delay.h> ​ \\ 
-#define LED_PIN PB7 +#define LED_PIN PB7  \\ 
-#define BUTTON_PIN PD2 +#define BUTTON_PIN PD2  \\ 
-#define BUZZER_PIN PH4 +#define BUZZER_PIN PH4  \\ 
-void uart_init() { +void uart_init() {  \\ 
-UBRR0H = 0; +UBRR0H = 0;  \\ 
-UBRR0L = 103; +UBRR0L = 103;  \\ 
-UCSR0B = (1 << RXEN0) | (1 << TXEN0); +UCSR0B = (1 << RXEN0) | (1 << TXEN0); ​ \\ 
-UCSR0C = (1 << UCSZ01) | (1 << UCSZ00); +UCSR0C = (1 << UCSZ01) | (1 << UCSZ00); ​ \\ 
-+ \\ 
-void uart_tx(char c) { +void uart_tx(char c) {  \\ 
-while (!(UCSR0A & (1 << UDRE0))); +while (!(UCSR0A & (1 << UDRE0))); ​ \\ 
-UDR0 = c; +UDR0 = c;  \\ 
-+ \\ 
-void uart_print(const char *s) { +void uart_print(const char *s) {  \\ 
-while (*s) uart_tx(*s++);​ +while (*s) uart_tx(*s++); ​ \\ 
-+ \\ 
-volatile uint8_t btn_flag = 0; +volatile uint8_t btn_flag = 0;  \\ 
-ISR(INT0_vect) { btn_flag = 1; } +ISR(INT0_vect) { btn_flag = 1; }  \\ 
-void pwm_init() { +void pwm_init() {  \\ 
-DDRB |= (1 << PB4); +DDRB |= (1 << PB4);  \\ 
-TCCR2A = (1 << COM2A1) | (1 << WGM20); +TCCR2A = (1 << COM2A1) | (1 << WGM20); ​ \\ 
-TCCR2B = (1 << CS21); +TCCR2B = (1 << CS21); ​ \\ 
-OCR2A = 0; +OCR2A = 0;  \\ 
-+ \\ 
-void adc_init() { +void adc_init() {  \\ 
-ADMUX = (1 << REFS0); +ADMUX = (1 << REFS0); ​ \\ 
-ADCSRA = (1 << ADEN) | (1 << ADPS2); +ADCSRA = (1 << ADEN) | (1 << ADPS2); ​ \\ 
-+ \\ 
-uint16_t adc_read(uint8_t ch) { +uint16_t adc_read(uint8_t ch) {  \\ 
-ADMUX = (ADMUX & 0xF0) | (ch & 0x0F); +ADMUX = (ADMUX & 0xF0) | (ch & 0x0F); ​ \\ 
-ADCSRA |= (1 << ADSC); +ADCSRA |= (1 << ADSC); ​ \\ 
-while (ADCSRA & (1 << ADSC)); +while (ADCSRA & (1 << ADSC)); ​ \\ 
-return ADC; +return ADC;  \\ 
-+ \\ 
-void spi_init() { +void spi_init() {  \\ 
-DDRB |= (1 << PB2) | (1 << PB1) | (1 << PB0); +DDRB |= (1 << PB2) | (1 << PB1) | (1 << PB0);  \\ 
-SPCR = (1 << SPE) | (1 << MSTR); +SPCR = (1 << SPE) | (1 << MSTR); ​ \\ 
-PORTB |= (1 << PB0); +PORTB |= (1 << PB0);  \\ 
-+ \\ 
-uint8_t spi_transfer(uint8_t data) { +uint8_t spi_transfer(uint8_t data) {  \\ 
-SPDR = data; +SPDR = data;  \\ 
-while (!(SPSR & (1 << SPIF))); +while (!(SPSR & (1 << SPIF))); ​ \\ 
-return SPDR; +return SPDR;  \\ 
-+ \\ 
-void twi_init() { +void twi_init() {  \\ 
-TWSR = 0; +TWSR = 0;  \\ 
-TWBR = 72; +TWBR = 72;  \\ 
-TWCR = (1 << TWEN); +TWCR = (1 << TWEN); ​ \\ 
-+ \\ 
-void twi_start() { +void twi_start() {  \\ 
-TWCR = (1 << TWINT) | (1 << TWSTA) | (1 << TWEN); +TWCR = (1 << TWINT) | (1 << TWSTA) | (1 << TWEN); ​ \\ 
-while (!(TWCR & (1 << TWINT))); +while (!(TWCR & (1 << TWINT))); ​ \\ 
-+ \\ 
-void twi_stop() { +void twi_stop() {  \\ 
-TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWSTO); +TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWSTO); ​ \\ 
-+ \\ 
-uint8_t twi_write(uint8_t data) { +uint8_t twi_write(uint8_t data) {  \\ 
-TWDR = data; +TWDR = data;  \\ 
-TWCR = (1 << TWINT) | (1 << TWEN); +TWCR = (1 << TWINT) | (1 << TWEN); ​ \\ 
-while (!(TWCR & (1 << TWINT))); +while (!(TWCR & (1 << TWINT))); ​ \\ 
-return (TWSR & 0xF8); +return (TWSR & 0xF8); ​ \\ 
-+ \\ 
-void setup() { +void setup() {  \\ 
-DDRB |= (1 << LED_PIN); +DDRB |= (1 << LED_PIN); ​ \\ 
-DDRH |= (1 << BUZZER_PIN);​ +DDRH |= (1 << BUZZER_PIN); ​ \\ 
-DDRD &= ~(1 << BUTTON_PIN);​ +DDRD &= ~(1 << BUTTON_PIN); ​ \\ 
-PORTD |= (1 << BUTTON_PIN);​ +PORTD |= (1 << BUTTON_PIN); ​ \\ 
-uart_init();​ +uart_init(); ​ \\ 
-EICRA |= (1 << ISC01); +EICRA |= (1 << ISC01); ​ \\ 
-EIMSK |= (1 << INT0); +EIMSK |= (1 << INT0); ​ \\ 
-sei(); +sei(); ​ \\ 
-pwm_init();​ +pwm_init(); ​ \\ 
-adc_init();​ +adc_init(); ​ \\ 
-spi_init();​ +spi_init(); ​ \\ 
-twi_init();​ +twi_init(); ​ \\ 
-uart_print("​Ceas multi-lab\r\n"​);​ +uart_print("​Ceas multi-lab\r\n"​); ​ \\ 
-+ \\ 
-void delay_ms(uint16_t ms) { +void delay_ms(uint16_t ms) {  \\ 
-while(ms--) _delay_ms(1);​ +while(ms--) _delay_ms(1); ​ \\ 
-+ \\ 
-void loop() { +void loop() {  \\ 
-PORTB |= (1 << LED_PIN); +PORTB |= (1 << LED_PIN); ​ \\ 
-delay_ms(300);​ +delay_ms(300); ​ \\ 
-PORTB &= ~(1 << LED_PIN); +PORTB &= ~(1 << LED_PIN); ​ \\ 
-delay_ms(300);​ +delay_ms(300); ​ \\ 
-uart_print("​Salut!\r\n"​);​ +uart_print("​Salut!\r\n"​); ​ \\ 
-if (btn_flag) { +if (btn_flag) {  \\ 
-uart_print("​Buton INT0!\r\n"​);​ +uart_print("​Buton INT0!\r\n"​); ​ \\ 
-PORTH |= (1 << BUZZER_PIN);​ +PORTH |= (1 << BUZZER_PIN); ​ \\ 
-delay_ms(100);​ +delay_ms(100); ​ \\ 
-PORTH &= ~(1 << BUZZER_PIN);​ +PORTH &= ~(1 << BUZZER_PIN); ​ \\ 
-btn_flag = 0; +btn_flag = 0;  \\ 
-+ \\ 
-static uint8_t duty = 0; +static uint8_t duty = 0;  \\ 
-OCR2A = duty; +OCR2A = duty;  \\ 
-duty += 32; +duty += 32;  \\ 
-uint16_t val = adc_read(0);​ +uint16_t val = adc_read(0); ​ \\ 
-char buf[32]; +char buf[32]; ​ \\ 
-float temp = val * (5.0 / 1023.0) * 20; +float temp = val * (5.0 / 1023.0) * 20;  \\ 
-snprintf(buf,​ sizeof(buf),​ "Temp: %.1f C\r\n",​ temp); +snprintf(buf,​ sizeof(buf),​ "Temp: %.1f C\r\n",​ temp); ​ \\ 
-uart_print(buf);​ +uart_print(buf); ​ \\ 
-PORTB &= ~(1 << PB0); +PORTB &= ~(1 << PB0);  \\ 
-uint8_t resp = spi_transfer(0xAA);​ +uint8_t resp = spi_transfer(0xAA); ​ \\ 
-PORTB |= (1 << PB0); +PORTB |= (1 << PB0);  \\ 
-twi_start();​ +twi_start(); ​ \\ 
-uint8_t status = twi_write(0xD0);​ +uint8_t status = twi_write(0xD0); ​ \\ 
-if (status == 0x18) uart_print("​RTC gasit!\r\n"​);​ +if (status == 0x18) uart_print("​RTC gasit!\r\n"​); ​ \\ 
-else uart_print("​RTC lipsa!\r\n"​);​ +else uart_print("​RTC lipsa!\r\n"​); ​ \\ 
-twi_stop();​ +twi_stop(); ​ \\ 
-delay_ms(1000);​ +delay_ms(1000); ​ \\ 
-+ \\ 
-int main(void) { +int main(void) {  \\ 
-setup(); +setup(); ​ \\ 
-while (1) { +while (1) {  \\ 
-loop(); +loop(); ​ \\ 
-+ \\ 
-}+ \\
  
 </​note>​ </​note>​
Line 201: Line 201:
  
 <note tip> <note tip>
-Care au fost rezultatele obţinute în urma realizării proiectului ​vostru.+În urma dezvoltării proiectului ​„Ceas multifuncțional”,​ am obținut următoarele rezultate:​ 
 + 
 +Funcționalitate completă hardware: Toate modulele hardware au fost conectate și testate — ceas RTC, afișaj LCD I2C, display TM1637, buzzer de alarmă, modul radio FM și MP3 player cu amplificator. 
 + 
 +Afișaj ora și dată: Ceasul afișează în timp real ora și data atât pe LCD I2C, cât și pe display-ul TM1637 cu 4 cifre. 
 + 
 +Alarmă sonoră: Sistemul permite programarea unei alarme, care activează buzzer-ul la ora setată și afișează un mesaj pe LCD. 
 + 
 +Redare audio: Am reușit să comut între două surse audio (radio FM sau MP3 player), semnalul fiind amplificat și, opțional, redat pe difuzor. 
 + 
 +Interfață Bluetooth: Utilizatorul poate seta ora alarmei, poate schimba frecvența radio sau melodia de pe MP3 player direct dintr-o aplicație pe telefon, folosind modulul Bluetooth HC-05. 
 + 
 +Cod modular, utilizare registre: Pentru testare și validare, am implementat funcționalitățile atât cu biblioteci, cât și direct pe registre AVR, pentru a ilustra cunoștințele teoretice și practice dobândite la fiecare laborator. 
 + 
 +Testare și prezentare: Proiectul a fost testat pe breadboard și poate fi demonstrat live, atât cu, cât și fără unele componente (ex: difuzor), arătând fluxul semnalului și interacțiunea dintre module.
 </​note>​ </​note>​
  
 ===== Concluzii ===== ===== Concluzii =====
 +
 +Proiectul a validat atât integrarea hardware a componentelor electronice diverse, cât și implementarea software pe platforma Arduino/​AVR,​ acoperind temele principale din laboratoarele de microcontrolere:​ GPIO, UART, întreruperi,​ ADC, PWM, SPI și I2C, precum și comunicarea wireless și interfața cu utilizatorul.
 +
  
  
-===== Jurnal ===== 
  
-<note tip> 
-Puteți avea și o secțiune de jurnal în care să poată urmări asistentul de proiect progresul proiectului. 
-</​note>​ 
  
 ===== Bibliografie/​Resurse ===== ===== Bibliografie/​Resurse =====
  
 +
 +==== Software ====
 <​note>​ <​note>​
-Listă cu documente, datasheet-uri, resurse Internet folosite, eventual grupate pe **Resurse Software** ş**Resurse ​Hardware**.+Arduino Documentation & Tutorials 
 +https://​www.arduino.cc/​en/​Guide/​HomePage 
 + 
 +PlatformIO Documentation 
 +https://​docs.platformio.org/​ 
 + 
 + 
 +Librăria “avr-libc” șmanualul de programare AVR 
 +https://​www.nongnu.org/​avr-libc/​user-manual/​index.html 
 + 
 +</​note>​ 
 +==== Hardware: ==== 
 + 
 + 
 +<​note>​ 
 +ATmega2560 Datasheet 
 +https://​ww1.microchip.com/​downloads/​en/​DeviceDoc/​ATmega2560-Data-Sheet-DS40002211A.pdf 
 + 
 +Optimus Digital – Fise tehnice module 
 + 
 +Modul RTC DS3231 - https://​www.optimusdigital.ro/​ro/​altele/​1102-modul-cu-ceas-in-timp-real-ds3231.html 
 + 
 +Modul MP3 YX5200 - https://​www.optimusdigital.ro/​ro/​audio-altele/​2146-modul-de-redare-mp3-in-miniatura.html 
 + 
 +Modul Radio RDA5807M - https://​www.optimusdigital.ro/​ro/​wireless-radio-fm/​745-modul-radio-fm-rda5807m.html 
 + 
 +Modul Bluetooth HC-05 - https://​www.optimusdigital.ro/​ro/​wireless-bluetooth/​153-modul-bluetooth-master-slave-hc-05-cu-adaptor.html
 </​note>​ </​note>​
  
 <​html><​a class="​media mediafile mf_pdf"​ href="?​do=export_pdf">​Export to PDF</​a></​html>​ <​html><​a class="​media mediafile mf_pdf"​ href="?​do=export_pdf">​Export to PDF</​a></​html>​
  
pm/prj2025/eradu/alexandru.ionita03.1748192733.txt.gz · Last modified: 2025/05/25 20:05 by alexandru.ionita03
CC Attribution-Share Alike 3.0 Unported
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