TEMPORIZACION DE ALARMAS

  • 2 Respuestas
  • 3272 Vistas

JavierZ

  • Principiante
  • Mensajes: 2
TEMPORIZACION DE ALARMAS
« : noviembre 26, 2015, 16:02:08 pm »
Buenas tardes, me encuentro realizando un proyecto, en el cual defino 4 alarmas que deben activarse en 4 momentos diferentes del dia. Las mismas deben encender una salida durante un tiempo que debe venir definido por una variable.

Ahora tengo dos consultas

Primero, si el modulo de un timer o un timeout (preferentemente un timeout por ser grande el tiempo) puede ser tomado de una variable?

Segundo, intente temporizar desde el evento de la alarma, pero no dio resultado, como debo realizar esto (en PAWN)?

Soporte

  • Global Moderator
  • Experto
  • *****
  • Mensajes: 2324
  • Soporte Técnico
Re:TEMPORIZACION DE ALARMAS
« Respuesta #1 : noviembre 26, 2015, 22:56:57 pm »
En el manual de Programación Pawn del PLC: http://slicetex.com/hw/stx80xx/docs/STX80XX-MP-PLC-AX_CX_DX.pdf

Están las descripciones completas de las funciones Pawn que utilizamos a continuación para responder sus dudas.

Por ejemplo para activar 4 alarmas que se repiten todos los días a una hora particular haces:

Código: (Pawn) [Seleccionar]

PlcMain()
{
   // Activar Alarma 1.
   TimeAlarm1SetEvent(17,0,0, TIMEALARM_REPEAT, 0)

   // Activar Alarma 2.
   TimeAlarm1SetEvent(15,33,0, TIMEALARM_REPEAT, 0)

   // Activar Alarma 3.
   TimeAlarm1SetEvent(21,52,0, TIMEALARM_REPEAT, 0)

   // Activar Alarma 4.
   TimeAlarm1SetEvent(23,58,0, TIMEALARM_REPEAT, 0)

   // Ciclo principal del programa.
   while(1)
  {
     // Hacer parpadear el led DEBUG.
    LedToggle()
    DelayMS(500)
   }
}

// A CONTINUACION SE DEFINEN LOS EVENTOS PARA TODAS LAS ALARMAS:

@OnTimeAlarm1()
{
    // ...
    // HACER ALGO AL OCURRIR LA ALARMA
    // ...
}

@OnTimeAlarm2()
{
    // ...
    // HACER ALGO AL OCURRIR LA ALARMA
    // ...
}

@OnTimeAlarm3()
{
    // ...
    // HACER ALGO AL OCURRIR LA ALARMA
    // ...
}

@OnTimeAlarm4()
{
    // ...
    // HACER ALGO AL OCURRIR LA ALARMA
    // ...
}


Si queres activar un timeout que apague un rele en un tiempo X luego de producirse la alarma haces los siguiente:

Código: (Pawn) [Seleccionar]

// Variable para alterar el tiempo de apagado del RELAY1.
new TimeoutRelay1Off = 20

PlcMain()
{
   // Inicializar temporizadores Timeout.
   TimeoutInitEvent()

   // Activar Alarma 1.
   TimeAlarm1SetEvent(17,0,0, TIMEALARM_REPEAT, 0)

   // Activar Alarma 2.
   TimeAlarm1SetEvent(15,33,0, TIMEALARM_REPEAT, 0)

   // Activar Alarma 3.
   TimeAlarm1SetEvent(21,52,0, TIMEALARM_REPEAT, 0)

   // Activar Alarma 4.
   TimeAlarm1SetEvent(23,58,0, TIMEALARM_REPEAT, 0)

   // Ciclo principal del programa.
   while(1)
  {
     // Hacer parpadear el led DEBUG.
    LedToggle()
    DelayMS(500)
   }
}

// A CONTINUACION SE DEFINEN LOS EVENTOS PARA TODAS LAS ALARMAS:

@OnTimeAlarm1()
{
    // Activar RELAY1
    RelayClose(RELAY1)

    // Especificar un Timeout1 en "TimeoutRelay1Off" segundos.
    Timeout1SetEvent(TimeoutRelay1Off)
}

@OnTimeAlarm2()
{
    // Activar RELAY1
    RelayClose(RELAY1)

    // Especificar un Timeout1 en "TimeoutRelay1Off" segundos.
    Timeout1SetEvent(TimeoutRelay1Off)
}

@OnTimeAlarm3()
{
    // Activar RELAY1
    RelayClose(RELAY1)

    // Especificar un Timeout1 en "TimeoutRelay1Off" segundos.
    Timeout1SetEvent(TimeoutRelay1Off)
}

@OnTimeAlarm4()
{
    // Activar RELAY1
    RelayClose(RELAY1)

    // Especificar un Timeout1 en "TimeoutRelay1Off" segundos.
    Timeout1SetEvent(TimeoutRelay1Off)
}

// Manejador para el evento "OnTimeout()"

@OnTimeout()
{
   // Comprobar si Timeout1 ha expirado.
   if(Timeout1Check() == 1)
   {
      // Desactivar RELAY1.
      RelayOpen(RELAY1)
     
      // Eliminar Timeout1.
      Timeout1ClrEvent()
   }
}

La linea:  Timeout1SetEvent(TimeoutRelay1Off) establece un timeout de acuerdo a la variable global TimeoutRelay1Off, que podes modificar en otra parte.

Este código es valido cuando el timeout es menor al tiempo entre alarmas.

Caso contrario, deberías utilizar un timeout diferente por cada alarma, para que no se "pisen".

Cualquier duda, quedamos a disposición.
« Última Modificación: noviembre 26, 2015, 22:59:59 pm por Soporte »
SOPORTE TÉCNICO

Slicetex Electronics
www.slicetex.com

JavierZ

  • Principiante
  • Mensajes: 2
Re:TEMPORIZACION DE ALARMAS
« Respuesta #2 : noviembre 27, 2015, 18:11:50 pm »
Muchas Gracias por la pronta respuesta.. Me funciono de 10, luego de ver el codigo que me enviaron y chequear el que yo tenia. Estaba ante un error respecto a la llamada al evento del timeout, por eso no me funcionaba.

Muchas gracias