INTRODUCCIÓN
Este es la V4 de las tarjetas especializadas para ascensores de carga que venimos desarrollando, esta vez con una mejora de haber integrado pulsadores de configuración y un display de 7 segmentos que nos indicada el nivel de piso. Te gustaría saber cómo se hizo este controlador desde el esquemático electrónico, el diseño pcb y el armado de la maqueta? Pues no te despegues de este articulo.
ESPECIFICACIONES TÉCNICAS

- Tensión de alimentación……………………….…………24VDC
- Corriente de alimentación………………….……………90mA
- Entadas digitales 12-24VDC……………………….……10
- Salidas RLY…………………………………………………………4
-
- Tensión AC…………..……….………………….….……250V
- Corriente AC…………………………………………….5A
- Tensión DC………………………………………………30V
- Corriente DC……………………………………………5A
-
- Entorno de programación………………………..………..Arduino IDE
- Condiciones ambientales min……………………….….-40°
- Condiciones ambientales max…………………..……….80°
- Dimensiones……………………………………………………….100x120mm
- Empotrable………………………………….……………………Sí
- Programación directa (PC-Tarjeta electrónica)…………Sí
- Display de 7 segmentos………………………………………………Sí
- Pulsadores de configuración……………………………………….Sí
ESQUEMATICO ELECTRONICO

LISTA DE MATERIALES

