PROGRAMA PARA CONTROLAR EL PROCESO DE UN EQUIPO TOSTADOR DE CAFE

Dependencies:   mbed NextionLCD

  • PROYECTO SISTEMAS MICROPROCESADOS*

PROBLEMA

En un proceso el tanque el cual contiene un producto, necesita ser monitoreado para que cumpla algunas condiciones de trabajo entre ellas tenemos:

La temperatura debe estar en 0 y 5 °C.

La presión del producto debe estar en 4 y 20 BAR;

Sólo como referencia para controlar el batch; el operador necesita saber el nivel del producto en el tanque.

SOLUCIÓN

DISEÑAR un programa con ayuda de una tarjeta electróncia (ARM) capaz de receptar las variables de proceso, se debe usar una terminal de salida para monitorizar las variables descritas en el problema, y a su vez programar las condiciones de alerta necesarias para el efectivo proceso de dicho producto.

  • DESARROLLO*
  • ETAPA 1 - RECEPCIÓN DE VARIABLES DE PROCESO*

En esta etapa se desarrolla el circuito para simular la entrada de variables analógicas de las variables de proceso, tales como temperatura, presión y nivel para este caso.

Es necesario escalar (interpretar la señal eléctrica a un variable de proceso) para poder presentar los valores y con ellos realizar el respectivo monitoreo.

Aquí se presentan divisores de tensión con su respectivo arreglo de resistencias para simular los rangos de voltajes que recepta la tarjeta electróncia ARM.

https://os.mbed.com/media/uploads/cristhian1987/img_20200216_000436.jpg

  • ETAPA 2 - PRESENTACIÓN DE HARDWARE*

A continuación se adjunta una foto, general del proyecto.

https://os.mbed.com/media/uploads/cristhian1987/img_20200216_000428.jpg

  • ETAPA 3 - PROGRAMACIÓN*

Se detalla el código para realizar la monitorización

include the mbed library with this snippet

#include "mbed.h"

/*
Problema:
En un tanque de proceso, el producto que reposa en él debe cumplir condiciones, las cuales tenemos:

La temperatura debe estar entre 0 - 5 °C.
La presion debe cumplir de 4 a 20 BAR.
El nivel del producto sólo es indicativo.
Si el proceso varía estas condiciones mostrarán mensajes de error como advertencia o alerta para el operador.
*/

#include "mbed.h"   // libreria mbed
#include "NextionLCD.h" // libreria NextionLCD (Básica)
NextionLCD lcd(PB_6, PB_7);     //Tx, Rx

