55 lines
778 B
C
55 lines
778 B
C
|
|
/*
|
||
|
|
* measure.c
|
||
|
|
*
|
||
|
|
* Created on: Jun 7, 2022
|
||
|
|
* Author: Keith.Lloyd
|
||
|
|
*/
|
||
|
|
|
||
|
|
|
||
|
|
#include "fsl_spi.h"
|
||
|
|
#include "pin_mux.h"
|
||
|
|
#include "board.h"
|
||
|
|
#include "fsl_debug_console.h"
|
||
|
|
|
||
|
|
#include <stdio.h>
|
||
|
|
#include <math.h>
|
||
|
|
#include <stdbool.h>
|
||
|
|
#include <string.h>
|
||
|
|
#include <stdint.h>
|
||
|
|
#include <arm_math.h>
|
||
|
|
#include "measure.h"
|
||
|
|
#include "frq.h"
|
||
|
|
#include "ports.h"
|
||
|
|
#include "adc.h"
|
||
|
|
#include "amps.h"
|
||
|
|
|
||
|
|
extern float32_t Volts;
|
||
|
|
extern float32_t Amps;
|
||
|
|
extern float32_t Ohms;
|
||
|
|
extern float32_t Watts,Max_Power_Limit;
|
||
|
|
extern uint8_t frequency;
|
||
|
|
extern uint8_t Port_State[];
|
||
|
|
extern ADC_t adc;
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
float Calc_Max_current(void)
|
||
|
|
{
|
||
|
|
float a;
|
||
|
|
if(freqArray[frequency].frequency1 <= MAX_DTYPE)
|
||
|
|
a = sqrtf(Max_Power_Limit / adc.Ohms_slowfilt);
|
||
|
|
else
|
||
|
|
a = sqrtf(1/adc.Ohms_slowfilt);
|
||
|
|
|
||
|
|
return(a);
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
|