This shows you the differences between two versions of the page.
|
pm:prj2025:cmoarcas:adrian.ariton [2025/05/21 00:49] adrian.ariton [Software Design] |
pm:prj2025:cmoarcas:adrian.ariton [2025/05/25 22:21] (current) adrian.ariton |
||
|---|---|---|---|
| Line 2: | Line 2: | ||
| ===== Introducere ===== | ===== Introducere ===== | ||
| + | <html><iframe width="560" height="315" src="https://www.youtube.com/embed/TrdBkxlq2JE?si=ej5ocPEVzuya_28Z" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></html> | ||
| + | |||
| + | https://github.com/adrianariton/PMProj | ||
| + | |||
| + | Updated project: | ||
| + | https://youtube.com/shorts/TrdBkxlq2JE?feature=share | ||
| + | |||
| + | Old version: | ||
| + | https://youtube.com/shorts/uZILq4yrm3E?feature=share | ||
| Proiectul **"Bomb Defusal Challenge"** este un joc fizic interactiv inspirat de "Keep Talking and Nobody Explodes". | Proiectul **"Bomb Defusal Challenge"** este un joc fizic interactiv inspirat de "Keep Talking and Nobody Explodes". | ||
| Line 118: | Line 127: | ||
| * (etapa 3) surse şi funcţii implementate | * (etapa 3) surse şi funcţii implementate | ||
| </note> | </note> | ||
| + | |||
| + | === Descriere === | ||
| Deignuit pe Platformio: VSCode. | Deignuit pe Platformio: VSCode. | ||
| Line 129: | Line 140: | ||
| * Arduino.h - pt ft putine lucruri (setup) | * Arduino.h - pt ft putine lucruri (setup) | ||
| + | === Code Snippets === | ||
| Timer loop: | Timer loop: | ||
| Line 271: | Line 283: | ||
| Senzorii de giroscop si temperatura sunt implementati cu drivere programate de mine dupa datasheets. | Senzorii de giroscop si temperatura sunt implementati cu drivere programate de mine dupa datasheets. | ||
| + | |||
| + | E.g. (girocop): | ||
| + | |||
| + | |||
| + | // Calculate B5 value from the datasheet | ||
| + | int32_t computeB5(int32_t UT) { | ||
| + | int32_t X1 = (UT - (int32_t)ac6) * ((int32_t)ac5) >> 15; | ||
| + | int32_t X2 = ((int32_t)mc << 11) / (X1 + (int32_t)md); | ||
| + | return X1 + X2; | ||
| + | } | ||
| + | | ||
| + | float readTemperature() { | ||
| + | int32_t UT = readRawTemperature(); | ||
| + | int32_t B5 = computeB5(UT); | ||
| + | | ||
| + | // Temperature in units of 0.1 deg C | ||
| + | float temp = ((B5 + 8) >> 4); | ||
| + | | ||
| + | // Convert to degrees C | ||
| + | return temp / 10.0; | ||
| + | } | ||
| + | | ||
| + | uint32_t readRawPressure() { | ||
| + | write8(BMP180_CONTROL, BMP180_READPRESSURECMD + (oversampling << 6)); | ||
| + | | ||
| + | // Wait for conversion based on oversampling setting | ||
| + | if (oversampling == BMP180_ULTRALOWPOWER) | ||
| + | delay(5); | ||
| + | else if (oversampling == BMP180_STANDARD) | ||
| + | delay(8); | ||
| + | else if (oversampling == BMP180_HIGHRES) | ||
| + | delay(14); | ||
| + | else | ||
| + | delay(26); | ||
| + | | ||
| + | uint32_t MSB = read8(BMP180_PRESSUREDATA); | ||
| + | uint32_t LSB = read8(BMP180_PRESSUREDATA + 1); | ||
| + | uint32_t XLSB = read8(BMP180_PRESSUREDATA + 2); | ||
| + | | ||
| + | // Combine readings with proper shifting based on oversampling | ||
| + | uint32_t raw = ((MSB << 16) + (LSB << 8) + XLSB) >> (8 - oversampling); | ||
| + | return raw; | ||
| + | } | ||
| + | | ||
| + | int32_t readPressure() { | ||
| + | // Read raw temperature value first | ||
| + | int32_t UT = readRawTemperature(); | ||
| + | // Then read raw pressure value | ||
| + | int32_t UP = readRawPressure(); | ||
| + | | ||
| + | // Temperature compensation | ||
| + | int32_t B5 = computeB5(UT); | ||
| + | | ||
| + | // Do pressure calculations (straight from Adafruit code) | ||
| + | int32_t B6 = B5 - 4000; | ||
| + | int32_t X1 = ((int32_t)b2 * ((B6 * B6) >> 12)) >> 11; | ||
| + | int32_t X2 = ((int32_t)ac2 * B6) >> 11; | ||
| + | int32_t X3 = X1 + X2; | ||
| + | int32_t B3 = ((((int32_t)ac1 * 4 + X3) << oversampling) + 2) / 4; | ||
| + | | ||
| + | X1 = ((int32_t)ac3 * B6) >> 13; | ||
| + | X2 = ((int32_t)b1 * ((B6 * B6) >> 12)) >> 16; | ||
| + | X3 = ((X1 + X2) + 2) >> 2; | ||
| + | uint32_t B4 = ((uint32_t)ac4 * (uint32_t)(X3 + 32768)) >> 15; | ||
| + | uint32_t B7 = ((uint32_t)UP - B3) * (uint32_t)(50000UL >> oversampling); | ||
| + | | ||
| + | int32_t p; | ||
| + | if (B7 < 0x80000000) { | ||
| + | p = (B7 * 2) / B4; | ||
| + | } else { | ||
| + | p = (B7 / B4) * 2; | ||
| + | } | ||
| + | | ||
| + | X1 = (p >> 8) * (p >> 8); | ||
| + | X1 = (X1 * 3038) >> 16; | ||
| + | X2 = (-7357 * p) >> 16; | ||
| + | p = p + ((X1 + X2 + (int32_t)3791) >> 4); | ||
| + | | ||
| + | return p; // Pressure in Pa | ||
| + | } | ||
| + | | ||
| + | // Calculate altitude based on atmospheric pressure | ||
| + | float readAltitude(float seaLevelPressure) { | ||
| + | float pressure = readPressure(); | ||
| + | float altitude = 44330 * (1.0 - pow(pressure / seaLevelPressure, 0.1903)); | ||
| + | return altitude; | ||
| + | } | ||
| + | |||
| + | |||
| + | == Dificultati: == | ||
| + | |||
| + | * am setat frecventa la ceasul de transmisie i2c mai jos pt a compensa rezistentele de pullup puse in paralel | ||
| Line 279: | Line 383: | ||
| Care au fost rezultatele obţinute în urma realizării proiectului vostru. | Care au fost rezultatele obţinute în urma realizării proiectului vostru. | ||
| </note> | </note> | ||
| + | |||
| + | * Jocuri calibrabile si modificabile | ||
| + | |||
| + | * Un workflow nedependent de main loop | ||
| ===== Concluzii ===== | ===== Concluzii ===== | ||
| Line 290: | Line 398: | ||
| </note> | </note> | ||
| + | |||
| + | https://github.com/adrianariton/PMProj | ||
| ===== Jurnal ===== | ===== Jurnal ===== | ||