Hace meses atrás publiqué un video sobre cómo hacer un PLC con ESP32, Si bien es cierto, aquel proyecto solo era de demostración, por lo tanto había varios aspectos que mejorar. Así que hoy crearemos un PLC LOGO con ESP32, donde integraremos las mejoras pertinentes, como por ejemplo, integraremos un reloj de tiempo real, se contará con 8 entradas digitales de 24V, tendremos salidas a transistores mosfet y para poder subir un programa lo haremos a través de un puerto usb de tipo c. No obstante, lo novedoso en este proyecto es que vamos a realizar una carcasa que sea montable a un tablero eléctrico y finalmente asumo que lo más importante de usar el ESP32 es el hecho de contar con la comunicación wifi y bluetooth.
ESPECIFICACIONES TÉCNICAS
- Tensión de alimentación……………………….…………24VDC
- Corriente de alimentación………………….……………70mA
- Entadas digitales 15-24VDC……………………….……8
- Salidas Trasistor mosfet…………………………8
-
- Tensión DC………………………………………………30V
- Corriente DC……………………………………………5A
-
- Entorno de programación………………………..………..Arduino IDE
- Condiciones ambientales min……………………….….-40°
- Condiciones ambientales max…………………..……….150°
- Dimensiones……………………………………………………….85x65mm
- Empotrable………………………………….……………………Sí
- Wifi……………………………………………………………………………….Sí
- Bluetooth……………………………………………………………………..Sí
- doble núcleo………………………………………………………………..Sí
- Programación directa (PC-PLC LOGO with ESP32)………..Sí
LISTA DE COMPONENTES ELECTRÓNICOS
Categoría | Cantidad | Referencias | Valor | PCB Package | Datasheet |
Condensadores | 22 | C1,C2,C3,C4,C5,C6,C7,C8,C9,C10,C11,C12,C13, C14,C15,C16,C18,C19,C22,C23,C24,C25 |
100nF | 0603_CAP | (see & buy) |
Condensadores | 1 | C17 | 10uF | 1206_CAP | (see & buy) |
Condensadores | 1 | C20 | 220uF | CAP SMD 6.3X7.7MM ALUMINUM 220UF/16V | (see & buy) |
Condensadores | 1 | C21 | 470uF | CAP SMD 10.5X10MM ALUMINUM 470UF/35V | (see & buy) |
Resistencias | 26 | R1,R2,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12, R13,R14,R15,R16,R28,R29,R67,R68,R69,R70, R71,R72,R73,R74 |
10k | 0603_RES | (see & buy) |
Resistencias | 8 | R17,R18,R19,R20,R21,R22,R23,R24 | 20k | 1206_RES | (see & buy) |
Resistencias | 2 | R25,R26 | 4.7k | RES_ARRAY 0603X4 | (see & buy) |
Resistencias | 1 | R27 | 470 | 0603_RES | (see & buy) |
Resistencias | 5 | R30,R31,R32,R33,R34 | 1k | 0603_RES | (see & buy) |
Resistencias | 16 | R35,R38,R39,R42,R43,R46,R47,R50,R51, R54,R55,R58,R59,R62,R63,R66 |
10k | 0805_RES | (see & buy) |
Resistencias | 8 | R36,R40,R44,R48,R52,R56,R60,R64 | 1k | 0805_RES | (see & buy) |
Resistencias | 8 | R37,R41,R45,R49,R53,R57,R61,R65 | 220 | 0603_RES | (see & buy) |
Integrados | 2 | U1,U2 | 74HC14 | TSSOP14 | (see & buy) |
Integrados | 1 | U3 | 74HC541 | TSSOP20 | (see & buy) |
Integrados | 8 | U4,U5,U6,U7,U14,U15,U16,U17 | ILD207T | SO8 | (see & buy) |
Integrados | 1 | U8 | AT24C512B | SO8 | (see & buy) |
Integrados | 1 | U9 | DS3232 | SO16W | (see & buy) |
Integrados | 1 | U10 | ESP-32s | ESP-32S | (see & buy) |
Integrados | 1 | U11 | LM2576-3,3 | TO170P1410X464-6 | (see & buy) |
Integrados | 1 | U12 | LD1117S33 | SOT230P700X180-4 | (see & buy) |
Integrados | 1 | U13 | CH340C | SO16 | (see & buy) |
Transistores | 2 | Q1,Q2 | PMBT3904,215 | SOT23-3 | (see & buy) |
Transistores | 8 | Q3,Q4,Q5,Q6,Q7,Q8,Q9,Q10 | FQD11P06TM | DPAK-N | (see & buy) |
Diodos | 1 | D1 | 1N4148W | SOD123 | (see & buy) |
Diodos | 3 | D2,D3,D4 | B330A-13-F | DIOM5226X230N | (see & buy) |
Diodos | 1 | D5 | LED-RED | LEDC2012X120 | (see & buy) |
Miscelánea | 1 | BAT1 | 3V | BAT 3V | (see & buy) |
Miscelánea | 2 | BTN1,BTN2 | RST | BUTTON SMD 2P | (see & buy) |
Miscelánea | 1 | F1 | 1A | FUSE SMD | (see & buy) |
Miscelánea | 1 | J1 | USB TYPE C | USB TYPE C | (see & buy) |
Miscelánea | 1 | J2 | TBLOCK-M2 | T-BLOCK 2PIN BLUE | (see & buy) |
Miscelánea | 1 | J3 | KFM736-5_0-6P | KFM736-5.0-6P P=5.0MM | (see & buy) |
Miscelánea | 1 | J4 | KFM736-5_0-5P | KFM736-5.0-5P P=5.0MM | (see & buy) |
Miscelánea | 1 | L1 | 100u | SMD 12.5X12.5X5MM | (see & buy) |
CÓDIGOS DE PRUEBA
TEST INPUTS & OUTPUT
// inputs const int in1 = 27; const int in2 = 35; const int in3 = 12; const int in4 = 14; const int in5 = 32; const int in6 = 33; const int in7 = 26; const int in8 = 25; // outputs const int ot1 = 15; const int ot2 = 4; const int ot3 = 16; const int ot4 = 17; const int ot5 = 5; const int ot6 = 18; const int ot7 = 19; const int ot8 = 23; void setup() { pinMode(in1, INPUT); pinMode(in2, INPUT); pinMode(in3, INPUT); pinMode(in4, INPUT); pinMode(in5, INPUT); pinMode(in6, INPUT); pinMode(in7, INPUT); pinMode(in8, INPUT); pinMode(ot1, OUTPUT); pinMode(ot2, OUTPUT); pinMode(ot3, OUTPUT); pinMode(ot4, OUTPUT); pinMode(ot5, OUTPUT); pinMode(ot6, OUTPUT); pinMode(ot7, OUTPUT); pinMode(ot8, OUTPUT); } void loop() { // simple test inputs and outputs if (digitalRead(in1))digitalWrite(ot1, 1); else digitalWrite(ot1, 0); if (digitalRead(in2))digitalWrite(ot2, 1); else digitalWrite(ot2, 0); if (digitalRead(in3))digitalWrite(ot3, 1); else digitalWrite(ot3, 0); if (digitalRead(in4))digitalWrite(ot4, 1); else digitalWrite(ot4, 0); if (digitalRead(in5))digitalWrite(ot5, 1); else digitalWrite(ot5, 0); if (digitalRead(in6))digitalWrite(ot6, 1); else digitalWrite(ot6, 0); if (digitalRead(in7))digitalWrite(ot7, 1); else digitalWrite(ot7, 0); if (digitalRead(in8))digitalWrite(ot8, 1); else digitalWrite(ot8, 0); }
PWM OUTPUTS
// the number of the LED pin const int pwm_out = 15; // 15 corresponds to GPIO15 // setting PWM properties const int freq = 5000; const int ledChannel = 0; const int resolution = 8; void setup(){ // configure LED PWM functionalitites ledcSetup(ledChannel, freq, resolution); // attach the channel to the GPIO to be controlled ledcAttachPin(pwm_out, ledChannel); } void loop(){ // increase the LED brightness for(int dutyCycle = 0; dutyCycle <= 255; dutyCycle++){ // changing the LED brightness with PWM ledcWrite(ledChannel, dutyCycle); delay(15); } // decrease the LED brightness for(int dutyCycle = 255; dutyCycle >= 0; dutyCycle--){ // changing the LED brightness with PWM ledcWrite(ledChannel, dutyCycle); delay(15); } }
TEST REAL TIME CLOCK (RTC)
// Date and time functions using a DS3231 RTC connected via I2C and Wire lib #include "RTClib.h" RTC_DS3231 rtc; char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; void setup () { Serial.begin(57600); #ifndef ESP8266 while (!Serial); // wait for serial port to connect. Needed for native USB #endif if (! rtc.begin()) { Serial.println("Couldn't find RTC"); Serial.flush(); abort(); } if (rtc.lostPower()) { Serial.println("RTC lost power, let's set the time!"); // When time needs to be set on a new device, or after a power loss, the // following line sets the RTC to the date & time this sketch was compiled rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); // This line sets the RTC with an explicit date & time, for example to set // January 21, 2014 at 3am you would call: // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0)); } // When time needs to be re-set on a previously configured device, the // following line sets the RTC to the date & time this sketch was compiled // rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); // This line sets the RTC with an explicit date & time, for example to set // January 21, 2014 at 3am you would call: // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0)); } void loop () { DateTime now = rtc.now(); Serial.print(now.year(), DEC); Serial.print('/'); Serial.print(now.month(), DEC); Serial.print('/'); Serial.print(now.day(), DEC); Serial.print(" ("); Serial.print(daysOfTheWeek[now.dayOfTheWeek()]); Serial.print(") "); Serial.print(now.hour(), DEC); Serial.print(':'); Serial.print(now.minute(), DEC); Serial.print(':'); Serial.print(now.second(), DEC); Serial.println(); Serial.print(" since midnight 1/1/1970 = "); Serial.print(now.unixtime()); Serial.print("s = "); Serial.print(now.unixtime() / 86400L); Serial.println("d"); // calculate a date which is 7 days, 12 hours, 30 minutes, 6 seconds into the future DateTime future (now + TimeSpan(7,12,30,6)); Serial.print(" now + 7d + 12h + 30m + 6s: "); Serial.print(future.year(), DEC); Serial.print('/'); Serial.print(future.month(), DEC); Serial.print('/'); Serial.print(future.day(), DEC); Serial.print(' '); Serial.print(future.hour(), DEC); Serial.print(':'); Serial.print(future.minute(), DEC); Serial.print(':'); Serial.print(future.second(), DEC); Serial.println(); Serial.print("Temperature: "); Serial.print(rtc.getTemperature()); Serial.println(" C"); Serial.println(); //delay(3000); }
3 comentarios. Dejar nuevo
Estimado buenas tardes,
Una pregunta, esta alimentando al ESP32 con 5v o con 3.3v, lo comento porque en la lista de materiales menciona LM2576-3,3 pero el link del componente es a uno de 5v
De antemano gracias.
es de 3.3V hermano
Muy interesante me gustaría saber si se puede hacer la programación con diagrama ladder ya que Soy electricista y entiendo más sobre bloque de contacto así como la programación que se puede hacer en el software de Siemens se lo agradezco si tiene más información sobre la programación muchas gracias