Made a formula for calc speed

This commit is contained in:
Inamr 2024-03-19 12:59:56 +01:00
parent 49c0874445
commit d14044e8df
2 changed files with 30 additions and 4 deletions

View File

@ -4,8 +4,8 @@
* *
* Created on 13. mars 2024, 13:38 * Created on 13. mars 2024, 13:38
*/ */
#include "uart.h"
#include "voltage.h"
#ifndef FANSEEEED_H #ifndef FANSEEEED_H
#define FANSEEEED_H #define FANSEEEED_H
@ -13,8 +13,14 @@
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#include "uart.h"
int speed(uint16_t adcVal); #include <stdbool.h>
#include <float.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <math.h>
int fan_speed(float value);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -1 +1,21 @@
#include "fan speeeed.h"
int fan_speed(float value){
float fan_speed;
float p = 0;
float timelate = 0;
float starttime = 0;
int oldPR = 0;
int curlPR;
int f;
if (curlPr > 300 && oldPr < 300){
starttime = millis();
p =(starttime - timelate);
timelate = startime;
}
oldPR = curlPR;
f = ((1/p)*1000);
fan_speed = (f*60)/2;
return fan_speed;
}