@@ -1,19 +1,39 | |||
|
1 | #define pinADC 15 | |
|
1 | #include <math.h> | |
|
2 | #define pinADC 12 | |
|
2 | 3 | int analogValue=0; |
|
4 | float Vref=2.45;// Voltaje de referencia para el ADC | |
|
3 | 5 | //int IPP=; |
|
4 | 6 | float Vout=0; |
|
7 | float Plinea=57.6;// Valor entre 1 y 500 kW, las unidades son kW | |
|
8 | float PdBm=0; | |
|
5 | 9 | int VminPot=1;//con esto quiere decir que potencias |
|
6 | float Vref=3.3;// Voltaje de referencia | |
|
10 | bool serialData=0; | |
|
11 | float VoutRef=1; | |
|
7 | 12 | void setup() { |
|
8 | 13 | Serial.begin(115200); |
|
14 | // analogSetAttenuation(ADC_11db); | |
|
15 | if(serialData){ | |
|
16 | Serial.println("Ingrese la potencia en la linea(en kW,debe ser int):"); | |
|
17 | while (!Serial.available()); // Wait for input | |
|
18 | String potLinChar = Serial.readStringUntil('\n'); | |
|
19 | Plinea=atof(potLinChar.c_str()); | |
|
20 | } | |
|
21 | PdBm=10 *(log10(Plinea)-2); | |
|
22 | VoutRef=ecuacionLineal(PdBm); | |
|
23 | Serial.print("Voltaje de salida de referencia: "); | |
|
24 | Serial.println(VoutRef); | |
|
9 | 25 | } |
|
10 | 26 | |
|
11 | 27 | void loop() { |
|
12 | 28 | // put your main code here, to run repeatedly: |
|
13 | 29 | analogValue = analogRead(pinADC); |
|
14 |
Vout = analogValue * |
|
|
15 | Serial.print(Vout); | |
|
16 |
Serial.print( |
|
|
17 | Serial.println(VminPot); | |
|
30 | Vout = analogValue * 3.458 / 4095; | |
|
31 | if(abs(Vout-VoutRef)>0.08 && Vout>1.9 ) { | |
|
32 | Serial.print(Vout); | |
|
33 | } | |
|
18 | 34 | |
|
19 | 35 | } |
|
36 | float ecuacionLineal(float PdBm){ | |
|
37 | float m=-0.02451,b=1.048; | |
|
38 | return Vout=m*PdBm+b; | |
|
39 | } |
General Comments 0
You need to be logged in to leave comments.
Login now