@@ -1,19 +1,39 | |||||
1 | #define pinADC 15 |
|
1 | #include <math.h> | |
|
2 | #define pinADC 12 | |||
2 | int analogValue=0; |
|
3 | int analogValue=0; | |
|
4 | float Vref=2.45;// Voltaje de referencia para el ADC | |||
3 | //int IPP=; |
|
5 | //int IPP=; | |
4 | float Vout=0; |
|
6 | float Vout=0; | |
|
7 | float Plinea=57.6;// Valor entre 1 y 500 kW, las unidades son kW | |||
|
8 | float PdBm=0; | |||
5 | int VminPot=1;//con esto quiere decir que potencias |
|
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 | void setup() { |
|
12 | void setup() { | |
8 | Serial.begin(115200); |
|
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 | void loop() { |
|
27 | void loop() { | |
12 | // put your main code here, to run repeatedly: |
|
28 | // put your main code here, to run repeatedly: | |
13 | analogValue = analogRead(pinADC); |
|
29 | analogValue = analogRead(pinADC); | |
14 |
Vout = analogValue * |
|
30 | Vout = analogValue * 3.458 / 4095; | |
15 | Serial.print(Vout); |
|
31 | if(abs(Vout-VoutRef)>0.08 && Vout>1.9 ) { | |
16 |
Serial.print( |
|
32 | Serial.print(Vout); | |
17 | Serial.println(VminPot); |
|
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