Vai al contenuto
PLC Forum


Ho Bisogno Di Moltissimi Timer E Merker Per Fronte Di Salita


UR65

Messaggi consigliati

Buongiorno,

per interfacciarmi con un'altra parte di programma esistente e che non vorrei modificare ho bisogno di moltissimi timer, e merker per gestire il fronte di salita di un bit.

ho la necessità di generare un impulsa che mi setti un bit che poi mi viene resettato da un'altra parte di programma.

Ho provato a creare un FB e con un l'utilizzo di un SFB ho creato il blocchetto con timer [TON], fronte di salita (P) e il set (S) per il bit.

quindi poi, avendo bisogno di un impulso, ho usato anche SFB con timer [TP] e set (S) per il bit,

l'ho richiamato in FC, ma non va.

Utilizzando in FC il timer [s_EVERZ], (P) per il fronte di salita e (S) per settare l'impulso funziona tutto bene, solo che i timer disponibili sono limitati per quello che devo fare io.

quello che succede che il bit che viene da me settato poi non viene resettato dall'altra parte del programma che sto controllando.

proverò ancora a lavorare sul FB, forse commetto un errore li, ma in ogni caso se ci fosse la possibilità di avere moltissimi timer e merker senza generare un DB per ogni blocco richiamato sarebbe l'deale.

grazie

e se non andate al mare........

rispondetemi

ciao

Link al commento
Condividi su altri siti


per i fronti di salita ...li puoi creare con DWORD .

Una DWORD che salva l'immagine degli ingressi o dei merker , una DWORD che contiene le memorie per il fronte e una DWORD che memorizza i fronti

I timer li puoi fare anche con il ciclo di scansione , se guardi i WTimer per arduino sono praticamente una cosa del genere

Link al commento
Condividi su altri siti

