XDK API  3.6.0
Documentation
Macros | Functions | Variables
Lem.c File Reference

Lem-Sensor signal sampling. More...

#include "XdkCommonInfo.h"
#include <math.h>
#include "XDK_Lem.h"
#include "BSP_BoardType.h"
#include "FreeRTOS.h"
#include "BCDS_Assert.h"
#include "task.h"
#include "timers.h"
#include "semphr.h"
#include "BCDS_MCU_Timer.h"
#include "BCDS_MCU_Timer_Handle.h"
#include "em_adc.h"
#include "em_dma.h"
#include "em_gpio.h"
#include "BSP_Adc.h"
#include "Mcu_Adc_Handle.h"
#include "Mcu_Adc.h"
#include "AdcCentral.h"
#include "AdcCentralConfig.h"
#include "BSP_LemSensor.h"
+ Include dependency graph for Lem.c:

Macros

#define ADC_BUFFER_SIZE   (ADC_CENTRAL_NO_OF_SAMPLES * NO_OF_CHANNELS_USED)
 
#define BCDS_MODULE_ID   XDK_COMMON_ID_LEMSENSOR
 
#define NO_OF_CHANNELS_USED   UINT32_C(2)
 
#define TIMER_SAMPLING_FREQ   5000UL
 

Functions

static void CalculateRunningRMS (ADC_T adc, uint32_t SamplingFreq, uint16_t *bufferPtr)
 ADC Central callback function which calculates the RMS voltage for the Differential signal from the AD5 & AD6 channels. More...
 
Retcode_T Lem_Disable (void)
 function to Deinitialize lemsensor module. More...
 
Retcode_T Lem_Enable (void)
 function to initialize the ADC, DMA , Board detect pin, Timer required for the LEM sensor sampling & Starts the sampling timer. More...
 
Retcode_T Lem_GetRmsCurrent (float *rmsCurrent)
 function to get the RMS current. More...
 
Retcode_T Lem_GetRmsVoltage (float *rmsvoltage)
 function to get the RMS voltage. More...
 
Retcode_T Lem_Setup (float currentRatedTransformationRatio)
 Initialize the required components and variables of lem sensor module. More...
 

Variables

static float CurrentRatedTransformationRatio = 0.0f
 
static volatile float RMSVoltageSumOfSquares = 0.0f
 
static uint16_t ScanData [ADC_BUFFER_SIZE]
 

Detailed Description

This module handles the LEM sensor features.

This module samples the ADC5 & ADC6 channels and calculates the RMS voltage which is updated on the window period configured by the SAMPLING_WINDOW_CYCLES

Macro Definition Documentation

#define ADC_BUFFER_SIZE   (ADC_CENTRAL_NO_OF_SAMPLES * NO_OF_CHANNELS_USED)
#define BCDS_MODULE_ID   XDK_COMMON_ID_LEMSENSOR
#define NO_OF_CHANNELS_USED   UINT32_C(2)
#define TIMER_SAMPLING_FREQ   5000UL

ADC Signal sampling frequency in Hz

Function Documentation

static void CalculateRunningRMS ( ADC_T  adc,
uint32_t  SamplingFreq,
uint16_t *  bufferPtr 
)
static
Parameters
[out]adchandle not used.
[out]SamplingFreqwhich tells the adc samples collected frequency.
[out]bufferPtrwhich is pointer to the application provided adc buffer which holds adc samples for CH5 & Ch6.

ADC central always provides 256 fixed number of adc samples per channel so the expecting the users to provide the buffer accordingly.

+ Here is the caller graph for this function:

Variable Documentation

float CurrentRatedTransformationRatio = 0.0f
static

Current rated transformation ratio for lem sensor

volatile float RMSVoltageSumOfSquares = 0.0f
static

RMS Voltage on Ch5

uint16_t ScanData[ADC_BUFFER_SIZE]
static

LEM sensor ADC user buffer for CH5


All rights reserved. The use is subject to the XDK SDK EULA by Bosch Connected Devices and Solutions GmbH.
This documentation file has been automatically generated on Thu Mar 14 2019 19:12:41 by doxygen 1.8.8