| Comment | Designator | Footprint | Value | Manufacturer Part | Manufacturer | Supplier Part |
| 100nF | C1,C13 | C1206 | 100nF | CL31B104KBCNNNC | SAMSUNG(三星) | C24497 |
| 100uF | C2 | CAP-SMD_BD8.0-L8.3-W8.3-FD | 100uF | VT1H101M-CRF10 | VT(首科) | C305377 |
| 100nF | C3,C4,C5,C6,C7,C8,C9,C10,C11,C12,C14,C15,C16, C17,C19,C20,C21,C22,C23,C24,C25,C26,C27,C28, C29,C30,C31,C32,C33,C34,C35,C36,C37 |
C0603 | 100nF | CC0603KRX7R9BB104 | YAGEO(国巨) | C14663 |
| 1000uF | C18 | CAP-SMD_BD10.0-L10.3-W10.3-LS11.3-FD | 1000uF | VT1C102M-CRG10 | VT(首科) | C263979 |
| SS210 | D1,D2,D3,D4,D5 | SMA_L4.3-W2.6-LS5.2-RD | SS210 | MDD | C14996 | |
| M7 | D6,D7,D8,D9 | SMA_L4.3-W2.6-LS5.2-RD | M7 | MDD | C95872 | |
| BSMD1206-100-24V | F1 | F1206 | BSMD1206-100-24V | BHFUSE(佰宏) | C910830 | |
| 2.54-1x6P直针 | H1 | HDR-TH_6P-P2.54-V-M-1 | 2.54-1x6P直针 | BOOMELE(博穆精密) | C37208 | |
| 100uH | L1 | IND-SMD_L12.3-W12.3 | 100uH | CYH127-100UH | SHOU HAN(首韩) | C2929505 |
| KT-0805G | LED1,LED2,LED3,LED4,LED5,LED6,LED7,LED8,LED9, LED10,LED11,LED12,LED13,LED14,LED15 |
LED0805-R-RD | KT-0805G | KENTO | C2297 | |
| SM420561N | LED16 | LED-SEG-TH_10P-L12.7-W19.0-P2.54-S15.24-BL | SM420561N | ARKLED(方舟) | C141367 | |
| WJ128V-5.0-2P | P1,P2,P3,P4,P5,P6,P7,P8,P9,P10 | CONN-TH_2P-P5.00_WJ128V-5.0-2P | WJ128V-5.0-2P | KANGNEX(康奈克斯电气) | C8269 | |
| MMBT5551 | Q1,Q2,Q3,Q4 | SOT-23-3_L2.9-W1.3-P1.90-LS2.4-BR | MMBT5551 | CJ(江苏长电/长晶) | C2145 | |
| 10kΩ | R1,R2,R3,R4,R5,R6,R7,R8,R9,R10 | R1206 | 10kΩ | 1206W4F1002T5E | UNI-ROYAL(厚声) | C17902 |
| 10kΩ | R11,R12,R13,R14,R15,R16,R17,R18,R19,R20,R21,R24, R26,R28,R30,R33,R35,R37,R38,R40,R43,R44,R46,R48, R49,R50,R51,R52,R57,R58,R59,R60 |
R0603 | 10kΩ | 0603WAF1002T5E | UNI-ROYAL(厚声) | C25804 |
| 1kΩ | R22,R23,R25,R27,R29,R31,R32,R34,R36,R39,R41,R45 ,R47,R61,R62,R63,R64 |
R0603 | 1kΩ | 0603WAF1001T5E | UNI-ROYAL(厚声) | C21190 |
| 1MΩ | R42 | R0603 | 1MΩ | 0603WAF1004T5E | UNI-ROYAL(厚声) | C22935 |
| 330Ω | R53,R54,R55,R56 | R0603 | 330Ω | 0603WAF3300T5E | UNI-ROYAL(厚声) | C23138 |
| 220Ω | R65,R66,R67,R68,R69,R70,R71,R72 | R0603 | 220Ω | 0603WAF2200T5E | UNI-ROYAL(厚声) | C22962 |
| 4.7kΩ | R73,R74,R75,R76 | R0805 | 4.7kΩ | 0805W8F4701T5E | UNI-ROYAL(厚声) | C17673 |
| RC-124DM1 | RLY1,RLY2,RLY3,RLY4 | RELAY-TH_RC-XXXXM | RC-124DM1 | WRG(旺荣集团) | C358574 | |
| DTS-66K-V | SW1,SW2,SW3,SW4 | KEY-TH_4P-L6.2-W6.2-P4.50-LS6.5 | DTS-66K-V | 圜达 | C141877 | |
| TLP127(TPL,U,F) | U1,U2,U3,U4,U5,U6,U7,U8,U9,U10,U15,U16,U17,U18 | SOP-4_L3.6-W4.4-P2.54-LS7.0-BR | TLP127(TPL,U,F) | TOSHIBA(东芝) | C5001 | |
| LM2576SX-5.0/NOPB | U11 | PG-TO-263-5_L10.2-W8.7-P1.70-LS14.4-BR | LM2576SX-5.0/NOPB | TI(德州仪器) | C34465 | |
| SN74HC541PWR | U12 | TSSOP-20_L6.5-W4.4-P0.65-LS6.4-BL | SN74HC541PWR | TI(德州仪器) | C6758 | |
| ATMEGA328P-AU | U13 | TQFP-32_L7.0-W7.0-P0.80-LS9.0-BL | ATMEGA328P-AU | MICROCHIP(美国微芯) | C14877 | |
| CH340C | U14 | SOP-16_L10.0-W3.9-P1.27-LS6.0-BL | CH340C | WCH(南京沁恒) | C84681 | |
| 74HC595D,118 | U19 | SOIC-16_L9.9-W3.9-P1.27-LS6.0-BL | 74HC595D,118 | Nexperia(安世) | C5947 | |
| SN74HC14PWR | U20,U21 | TSSOP-14_L5.0-W4.4-P0.65-LS6.4-BL | SN74HC14PWR | TI(德州仪器) | C6821 | |
| USB-TYPE-C-018 | USB1 | USB-C_SMD-TYPE-C-31-M-12 | USB-TYPE-C-018 | DEALON(德艺隆) | C2927038 | |
| 16MHz | X1 | OSC-SMD_3P-L3.2-W1.3-P0.95-L | 16MHz | CSTCE16M0V53-R0 | muRata(村田) | C32180 |
PASOS PARA SUBIR UN PROGRAMA

PASO 1 : SUBIR PROGRAMA BOOTLOADER A UN ARDUINO UNO
Primero subimos este código BOOTLOADER a un arduino UNO como normalmente subimos cualquier programa a nuestra placa arduino UNO.
PASO 2 : CABLEADO PARA SUBIR GESTOR DE ARRANQUE (BOOTLOADER)
Despues de haber subido el programa anterior, ahora vamos aquemar el gestor de arranque al nuevo microcontrolador que tiene nuestro plc.
Recuerden que para poder usar un microcontrolador nuevo (atmega328P-AU), es necesario subir un gestor de arranque como también llamado “BOOTLOADER”, esto nos facilitará subir programas en futuras ocasiones. Especialmente cuando se quiere programar desde el IDE de arduino.
finalmente para quemar el bootloader se tendrá que realizar a través de los pines ISP, que prácticamente serían los pines [(MOSI=PIN 11) (MISO = PIN 12) (SCK=PIN 13) (Slave=PIN 10)]. Para subir y quemar el gestor de arranque necesitaremos un arduino UNO ó MEGA y realizar las siguientes conexiones (ARDUINO UNO – PLC LOGO demo). OJO que este paso solo se hace una sola vez.
CODIGO

