DISEÑO DE MEDIDOR DE CORRIENTE Y CALCULO DE POTENCIA MOSTRADO EN PUERTO SERIAL
Dependencies: mbed MEDIDORCORRIENTEVOLTAJEYPOTENCIA
Diff: main.cpp
- Revision:
- 1:49382e23d412
- Parent:
- 0:bb38e88170c8
--- a/main.cpp Wed Feb 05 01:43:41 2020 +0000 +++ b/main.cpp Sat Feb 15 00:06:19 2020 +0000 @@ -1,12 +1,137 @@ #include "mbed.h" +#include "TextLCD.h" + +DigitalOut myled(PD_13); +Serial pc(PA_2,PA_3); +I2C i2c_lcd(PB_7, PB_8); // SDA, SCL +TextLCD_I2C lcd(&i2c_lcd, 0x4E, TextLCD::LCD20x4); + +////////ENTRADAS ANALOGICAS +AnalogIn IFASE1(PB_0); +AnalogIn IFASE2(PB_1); +AnalogIn IFASE3(PC_5); +AnalogIn VFASE1_2(PA_6); +AnalogIn VFASE2_3(PA_7); +AnalogIn VFASE3_1(PC_4); +float valor_IFASE1=0; +float valor_IFASE2=0; +float valor_IFASE3=0; +float valor_VFASE1_2=0; +float valor_VFASE2_3=0; +float valor_VFASE3_1=0; +////ESTRUCTURA -DigitalOut myled(LED1); +int main() +{ + while(true){ + pc.baud(115200); + //myled = 1; + //wait(0.2); + //myled = 0; + //wait(0.2); + valor_IFASE1=IFASE1.read(); + valor_IFASE2=IFASE2.read(); + valor_IFASE3=IFASE3.read(); + valor_VFASE1_2=VFASE1_2.read(); + valor_VFASE2_3=VFASE2_3.read(); + valor_VFASE3_1=VFASE3_1.read(); + //device.printf("el valor de la corriente FASE1 es: %2.2fA%\n",valor_IFASE1*20);//ESCALAMIENTO A SENSOR DE 20 AMP + //device.printf("el valor de la corriente FASE2 es: %2.2fA%\n",valor_IFASE2*20); + //device.printf("el valor de la corriente FASE3 es: %2.2fA%\n",valor_IFASE3*20); + //device.printf("el valor del voltaje F1-F2 es: %2.2fV%\n",valor_VFASE1_2*480);//ESCALAMIENTO A VOLTAJE DE 480 + //device.printf("el valor del voltaje F2-F3 es: %2.2fV%\n",valor_VFASE2_3*480); + //device.printf("el valor del voltaje F3-F1 es: %2.2fV%\n",valor_VFASE3_1*480); + + //pc.printf("From here is a new example for Master classes in UPS Guayaquil \r\n"); + + // Clear the screen and locate to 0,0 + lcd.cls(); + + // LCD Backlight control + lcd.setBacklight(TextLCD::LightOn); + + // LCD Orientation control, supported for some Controllers + //lcd.setOrient(TextLCD::Bottom); + + // LCD BigFont control, supported for some Controllers + //lcd.LCDBigFont(TextLCD::TopBottomLine); + + // Locate cursor to a screen column and row + //int col = 0; + //int row = 0; + //lcd.locate(col,row); + //lcd.printf("Iniciando...¡"); + //wait(1); + + //No Show cursor as blinking character + lcd.setCursor(TextLCD::CurOff_BlkOff); -int main() { - while(1) { - myled = 1; - wait(0.2); - myled = 0; - wait(0.2); + // Write a character to the LCD "ARROW" + //int c = 1; + //lcd.cls(); + //lcd.locate(0,0); + //for (int row=0; row<4; row++) { + //lcd.putc(c); + //wait(0.01); + + //for (col=0; col<19; col++) { + //lcd.putc(c); + //wait(0.01); + //} + //} + //wait(2); + + // Write a raw string to the LCD + lcd.cls(); + lcd.locate(0,0); + lcd.printf("IA%2.1f%", valor_IFASE1*20); + lcd.locate(7,0); + lcd.printf("IB%2.1f%", valor_IFASE2*20); + lcd.locate(14,0); + lcd.printf("IC%2.1f%", valor_IFASE3*20); + lcd.locate(0,1); + lcd.printf("V1=%1.0f%", valor_VFASE1_2*480); + lcd.locate(7,1); + lcd.printf("V2=%1.0f%", valor_VFASE2_3*480); + lcd.locate(14,1); + lcd.printf("V3=%1.0f%", valor_VFASE3_1*480); + lcd.locate(0,2); + lcd.printf("P1=%1.1f%", (((valor_IFASE1*20)*(valor_VFASE1_2*480)))/1000); + lcd.locate(7,2); + lcd.printf("P2=%1.1f%", (((valor_IFASE2*20)*(valor_VFASE2_3*480)))/1000); + lcd.locate(14,2); + lcd.printf("P3=%1.1f%", (((valor_IFASE3*20)*(valor_VFASE3_1*480)))/1000); + wait(0.5); + + // Write a raw string to the LCD -> pointer + + //lcd.locate(0,1); + //lcd.printf("/----------------/"); + + //const char* msg = "Mensaje con punteros"; + //int string_size = strlen (msg); + //lcd.locate(0,2); + //lcd.printf("%.*s", string_size, msg); + + //lcd.locate(0,3); + //const char* msg2 = "\"TXT: %.*s\",size,msg"; + //int string_size2 = strlen (msg2); + //lcd.printf("%.*s", string_size2, msg2); + //wait(0.2); + + + + // Return the memoryaddress of screen column and row location + //lcd.getAddress(col,row); + //pc.printf("column %d\trow %d\r\n",col,row); + //wait(1); + + + + // Return the number of rows ans columns + //pc.printf("column %d\trow %d\r\n",lcd.rows(),lcd.columns()); + //wait(1); + } } -} + +