int main()
{
    char str[20];
    float v_Temp;
    float v_Presion;
    float v_Nivel;

    float Temperatura;
    float Presion;
    float Nivel;

    DigitalOut myled(PD_13); // Asignar salida digital al pin PD 13
    DigitalOut myled2(PD_12); // Asignar salida digital al pin PD 13
    AnalogIn Ain(PB_0); // Variable (Ain) para Entrada Analógica en el puerto PB_0
    AnalogIn Ain1(PB_1); // Variable (Ain) para Entrada Analógica en el puerto PB_0
    AnalogIn Ain2(PC_4); // Variable (Ain) para Entrada Analógica en el puerto PB_0
    v_Temp=0;
    v_Presion=0;
    v_Nivel=0;
    Temperatura=0;
    Presion=0;
    Nivel=0;

    lcd.ClrScr(BLACK);  //clear the display and fill it with BLACK pixels

    //draw some shapes
    //lcd.FillCircle(100,100,50,RED);
    //lcd.DrawPixel(100,100,WHITE);
    //lcd.DrawRectangle(50,50,100,100,BLUE);
    //lcd.DrawLine(50,50,100,150,YELLOW);

    /** Draws a string on the lcd at the specified xy position.
        * @param x x position.
        * @param y y position.
        * @param w Width of string area.
        * @param h Height of string area.
        * @param font Font ID to use (0:smallest - 7:largest).
        * @param fontcolor Color Integer value (0 to 65535) to represent the font color of the string - represented in 16-bit 565 color format.
        * @param backcolor Color Integer value (0 to 65535) to represent the background color of the string - represented in 16-bit 565 color format.
        * @param xcenter Horizontal alignment (0: left-aligned, 1: entered, 2: right-aligned).
        * @param ycenter Vertical alignment (0: upper-aligned, 1: entered, 2: lower-aligned).
        * @param str String content.
        */
    //void DrawString(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint8_t font, uint16_t fontcolor, uint16_t backcolor, uint8_t xcenter, uint8_t ycenter, char *str);
    //str.printf("hola mundo");
    //lcd.DrawString(0,0,50,50,20,20,20,20,20,str);

    while(1) {
        sprintf(str, "PROYECTO SISTEMAS MICROPROCESADOS"); //print to string buffer
        lcd.DrawString(10,0,300,50,0,WHITE,BLACK,0,0,str);            //display string on LCD:

        v_Temp=Ain;
        v_Presion=Ain1;
        v_Nivel=Ain2;
        myled = 1; //Asigna el valor de 1 (ON) a la variable "myled"
        wait(0.1); //Línea de espera (ms)
        //sprintf(str, "El valor analogico en voltaje es: %f",v_analogico); //print to string buffer
        //lcd.DrawString(40,100,250,20,0,GREEN,GRAY,0,0,str);            //display string on LCD:
        myled = 0; //Asigna el valor de 1 (ON) a la variable "myled"
        wait(0.1); //Línea de espera (ms)

        //Escalar variable de entrada
        Temperatura= v_Temp*10;
        Presion= v_Presion*50;
        Nivel= v_Nivel*12;

        myled = 1; //Asigna el valor de 1 (ON) a la variable "myled"
        wait(0.1); //Línea de espera (ms)

        sprintf(str,"El valor de Temperatura es: %0.1f C",Temperatura); //print to string buffer
        lcd.DrawString(40,150,250,20,0,WHITE,GRAY,0,0,str);            //display string on LCD:
        myled = 0; //Asigna el valor de 1 (ON) a la variable "myled"
        wait(0.1); //Línea de espera (ms)

        sprintf(str, "El valor de Presion es: %0.2f BAR",Presion); //print to string buffer
        lcd.DrawString(40,170,250,20,0,WHITE,GRAY,0,0,str);            //display string on LCD:
        myled = 1; //Asigna el valor de 1 (ON) a la variable "myled"
        wait(0.1); //Línea de espera (ms)

        sprintf(str, "El valor de nivel es: %0.3f m",Nivel); //print to string buffer
        lcd.DrawString(40,190,250,20,0,WHITE,GRAY,0,0,str);            //display string on LCD:
        //myled = 0; //Asigna el valor de 1 (ON) a la variable "myled"
        //wait(0.1); //Línea de espera (ms)


        //Condiciones del proceso:
        if (Temperatura >= 5 && Temperatura<=10 && Presion >= 20 && Presion <= 50) {
            sprintf(str, "ERROR EN PROCESO"); //print to string buffer
            lcd.DrawString(40,30,250,20,0,RED,GRAY,0,0,str);            //display string on LCD:
        } 
        if (Temperatura >= 0 && Temperatura<5) {
            sprintf(str, "TEMPERATURA ESTABLE"); //print to string buffer
            lcd.DrawString(40,70,250,20,0,GREEN,GRAY,0,0,str);            //display string on LCD:
        } 
        if (Temperatura >= 5 && Temperatura <= 10) {
            sprintf(str, "TEMPERATURA ELEVADA"); //print to string buffer
            lcd.DrawString(40,70,250,20,0,RED,GRAY,0,0,str);            //display string on LCD:
        } 
        if (Presion >= 4 && Presion <= 20) {
            sprintf(str, "PRESION ESTABLE"); //print to string buffer
            lcd.DrawString(40,100,250,20,0,GREEN,GRAY,0,0,str);            //display string on LCD:
        }
        if (Presion > 20 && Presion <= 40) {
            sprintf(str, "PRESION ELEVADA"); //print to string buffer
            lcd.DrawString(40,100,250,20,0,YELLOW,GRAY,0,0,str);            //display string on LCD:
        }
        if (Presion > 40 && Presion <= 50) {
            sprintf(str, "SOBREPRESION"); //print to string buffer
            lcd.DrawString(40,100,250,20,0,RED,GRAY,0,0,str);            //display string on LCD:
        }
     }
}
  • MONITORIZACIÓN DEL PROCESO*

https://os.mbed.com/media/uploads/cristhian1987/img_20200216_000511_1.jpg

https://os.mbed.com/media/uploads/cristhian1987/img_20200216_000506.jpg

https://os.mbed.com/media/uploads/cristhian1987/img_20200216_000504.jpg

https://os.mbed.com/media/uploads/cristhian1987/img_20200216_000458.jpg

https://os.mbed.com/media/uploads/cristhian1987/img_20200216_000449.jpg

https://os.mbed.com/media/uploads/cristhian1987/img_20200216_000445.jpg

https://os.mbed.com/media/uploads/cristhian1987/img_20200216_000443.jpg

Download repository: zip gz

Files at revision 1:6f80c4b7b4b5

Name Size Actions
[up]
NextionLCD.lib 70 Revisions Annotate
main.cpp 5849 Revisions Annotate
mbed.bld 69 Revisions Annotate