Se non hai bisogno di precisione estrema puoi fare un FC dove incrementi una DWORD con un parametro di ingresso in cui passerai il valore OB1_PREV_CYCLE. (tempo ultma scansione OB1 in ms.

Per i fronti puoi creare una DB con un array di bit, ne puoi fare quanti ne vuoi, magari la DB la chiami "F" (flags) e l'array pure "F" (fronte).

Link al commento
Condividi su altri siti

sui il cycle time del plc per incrementare N timer software che si basano su accumulatori di REAL , un bit di start e un done come stato quando ha finito di contare

Link al commento
Condividi su altri siti

Esempio di timer DINT con conteggio in ms:

DATA_BLOCK "T"
TITLE =
VERSION : 0.1


  STRUCT 	
   Set : ARRAY  [0 .. 31 ] OF //Setpoint timer non (ms)
   DINT ;	
   Val : ARRAY  [0 .. 31 ] OF //Valore conteggio timer non (ms)
   DINT ;	
   Start : ARRAY  [0 .. 31 ] OF //Bit Start timer
   BOOL ;	
   Pause : ARRAY  [0 .. 31 ] OF //Bit Pausa timer
   BOOL ;	
   Done : ARRAY  [0 .. 31 ] OF //Bit Uscita timer
   BOOL ;	
  END_STRUCT ;	
BEGIN
   Set[0] := L#0; 
   Set[1] := L#0; 
   Set[2] := L#0; 
   Set[3] := L#0; 
   Set[4] := L#0; 
   Set[5] := L#0; 
   Set[6] := L#0; 
   Set[7] := L#0; 
   Set[8] := L#0; 
   Set[9] := L#0; 
   Set[10] := L#0; 
   Set[11] := L#0; 
   Set[12] := L#0; 
   Set[13] := L#0; 
   Set[14] := L#0; 
   Set[15] := L#0; 
   Set[16] := L#0; 
   Set[17] := L#0; 
   Set[18] := L#0; 
   Set[19] := L#0; 
   Set[20] := L#0; 
   Set[21] := L#0; 
   Set[22] := L#0; 
   Set[23] := L#0; 
   Set[24] := L#0; 
   Set[25] := L#0; 
   Set[26] := L#0; 
   Set[27] := L#0; 
   Set[28] := L#0; 
   Set[29] := L#0; 
   Set[30] := L#0; 
   Set[31] := L#0; 
   Val[0] := L#0; 
   Val[1] := L#0; 
   Val[2] := L#0; 
   Val[3] := L#0; 
   Val[4] := L#0; 
   Val[5] := L#0; 
   Val[6] := L#0; 
   Val[7] := L#0; 
   Val[8] := L#0; 
   Val[9] := L#0; 
   Val[10] := L#0; 
   Val[11] := L#0; 
   Val[12] := L#0; 
   Val[13] := L#0; 
   Val[14] := L#0; 
   Val[15] := L#0; 
   Val[16] := L#0; 
   Val[17] := L#0; 
   Val[18] := L#0; 
   Val[19] := L#0; 
   Val[20] := L#0; 
   Val[21] := L#0; 
   Val[22] := L#0; 
   Val[23] := L#0; 
   Val[24] := L#0; 
   Val[25] := L#0; 
   Val[26] := L#0; 
   Val[27] := L#0; 
   Val[28] := L#0; 
   Val[29] := L#0; 
   Val[30] := L#0; 
   Val[31] := L#0; 
   Start[0] := FALSE; 
   Start[1] := FALSE; 
   Start[2] := FALSE; 
   Start[3] := FALSE; 
   Start[4] := FALSE; 
   Start[5] := FALSE; 
   Start[6] := FALSE; 
   Start[7] := FALSE; 
   Start[8] := FALSE; 
   Start[9] := FALSE; 
   Start[10] := FALSE; 
   Start[11] := FALSE; 
   Start[12] := FALSE; 
   Start[13] := FALSE; 
   Start[14] := FALSE; 
   Start[15] := FALSE; 
   Start[16] := FALSE; 
   Start[17] := FALSE; 
   Start[18] := FALSE; 
   Start[19] := FALSE; 
   Start[20] := FALSE; 
   Start[21] := FALSE; 
   Start[22] := FALSE; 
   Start[23] := FALSE; 
   Start[24] := FALSE; 
   Start[25] := FALSE; 
   Start[26] := FALSE; 
   Start[27] := FALSE; 
   Start[28] := FALSE; 
   Start[29] := FALSE; 
   Start[30] := FALSE; 
   Start[31] := FALSE; 
   Pause[0] := FALSE; 
   Pause[1] := FALSE; 
   Pause[2] := FALSE; 
   Pause[3] := FALSE; 
   Pause[4] := FALSE; 
   Pause[5] := FALSE; 
   Pause[6] := FALSE; 
   Pause[7] := FALSE; 
   Pause[8] := FALSE; 
   Pause[9] := FALSE; 
   Pause[10] := FALSE; 
   Pause[11] := FALSE; 
   Pause[12] := FALSE; 
   Pause[13] := FALSE; 
   Pause[14] := FALSE; 
   Pause[15] := FALSE; 
   Pause[16] := FALSE; 
   Pause[17] := FALSE; 
   Pause[18] := FALSE; 
   Pause[19] := FALSE; 
   Pause[20] := FALSE; 
   Pause[21] := FALSE; 
   Pause[22] := FALSE; 
   Pause[23] := FALSE; 
   Pause[24] := FALSE; 
   Pause[25] := FALSE; 
   Pause[26] := FALSE; 
   Pause[27] := FALSE; 
   Pause[28] := FALSE; 
   Pause[29] := FALSE; 
   Pause[30] := FALSE; 
   Pause[31] := FALSE; 
   Done[0] := FALSE; 
   Done[1] := FALSE; 
   Done[2] := FALSE; 
   Done[3] := FALSE; 
   Done[4] := FALSE; 
   Done[5] := FALSE; 
   Done[6] := FALSE; 
   Done[7] := FALSE; 
   Done[8] := FALSE; 
   Done[9] := FALSE; 
   Done[10] := FALSE; 
   Done[11] := FALSE; 
   Done[12] := FALSE; 
   Done[13] := FALSE; 
   Done[14] := FALSE; 
   Done[15] := FALSE; 
   Done[16] := FALSE; 
   Done[17] := FALSE; 
   Done[18] := FALSE; 
   Done[19] := FALSE; 
   Done[20] := FALSE; 
   Done[21] := FALSE; 
   Done[22] := FALSE; 
   Done[23] := FALSE; 
   Done[24] := FALSE; 
   Done[25] := FALSE; 
   Done[26] := FALSE; 
   Done[27] := FALSE; 
   Done[28] := FALSE; 
   Done[29] := FALSE; 
   Done[30] := FALSE; 
   Done[31] := FALSE; 
END_DATA_BLOCK


FUNCTION "Timer++" : VOID
TITLE =Timer DINT con interruzione
VERSION : 0.1


VAR_INPUT
  Start : BOOL ;	//Start timer
  Pause : BOOL ;	//Pausa timer
  OB1_PREV_CYCLE : INT ;	//Tempo scansione OB1
  Timer_Set : DINT ;	//Setpoint timer (ms)
END_VAR
VAR_IN_OUT
  Timer_Value : DINT ;	//Valore timer (ms)
  Output : BOOL ;	//Uscita timer
END_VAR
BEGIN
NETWORK
TITLE =Start

      U     #Start; // Se ingresso start
      SPB   seg2; // --> seg2

// Temporizzatore inattivo
      R     #Output; // resetta uscita
      L     #Timer_Set; // Preimposta 
      T     #Timer_Value; // valore conteggio
      BEA   ; 

NETWORK
TITLE =Pausa

seg2: U     #Output; // se conteggio terminato
      O     #Pause; // o pausa 
      BEB   ; // termina qui

NETWORK
TITLE =Conteggio


      L     #Timer_Value; // Decrementa il valore del timer
      L     #OB1_PREV_CYCLE; // con il tempo di scansione di OB1
      ITD   ; 
      -D    ; 
      SPP   cnt; // se risultato > 0 salta a cnt e aggiorna...

// Tempo scaduto:
      SET   ; 
      S     #Output; // Setta uscita
      L     L#0; // e azzera ...

cnt:  T     #Timer_Value; // ... il conteggio



END_FUNCTION

ORGANIZATION_BLOCK "Cycle Execution"
TITLE = "Main Program Sweep (Cycle)"
VERSION : 0.1


VAR_TEMP
  OB1_EV_CLASS : BYTE ;	//Bits 0-3 = 1 (Coming event), Bits 4-7 = 1 (Event class 1)
  OB1_SCAN_1 : BYTE ;	//1 (Cold restart scan 1 of OB 1), 3 (Scan 2-n of OB 1)
  OB1_PRIORITY : BYTE ;	//Priority of OB Execution
  OB1_OB_NUMBR : BYTE ;	//1 (Organization block 1, OB1)
  OB1_RESERVED_1 : BYTE ;	//Reserved for system
  OB1_RESERVED_2 : BYTE ;	//Reserved for system
  OB1_PREV_CYCLE : INT ;	//Cycle time of previous OB1 scan (milliseconds)
  OB1_MIN_CYCLE : INT ;	//Minimum cycle time of OB1 (milliseconds)
  OB1_MAX_CYCLE : INT ;	//Maximum cycle time of OB1 (milliseconds)
  OB1_DATE_TIME : DATE_AND_TIME ;	//Date and time OB1 started
END_VAR
BEGIN

NETWORK
TITLE =

      CALL "Timer++" (
           Start                    := "T".Start[0],
           Pause                    := "T".Pause[0],
           OB1_PREV_CYCLE           := #OB1_PREV_CYCLE,
           Timer_Set                := "T".Set[0],
           Timer_Value              := "T".Val[0],
           Output                   := "T".Done[0]);


      CALL "Timer++" (
           Start                    := "T".Start[1],
           Pause                    := "T".Pause[1],
           OB1_PREV_CYCLE           := #OB1_PREV_CYCLE,
           Timer_Set                := "T".Set[1],
           Timer_Value              := "T".Val[1],
           Output                   := "T".Done[1]);

END_ORGANIZATION_BLOCK


Modificato: da JumpMan
Link al commento
Condividi su altri siti

  • 4 weeks later...

Crea un account o accedi per commentare

Devi essere un utente per poter lasciare un commento

Crea un account

Registrati per un nuovo account nella nostra comunità. è facile!

Registra un nuovo account

Accedi

Hai già un account? Accedi qui.

Accedi ora
×
×
  • Crea nuovo/a...