DISEÑO DE MEDIDOR DE CORRIENTE Y CALCULO DE POTENCIA MOSTRADO EN PUERTO SERIAL

Dependencies:   mbed MEDIDORCORRIENTEVOLTAJEYPOTENCIA

Committer:
dibbrowing
Date:
Sat Feb 15 00:06:19 2020 +0000
Revision:
1:49382e23d412
Parent:
0:bb38e88170c8
debermedidor de corriente voltaje y potencia por fase mostrado en pantalla lcd

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dibbrowing 0:bb38e88170c8 1 #include "mbed.h"
dibbrowing 1:49382e23d412 2 #include "TextLCD.h"
dibbrowing 1:49382e23d412 3
dibbrowing 1:49382e23d412 4 DigitalOut myled(PD_13);
dibbrowing 1:49382e23d412 5 Serial pc(PA_2,PA_3);
dibbrowing 1:49382e23d412 6 I2C i2c_lcd(PB_7, PB_8); // SDA, SCL
dibbrowing 1:49382e23d412 7 TextLCD_I2C lcd(&i2c_lcd, 0x4E, TextLCD::LCD20x4);
dibbrowing 1:49382e23d412 8
dibbrowing 1:49382e23d412 9 ////////ENTRADAS ANALOGICAS
dibbrowing 1:49382e23d412 10 AnalogIn IFASE1(PB_0);
dibbrowing 1:49382e23d412 11 AnalogIn IFASE2(PB_1);
dibbrowing 1:49382e23d412 12 AnalogIn IFASE3(PC_5);
dibbrowing 1:49382e23d412 13 AnalogIn VFASE1_2(PA_6);
dibbrowing 1:49382e23d412 14 AnalogIn VFASE2_3(PA_7);
dibbrowing 1:49382e23d412 15 AnalogIn VFASE3_1(PC_4);
dibbrowing 1:49382e23d412 16 float valor_IFASE1=0;
dibbrowing 1:49382e23d412 17 float valor_IFASE2=0;
dibbrowing 1:49382e23d412 18 float valor_IFASE3=0;
dibbrowing 1:49382e23d412 19 float valor_VFASE1_2=0;
dibbrowing 1:49382e23d412 20 float valor_VFASE2_3=0;
dibbrowing 1:49382e23d412 21 float valor_VFASE3_1=0;
dibbrowing 1:49382e23d412 22 ////ESTRUCTURA
dibbrowing 0:bb38e88170c8 23
dibbrowing 1:49382e23d412 24 int main()
dibbrowing 1:49382e23d412 25 {
dibbrowing 1:49382e23d412 26 while(true){
dibbrowing 1:49382e23d412 27 pc.baud(115200);
dibbrowing 1:49382e23d412 28 //myled = 1;
dibbrowing 1:49382e23d412 29 //wait(0.2);
dibbrowing 1:49382e23d412 30 //myled = 0;
dibbrowing 1:49382e23d412 31 //wait(0.2);
dibbrowing 1:49382e23d412 32 valor_IFASE1=IFASE1.read();
dibbrowing 1:49382e23d412 33 valor_IFASE2=IFASE2.read();
dibbrowing 1:49382e23d412 34 valor_IFASE3=IFASE3.read();
dibbrowing 1:49382e23d412 35 valor_VFASE1_2=VFASE1_2.read();
dibbrowing 1:49382e23d412 36 valor_VFASE2_3=VFASE2_3.read();
dibbrowing 1:49382e23d412 37 valor_VFASE3_1=VFASE3_1.read();
dibbrowing 1:49382e23d412 38 //device.printf("el valor de la corriente FASE1 es: %2.2fA%\n",valor_IFASE1*20);//ESCALAMIENTO A SENSOR DE 20 AMP
dibbrowing 1:49382e23d412 39 //device.printf("el valor de la corriente FASE2 es: %2.2fA%\n",valor_IFASE2*20);
dibbrowing 1:49382e23d412 40 //device.printf("el valor de la corriente FASE3 es: %2.2fA%\n",valor_IFASE3*20);
dibbrowing 1:49382e23d412 41 //device.printf("el valor del voltaje F1-F2 es: %2.2fV%\n",valor_VFASE1_2*480);//ESCALAMIENTO A VOLTAJE DE 480
dibbrowing 1:49382e23d412 42 //device.printf("el valor del voltaje F2-F3 es: %2.2fV%\n",valor_VFASE2_3*480);
dibbrowing 1:49382e23d412 43 //device.printf("el valor del voltaje F3-F1 es: %2.2fV%\n",valor_VFASE3_1*480);
dibbrowing 1:49382e23d412 44
dibbrowing 1:49382e23d412 45 //pc.printf("From here is a new example for Master classes in UPS Guayaquil \r\n");
dibbrowing 1:49382e23d412 46
dibbrowing 1:49382e23d412 47 // Clear the screen and locate to 0,0
dibbrowing 1:49382e23d412 48 lcd.cls();
dibbrowing 1:49382e23d412 49
dibbrowing 1:49382e23d412 50 // LCD Backlight control
dibbrowing 1:49382e23d412 51 lcd.setBacklight(TextLCD::LightOn);
dibbrowing 1:49382e23d412 52
dibbrowing 1:49382e23d412 53 // LCD Orientation control, supported for some Controllers
dibbrowing 1:49382e23d412 54 //lcd.setOrient(TextLCD::Bottom);
dibbrowing 1:49382e23d412 55
dibbrowing 1:49382e23d412 56 // LCD BigFont control, supported for some Controllers
dibbrowing 1:49382e23d412 57 //lcd.LCDBigFont(TextLCD::TopBottomLine);
dibbrowing 1:49382e23d412 58
dibbrowing 1:49382e23d412 59 // Locate cursor to a screen column and row
dibbrowing 1:49382e23d412 60 //int col = 0;
dibbrowing 1:49382e23d412 61 //int row = 0;
dibbrowing 1:49382e23d412 62 //lcd.locate(col,row);
dibbrowing 1:49382e23d412 63 //lcd.printf("Iniciando...¡");
dibbrowing 1:49382e23d412 64 //wait(1);
dibbrowing 1:49382e23d412 65
dibbrowing 1:49382e23d412 66 //No Show cursor as blinking character
dibbrowing 1:49382e23d412 67 lcd.setCursor(TextLCD::CurOff_BlkOff);
dibbrowing 0:bb38e88170c8 68
dibbrowing 1:49382e23d412 69 // Write a character to the LCD "ARROW"
dibbrowing 1:49382e23d412 70 //int c = 1;
dibbrowing 1:49382e23d412 71 //lcd.cls();
dibbrowing 1:49382e23d412 72 //lcd.locate(0,0);
dibbrowing 1:49382e23d412 73 //for (int row=0; row<4; row++) {
dibbrowing 1:49382e23d412 74 //lcd.putc(c);
dibbrowing 1:49382e23d412 75 //wait(0.01);
dibbrowing 1:49382e23d412 76
dibbrowing 1:49382e23d412 77 //for (col=0; col<19; col++) {
dibbrowing 1:49382e23d412 78 //lcd.putc(c);
dibbrowing 1:49382e23d412 79 //wait(0.01);
dibbrowing 1:49382e23d412 80 //}
dibbrowing 1:49382e23d412 81 //}
dibbrowing 1:49382e23d412 82 //wait(2);
dibbrowing 1:49382e23d412 83
dibbrowing 1:49382e23d412 84 // Write a raw string to the LCD
dibbrowing 1:49382e23d412 85 lcd.cls();
dibbrowing 1:49382e23d412 86 lcd.locate(0,0);
dibbrowing 1:49382e23d412 87 lcd.printf("IA%2.1f%", valor_IFASE1*20);
dibbrowing 1:49382e23d412 88 lcd.locate(7,0);
dibbrowing 1:49382e23d412 89 lcd.printf("IB%2.1f%", valor_IFASE2*20);
dibbrowing 1:49382e23d412 90 lcd.locate(14,0);
dibbrowing 1:49382e23d412 91 lcd.printf("IC%2.1f%", valor_IFASE3*20);
dibbrowing 1:49382e23d412 92 lcd.locate(0,1);
dibbrowing 1:49382e23d412 93 lcd.printf("V1=%1.0f%", valor_VFASE1_2*480);
dibbrowing 1:49382e23d412 94 lcd.locate(7,1);
dibbrowing 1:49382e23d412 95 lcd.printf("V2=%1.0f%", valor_VFASE2_3*480);
dibbrowing 1:49382e23d412 96 lcd.locate(14,1);
dibbrowing 1:49382e23d412 97 lcd.printf("V3=%1.0f%", valor_VFASE3_1*480);
dibbrowing 1:49382e23d412 98 lcd.locate(0,2);
dibbrowing 1:49382e23d412 99 lcd.printf("P1=%1.1f%", (((valor_IFASE1*20)*(valor_VFASE1_2*480)))/1000);
dibbrowing 1:49382e23d412 100 lcd.locate(7,2);
dibbrowing 1:49382e23d412 101 lcd.printf("P2=%1.1f%", (((valor_IFASE2*20)*(valor_VFASE2_3*480)))/1000);
dibbrowing 1:49382e23d412 102 lcd.locate(14,2);
dibbrowing 1:49382e23d412 103 lcd.printf("P3=%1.1f%", (((valor_IFASE3*20)*(valor_VFASE3_1*480)))/1000);
dibbrowing 1:49382e23d412 104 wait(0.5);
dibbrowing 1:49382e23d412 105
dibbrowing 1:49382e23d412 106 // Write a raw string to the LCD -> pointer
dibbrowing 1:49382e23d412 107
dibbrowing 1:49382e23d412 108 //lcd.locate(0,1);
dibbrowing 1:49382e23d412 109 //lcd.printf("/----------------/");
dibbrowing 1:49382e23d412 110
dibbrowing 1:49382e23d412 111 //const char* msg = "Mensaje con punteros";
dibbrowing 1:49382e23d412 112 //int string_size = strlen (msg);
dibbrowing 1:49382e23d412 113 //lcd.locate(0,2);
dibbrowing 1:49382e23d412 114 //lcd.printf("%.*s", string_size, msg);
dibbrowing 1:49382e23d412 115
dibbrowing 1:49382e23d412 116 //lcd.locate(0,3);
dibbrowing 1:49382e23d412 117 //const char* msg2 = "\"TXT: %.*s\",size,msg";
dibbrowing 1:49382e23d412 118 //int string_size2 = strlen (msg2);
dibbrowing 1:49382e23d412 119 //lcd.printf("%.*s", string_size2, msg2);
dibbrowing 1:49382e23d412 120 //wait(0.2);
dibbrowing 1:49382e23d412 121
dibbrowing 1:49382e23d412 122
dibbrowing 1:49382e23d412 123
dibbrowing 1:49382e23d412 124 // Return the memoryaddress of screen column and row location
dibbrowing 1:49382e23d412 125 //lcd.getAddress(col,row);
dibbrowing 1:49382e23d412 126 //pc.printf("column %d\trow %d\r\n",col,row);
dibbrowing 1:49382e23d412 127 //wait(1);
dibbrowing 1:49382e23d412 128
dibbrowing 1:49382e23d412 129
dibbrowing 1:49382e23d412 130
dibbrowing 1:49382e23d412 131 // Return the number of rows ans columns
dibbrowing 1:49382e23d412 132 //pc.printf("column %d\trow %d\r\n",lcd.rows(),lcd.columns());
dibbrowing 1:49382e23d412 133 //wait(1);
dibbrowing 1:49382e23d412 134 }
dibbrowing 0:bb38e88170c8 135 }
dibbrowing 1:49382e23d412 136
dibbrowing 1:49382e23d412 137