int clockpin = 11; //Cuando ay que leer los bit SH
int data = 12; //Envio datos DS
int latch = 13; //indica pin de salida en el chip ST
int S_I_cont = 0;
int contador = 0;
int valor = 0;
int valor1 = 0;
int B_EM = 0;
const int NUM[] = {
// display katodo comun
63, //Numero 0 en binario es : 00111111
6, //Numero 1 en binario es : 00000110
91, //Numero 2 en binario es : 01011011
79, //Numero 3 en binario es : 01001111
102, //Numero 4 en binario es : 01100110
109, //Numero 5 en binario es : 01101101
125, //Numero 6 en binario es : 01111101
7, //Numero 7 en binario es : 00000111
127, //Numero 8 en binario es : 01111111
111, //Numero 9 en binario es : 01101111
63, //Numero 0 en binario es : 00111111
28, //NUM 0 en binario es : 00011100 puerta bajando, para posicion inicial
};
unsigned long time;
float tiempo = 2000;
unsigned long t = 0;
//physical inputs
const int in1 = 2;
const int in2 = 3;
const int in3 = 4;
const int in4 = 5;
const int in5 = 6;
const int in6 = 7;
const int in7 = 8;
const int in8 = 9;
const int in9 = 10;
const int in10 = A6;
const int in11 = A7;
const int btn_up = 16;
const int btn_ok = 15;
const int btn_dn = 14;
// physical outputs
const int m_up = 17; //motor up
const int m_down = 18; // motor down
const int booking = 19; // reserva
const int booking1 = 10; // reserva
// Memories
//ETAPA
boolean e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12 = false;
//TRANSITION
boolean t01, t02, t03, t04, t05, t06, t07, t08, t09, t010, t011, t012, t10, t20, t30, t40, t50, t60, t70, t80, t90, t100, t110, t120 = false;
int last_S_I = 0;
int retard = 0;
void setup() {
Serial.begin(9600);
//salidas para display
pinMode(latch, OUTPUT);
pinMode(clockpin, OUTPUT);
pinMode(data, OUTPUT);
//sensores infrarrojo
pinMode(in1, INPUT);
//final de carrera de seguridad
pinMode(in2, INPUT);
pinMode(in3, INPUT);
//pusadores de llamada
pinMode(in4, INPUT); //1er piso
pinMode(in5, INPUT); //2do piso
pinMode(in6, INPUT); //3to piso
pinMode(in7, INPUT); //4to piso
pinMode(in8, INPUT); //5to piso
pinMode(in9, INPUT); // Pulsador de emergencia
//Pulsadores de configuración
pinMode(btn_up, INPUT);
pinMode(btn_ok, INPUT);
pinMode(btn_dn, INPUT);
//salidas motor
pinMode(m_up, OUTPUT);
pinMode(m_down, OUTPUT);
pinMode(booking, OUTPUT);
pinMode(booking1, OUTPUT);
//delay(2000);
while (!digitalRead(in2) == HIGH) {
digitalWrite(m_down, 1);
digitalWrite(latch, LOW);
shiftOut(data, clockpin, MSBFIRST, NUM[11]); // lee el arreglo y pasa cada NUM a lectura binaria
digitalWrite(latch, HIGH);
}
//delay(500);
while (!digitalRead(in1) == HIGH) {
digitalWrite(m_down, 0);
digitalWrite(m_up, 1);
}
if (digitalRead(in1) == true) {
digitalWrite(m_up, 0);
S_I_cont = 1;
}
digitalWrite(m_down, 0);
digitalWrite(booking, 0);
digitalWrite(booking1, 0);
}
void loop() {
//Inputs
int S_I = digitalRead(in1);
int F_D = digitalRead(in2);
int F_U = digitalRead(in3);
int b1 = digitalRead(in4);
int b2 = digitalRead(in5);
int b3 = digitalRead(in6);
int b4 = digitalRead(in7);
int b5 = digitalRead(in8);
int B_E = digitalRead(in9); //Boton de energencia
if (B_E != valor) {
if (B_E == LOW) {
valor1++;
delay(200);
}
}
valor = B_E;
if (valor1 == 1) {
B_EM = true;
}
if (valor1 == 2) {
B_EM = false;
valor1 = 0;
}
if (e1 || e2 || e3 || e4 || e5 || e6 || e7 || e8 || e9 || e10 || e11 || e12 == true) {
time = millis();
if (time - t > tiempo) {
t = time;
contador++;
//Serial.println(contador);
}
}
if (S_I != last_S_I) {
if (S_I == LOW) {
if (contador > 3) {
if (e1 || e2 || e3 || e4 || e5 || e6 == true) {
if (S_I_cont < 4) {
S_I_cont++;
contador = 0;
}
}
if (e7 || e8 || e9 || e10 || e11 || e12 == true) {
if (S_I_cont > 1) {
S_I_cont--;
contador = 0;
}
}
}
}
}
last_S_I = S_I;
//INICIALIZACION***************************
if ((!e1 && !e2 && !e3 && !e4 && !e5 && !e6 && !e7 && !e8 && !e9 && !e10 && !e11 && !e12) == true) {
e0 = true;
}
//TRANSITION*********************************
//from 1 to 2 floor
if (e0 == true && S_I_cont == 1 && b2 == true) {
t01 = true;
t10 = false;
}
if (e1 && S_I_cont == 2) {
t10 = true;
t01 = false;
}
//from 1 to 3 floor
if (e0 && S_I_cont == 1 && b3 == true) {
t02 = true;
t20 = false;
}
if (e2 && S_I_cont == 3) {
t20 = true;
t02 = false;
}
//from 1 to 4 floor
if (e0 && S_I_cont == 1 && b4 == true) {
t03 = true;
t30 = false;
}
if (e3 && S_I_cont == 4) {
t30 = true;
t03 = false;
}
//from 2 to 3 floor
if (e0 && S_I_cont == 2 && b3 == true) {
t04 = true;
t40 = false;
}
if (e4 && S_I_cont == 3) {
t40 = true;
t04 = false;
}
//from 2 to 4 floor
if (e0 && S_I_cont == 2 && b4 == true) {
t05 = true;
t50 = false;
}
if (e5 && S_I_cont == 4) {
t50 = true;
t05 = false;
}
//from 3 to 4 floor
if (e0 && S_I_cont == 3 && b4 == true) {
t06 = true;
t60 = false;
}
if (e6 && S_I_cont == 4) {
t60 = true;
t06 = false;
}
//from 4 to 3 floor
if (e0 && S_I_cont == 4 && b3 == true) {
t07 = true;
t70 = false;
}
if (e7 && S_I_cont == 3) {
t70 = true;
t07 = false;
}
//from 4 to 2 floor
if (e0 && S_I_cont == 4 && b2 == true) {
t08 = true;
t80 = false;
}
if (e8 && S_I_cont == 2) {
t80 = true;
t08 = false;
}
//from 4 to 1 floor
if (e0 && S_I_cont == 4 && b1 == true) {
t09 = true;
t90 = false;
}
if (e9 && S_I_cont == 1) {
t90 = true;
t09 = false;
}
//from 3 to 2 floor
if (e0 && S_I_cont == 3 && b2 == true) {
t010 = true;
t100 = false;
}
if (e10 && S_I_cont == 2) {
t100 = true;
t010 = false;
}
//from 3 to 1 floor
if (e0 && S_I_cont == 3 && b1 == true) {
t011 = true;
t110 = false;
}
if (e11 && S_I_cont == 1) {
t110 = true;
t011 = false;
}
//from 2 to 1 floor
if (e0 && S_I_cont == 2 && b1 == true) {
t012 = true;
t120 = false;
}
if (e12 && S_I_cont == 1) {
t120 = true;
t012 = false;
}
//ETAPA**************************************
if (e0 && t01 == true) {
e0 = false;
e1 = true;
}
if (e1 && t10 == true) {
e1 = false;
e0 = true;
}
if (e0 && t02 == true) {
e0 = false;
e2 = true;
}
if (e2 && t20 == true) {
e2 = false;
e0 = true;
}
if (e0 && t03 == true) {
e0 = false;
e3 = true;
}
if (e3 && t30 == true) {
e3 = false;
e0 = true;
}
if (e0 && t04 == true) {
e0 = false;
e4 = true;
}
if (e4 && t40 == true) {
e4 = false;
e0 = true;
}
if (e0 && t05 == true) {
e0 = false;
e5 = true;
}
if (e5 && t50 == true) {
e5 = false;
e0 = true;
}
if (e0 && t06 == true) {
e0 = false;
e6 = true;
}
if (e6 && t60 == true) {
e6 = false;
e0 = true;
}
if (e0 && t07 == true) {
e0 = false;
e7 = true;
}
if (e7 && t70 == true) {
e7 = false;
e0 = true;
}
if (e0 && t08 == true) {
e0 = false;
e8 = true;
}
if (e8 && t80 == true) {
e8 = false;
e0 = true;
}
if (e0 && t09 == true) {
e0 = false;
e9 = true;
}
if (e9 && t90 == true) {
e9 = false;
e0 = true;
}
if (e0 && t010 == true) {
e0 = false;
e10 = true;
}
if (e10 && t100 == true) {
e10 = false;
e0 = true;
}
if (e0 && t011 == true) {
e0 = false;
e11 = true;
}
if (e11 && t110 == true) {
e11 = false;
e0 = true;
}
if (e0 && t012 == true) {
e0 = false;
e12 = true;
}
if (e12 && t120 == true) {
e12 = false;
e0 = true;
}
//ACTUADORES*********************************
// Motor subiendo
if ((e1 || e2 || e3 || e4 || e5 || e6 == true) && (!F_D && !F_U && !B_EM == true)) {
digitalWrite(m_up, HIGH);
digitalWrite(m_down, LOW);
cont();
}
//Reposo
if (e0 || F_D || F_U || B_EM == true) {
digitalWrite(m_up, LOW);
digitalWrite(m_down, LOW);
cont();
}
//motor bajando
if ((e7 || e8 || e9 || e10 || e11 || e12 == true) && (!F_D && !F_U && !B_EM == true)) {
digitalWrite(m_up, LOW);
digitalWrite(m_down, HIGH);
cont();
}
while (digitalRead(btn_up) == 1) {
digitalWrite(m_up, HIGH);
digitalWrite(m_down, LOW);
}
while (digitalRead(btn_dn) == 1) {
digitalWrite(m_up, LOW);
digitalWrite(m_down, HIGH);
}
}
void cont() {
digitalWrite(latch, LOW);
shiftOut(data, clockpin, MSBFIRST, NUM[S_I_cont]); // lee el arreglo y pasa cada NUM a lectura binaria
digitalWrite(latch, HIGH);
}






4 comentarios. Dejar nuevo
hola, y muy buen proyecto, me agrada ver personas con este espíritu de pasión por la electrónica y sin egoísmo por compartir su conocimiento al mundo entero.
Yo NO trabajo con arduino, me gusta mas hacerlo con mis propios medios y utilizar el mplax 4.2 en código assembler.
Excelente vídeo y aporte, saludos y éxitos profesionales.
Which are the reasons for d1 d2 d5 from power supply section?
Sería posible aplicar el sistema ascensor en una compuerta para riego, utilizando un motor nema 23, con comunicación lora par enviar las ordenes de pisos 1, 2, 3, 4 (SERÍA SUBIR 5 cm, 10 cm, 15 cm, 20 cm, que es el máximo a elevar), sin necesidad de poner fines de carrera? , a su vez se realizaría por móvil con un pequeño programa. La idea es tener controladas al menos 200 compuertas de regadío, sobre canales de obra y en caso de no poder con módulos lora, se podría hacer mediante gprs y con ubicación via gps de lugar de cada compuerta para poder verlo es una especie de Sistema de Información Geográfica
claro que si se puede, puede ser con encoder o o solo sensor. contacto: +51945601024