Metal Detector
 
Loading...
Searching...
No Matches
app_signal.h File Reference

Header file for signal processing and FFT operations. More...

#include <stdint.h>
#include "arm_math.h"

Go to the source code of this file.

Data Structures

struct  SIG_ADCRegister_t
 Structure to hold ADC conversion values from two channels. More...
 
struct  SIG_FreqDomain_t
 Structure representing a complex number in the frequency domain. More...
 
struct  SIG_PolarForm_t
 Structure representing the magnitude and phase of a frequency component. More...
 
struct  SIG_Handle_t
 Handle structure for managing signal processing tasks. More...
 

Macros

#define OUTPUT_SINE_SIGNAL_LEN   10
 Length of the output sine wave signal array.
 
#define OUTPUT_SINE_AUDIO_LEN   100
 Length of the output audio signal array.
 
#define INPUT_BUFF_LEN   2048
 Length of the input buffer for ADC samples.
 
#define BUFF_TO_DFT_LEN   ( INPUT_BUFF_LEN / 2 )
 Number of samples to be used for the FFT (half of the input buffer length).
 
#define FREQ_DOMAIN_LEN   ( BUFF_TO_DFT_LEN / 2 )
 Number of frequency domain bins (quarter of the input buffer length).
 
#define POLAR_FORM_LEN   FREQ_DOMAIN_LEN
 Length of the polar form array (same as frequency domain length).
 
#define ADC_MAX_VALUE   4095
 Maximum value of the ADC output (12-bit resolution).
 
#define REF_VOLTAGE   3.3f
 Reference voltage for the ADC.
 
#define ADC_HALF_COMPLETE_FLAG   0
 Flag indicating that the ADC conversion is complete for the first half of the buffer.
 
#define ADC_FULL_COMPLETE_FLAG   1
 Flag indicating that the ADC conversion is complete for the entire buffer.
 

Typedefs

typedef struct SIG_Handle_t SIG_Handle_t
 Handle structure for managing signal processing tasks.
 

Functions

void sig_start (SIG_Handle_t *const handle)
 Starts the signal processing by initializing ADC and DAC, and starting timers.
 
void sig_load_samples (SIG_Handle_t *const handle, uint8_t flag)
 Loads samples from the ADC buffer into the processing buffers.
 
size_t sig_perform_fft (SIG_Handle_t *const handle)
 Performs FFT on the loaded signal data and computes magnitude and phase.
 

Variables

SIG_Handle_t sig_handle
 

Detailed Description

Header file for signal processing and FFT operations.

This file contains the declarations for functions and data types used in signal processing tasks, including ADC and DAC setup, sample loading, and FFT operations. It defines constants, data structures, and function prototypes for managing and processing signals.

Created on: Jul 5, 2024 Author: Viktor

Function Documentation

◆ sig_load_samples()

void sig_load_samples ( SIG_Handle_t *const handle,
uint8_t flag )

Loads samples from the ADC buffer into the processing buffers.

Parameters
handlePointer to the SIG_Handle_t structure.
flagFlag indicating the ADC conversion status (half or full completion).

Loads samples from the ADC buffer into the processing buffers.

This function copies samples from the input buffer to the processing buffers for further signal analysis. The samples are loaded based on the provided flag.

Parameters
handlePointer to the SIG_Handle_t structure containing the buffers.
flagFlag indicating the completion status of ADC conversion.

◆ sig_perform_fft()

size_t sig_perform_fft ( SIG_Handle_t *const handle)

Performs FFT on the loaded signal data and computes magnitude and phase.

Parameters
handlePointer to the SIG_Handle_t structure.
Returns
Index of the frequency with the maximum magnitude.

Performs FFT on the loaded signal data and computes magnitude and phase.

This function calculates the FFT of the input signals for both the receive and transmit coils. It then computes the magnitude and phase of the frequency domain data and returns the index of the maximum magnitude value.

Parameters
handlePointer to the SIG_Handle_t structure containing the signal data.
Returns
size_t Index of the maximum magnitude value in the frequency domain.

◆ sig_start()

void sig_start ( SIG_Handle_t *const handle)

Starts the signal processing by initializing ADC and DAC, and starting timers.

Parameters
handlePointer to the SIG_Handle_t structure.

Starts the signal processing by initializing ADC and DAC, and starting timers.

This function initializes the ADC and DAC peripherals, starts the ADC conversion in DMA mode, and begins the DAC output with a sine wave signal. It also starts the timer used for signal processing.

Parameters
handlePointer to the SIG_Handle_t structure containing the configuration.

Variable Documentation

◆ sig_handle

SIG_Handle_t sig_handle
extern

Global handle for signal processing