Skip to content

The algorithm is designed for sensor data processing, employing various combining techniques for robust VLC communication.

License

Notifications You must be signed in to change notification settings

zamaex96/Aqua-sense

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Libraries and Constants

  • Libraries: Includes the necessary libraries for the HTS221 sensor and standard C++ algorithms.
  • Constants: Defines pin assignments (sensorPin1, sensorPin2, sensorPin3), LED pin (LED), and threshold values (HB, SB, EP).
  • Global Variables: Initializes variables for sensor readings (v_R1, v_R2, v_R3), thresholds (Th_voltages, Th_voltage), and communication parameters.

Setup Function (setup())

  • Begins serial communication and initializes the HTS221 temperature and humidity sensor.
  • Halts program execution with an error message if sensor initialization fails.

Loop Function (loop())

  • Calls DiversityGainEngineInit() repeatedly to initiate the diversity gain engine process.

Diversity Gain Engine (DiversityGainEngineInit())

  • Iterates through a loop (BITLENGTH times) to read sensor values (v_R1, v_R2, v_R3) and estimate threshold voltages (Th_voltages) using ThresholdVoltageEstimator().
  • Calculates an average threshold voltage (Th_voltage) from the collected data.
  • Calls CombiningTEchniqueSelection() to determine and execute a combining technique (EGC, MLC, or SC) based on the highest detected signal strength.

Threshold Voltage Estimation (ThresholdVoltageEstimator())

  • Determines the maximum value among three sensor readings (v1, v2, v3) to estimate the threshold voltage.

Combining Technique Selection (CombiningTEchniqueSelection())

  • Evaluates the effectiveness of different combining techniques (EGC, MLC, SC) based on sensor readings.
  • Selects the technique with the highest signal strength (CT_ID_EGC, CT_ID_MLC, CT_ID_SC) and calls the corresponding function (EGC_machine(), MLC_machine(), SC_machine()).

Communication and Machine Functions

  • EGC Machine (EGC_machine()): Implements error correction and detection using the EGC (Exclusive-OR Gate Combination) technique.
  • MLC Machine (MLC_machine()): Implements majority logic combining technique.
  • SC Machine (SC_machine()): Implements selection combining technique.
  • Data Processing: Each machine function processes sensor data to determine communication modes and handles data transmission.

Utility Functions

  • Write Byte (writeByte()): Converts a decimal value to binary and sends it bit-by-bit to output pins.
  • Pulse Mapping (PulseMapping()): Controls LED to indicate data transmission status based on temperature data.

Supporting Functions

  • EGC_Engine(), MLC_Engine(), SC_Engine(): Functions implementing respective combining techniques with different bit processing logic.
  • inRange(): Checks if a value falls within a specified range.

Overall Purpose

  • The sketch is designed for sensor data processing, employing various combining techniques for robust communication.
  • It likely serves as part of a larger system for data transmission or control in an embedded environment like Arduino.
  • Modifications can be made to tailor the code to specific application requirements.
  • Application Context: Designed for robust sensor data processing and communication in an Arduino, stm32 or any other environment.
  • Functionality: Implements diverse combining techniques (EGC, MLC, SC) to ensure reliable data transmission or control.
  • Feedback: Provides visual feedback through an LED to indicate transmission status based on temperature data.

STM32 Diversity Gain Engine Communication: Implementation Process

Purpose and Overview

This code implements a sophisticated signal processing system on an STM32 microcontroller, designed to optimize signal reception and communication through advanced combining techniques.

Step-by-Step Implementation Process

1. System Initialization πŸ–₯️

void SystemInit() {
    HAL_Init();
    SystemClock_Config();
    MX_GPIO_Init();
    MX_ADC1_Init();
    MX_USART2_UART_Init();
}

Key Actions:

  • Initialize Hardware Abstraction Layer (HAL)
  • Configure system clock
  • Set up GPIO pins
  • Initialize Analog-to-Digital Converter (ADC)
  • Configure UART communication

2. ADC Configuration πŸ“Š

static void MX_ADC1_Init(void) {
    hadc1.Init.Resolution = ADC_RESOLUTION_12B;
    hadc1.Init.NbrOfConversion = 3;
    // Additional configuration parameters
}

Configuration Details:

  • 12-bit resolution for precise measurements
  • 3 channels for multi-sensor input
  • Non-continuous conversion mode
  • Configures clock prescaler and data alignment

3. Threshold Voltage Estimation πŸ”

uint16_t ThresholdVoltageEstimator(uint16_t v1, uint16_t v2, uint16_t v3) {
    return std::max({v1, v2, v3});
}

Purpose:

  • Selects the maximum voltage from three sensor inputs
  • Determines signal strength and quality
  • Provides a basis for subsequent processing

4. Diversity Gain Engine Initialization πŸš€

void DiversityGainEngineInit() {
    for(int j = 0; j < BITLENGTH; j++) {
        // Trigger ADC conversions
        // Calculate threshold voltages
    }
    
    // Compute average threshold voltage
    Th_voltage = (/* sum of threshold voltages */) / 8;
    
    CombiningTechniqueSelection();
}

Main Responsibilities:

  • Perform multiple ADC conversions
  • Calculate threshold voltages for different bit lengths
  • Compute average threshold voltage
  • Initiate combining technique selection

5. Combining Technique Selection πŸ”€

void CombiningTechniqueSelection() {
    for (uint8_t j = 0; j < BITLENGTH; j++) {
        CT_ID_EGC = EGC_Engine(v_R1, v_R2, v_R3, HIGH, j);
        CT_ID_MLC = MLC_Engine(v_R1, v_R2, v_R3, HIGH, j);
        CT_ID_SC = SC_Engine(v_R1, v_R2, v_R3, j);
    }
}

Combining Techniques:

  1. EGC (Equal Gain Combining)
  2. MLC (Maximum Likelihood Combining)
  3. SC (Selection Combining)

6. Signal Transmission πŸ“‘

void writeByte(char decimal) {
    for(int i = 0; i < BITLENGTH; i++) {
        // Convert decimal to binary
        // Transmit bits via GPIO
    }
}

Transmission Process:

  • Convert decimal to binary representation
  • Use GPIO pins to represent binary states
  • Implement bit-level transmission

7. Continuous Operation ♾️

int main(void) {
    SystemInit();
    
    while(1) {
        DiversityGainEngineInit();
        HAL_Delay(500);
    }
}

Operation Flow:

  • Continuous initialization of Diversity Gain Engine
  • 500ms delay between iterations

Potential Applications 🌐

  • Wireless communication systems
  • Signal processing in noisy environments
  • Adaptive sensor fusion
  • Advanced communication protocols

Limitations and Considerations ⚠️

  • Placeholder implementations for some engine functions
  • Requires specific STM32 hardware configuration
  • Needs customization for specific use cases

Conclusion 🎯

The code represents a complex signal processing approach, leveraging multiple sensors and advanced combining techniques to potentially improve communication reliability and performance.

gh

Explore More! πŸš€

About

The algorithm is designed for sensor data processing, employing various combining techniques for robust VLC communication.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages