@@ -0,0 +1,9 | |||||
|
1 | void setup() { | |||
|
2 | // put your setup code here, to run once: | |||
|
3 | ||||
|
4 | } | |||
|
5 | ||||
|
6 | void loop() { | |||
|
7 | // put your main code here, to run repeatedly: | |||
|
8 | ||||
|
9 | } |
@@ -9,8 +9,8 bool serialData=1;//Un valor de 1 indica que se debe ingresar por monitor serial | |||||
9 | float VoutRef=1,Pmax; |
|
9 | float VoutRef=1,Pmax; | |
10 | int numSamples=20; |
|
10 | int numSamples=20; | |
11 | int total=0; |
|
11 | int total=0; | |
12 |
int contador=0,SIZE= |
|
12 | int contador=0,SIZE=40; | |
13 |
float *p, Parray[ |
|
13 | float *p, Parray[40]; | |
14 | void setup() { |
|
14 | void setup() { | |
15 | Serial.begin(115200); |
|
15 | Serial.begin(115200); | |
16 | analogSetAttenuation(ADC_11db); |
|
16 | analogSetAttenuation(ADC_11db); | |
@@ -29,7 +29,6 void setup() { | |||||
29 | void loop() { |
|
29 | void loop() { | |
30 | total=0; |
|
30 | total=0; | |
31 | //analogValue = analogRead(pinADC); |
|
31 | //analogValue = analogRead(pinADC); | |
32 | //Hacemos multisampling para asegurar el buen performance |
|
|||
33 | /* |
|
32 | /* | |
34 | for (int i = 0; i < numSamples; i++) { |
|
33 | for (int i = 0; i < numSamples; i++) { | |
35 | total += analogRead(pinADC); |
|
34 | total += analogRead(pinADC); | |
@@ -39,26 +38,36 void loop() { | |||||
39 | Vout = 0.8291*averageValue+90.27;//Ajuste realizado para el ADC |
|
38 | Vout = 0.8291*averageValue+90.27;//Ajuste realizado para el ADC | |
40 | //Serial.println(Vout); |
|
39 | //Serial.println(Vout); | |
41 | Plcal=5*pow((Vout+101),2)/(2*175.19*175.19);//Calculamos la potencia en la línea |
|
40 | Plcal=5*pow((Vout+101),2)/(2*175.19*175.19);//Calculamos la potencia en la línea | |
42 | dif=abs(Plinea-Plcal)*100/Plinea;//Hallamos la diferencia porcentual |
|
41 | //dif=abs(Plinea-Plcal)*100/Plinea;//Hallamos la diferencia porcentual | |
43 | difPlow=abs(Plinea-Plcal); |
|
42 | if (Plcal>3){//valores por debajo de este umbral serán leidos como tierra | |
44 | if(dif>10 && Vout>120){ |
|
|||
45 | Parray[contador]=Plcal; |
|
43 | Parray[contador]=Plcal; | |
46 | contador =contador+1; |
|
44 | contador =contador+1; | |
47 | if(contador==15){ |
|
45 | } | |
|
46 | //cuando llenamos los valores hacemos la | |||
|
47 | if (contador==SIZE){ | |||
48 |
|
|
48 | p=&Parray[0]; | |
49 |
|
|
49 | Pmax=find_maximun(p); | |
50 |
|
|
50 | contador=0; | |
51 | Serial.print("Potencia anomala en el transmisor: "); Serial.print(Pmax); |
|
51 | dif=abs(Plinea-Pmax)*100/Plinea; | |
|
52 | difPlow=abs(Plinea-Pmax); | |||
|
53 | if(dif>10 && difPlow>7) Serial.println(Pmax); | |||
52 |
|
|
54 | } | |
53 |
|
55 | |||
54 | // Serial.print("Nivel anómalo de potencia Ph"); |
|
56 | ||
55 | //Serial.print(" "); Serial.print(Plcal); |
|
57 | /* | |
56 | //Serial.print(" "); Serial.println(Vout); |
|
58 | if(dif>10 && Vout>120 ){ | |
|
59 | Parray[contador]=Plcal; | |||
|
60 | contador =contador+1; | |||
|
61 | if(contador==SIZE){ | |||
|
62 | p=&Parray[0]; | |||
|
63 | Pmax=find_maximun(p); | |||
|
64 | contador=0; | |||
|
65 | difPlow=abs(Plinea-Pmax); | |||
|
66 | if (difPlow>8) { | |||
|
67 | Serial.print("Potencia anomala en el transmisor: "); | |||
|
68 | Serial.println(Pmax); | |||
|
69 | } | |||
57 |
} |
|
70 | } | |
58 | /* else if(VoutRef<3000 && difPlow>5 && Vout>120){ |
|
|||
59 | Serial.print("Potencia anómala para Plow"); |
|
|||
60 | Serial.print(" "); Serial.println(Plcal); |
|
|||
61 | Serial.println(Vout); |
|
|||
62 | }*/ |
|
71 | } */ | |
63 | } |
|
72 | } | |
64 | float ecuacionLineal(float Vpk){ |
|
73 | float ecuacionLineal(float Vpk){ |
General Comments 0
You need to be logged in to leave comments.
Login now