Funzioni ed FB per gestione counters ------------------------------------ CTD, Counter Down ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |image0| +----------+------------------+ | **Type** | **Library** | | | | +----------+------------------+ | FB | eLLabStdLib_B000 | +----------+------------------+ Questo blocco funzione esegue la gestione di un counter in decremento. Agendo sull\'ingresso di load **LD** è possibile in qualsiasi momento trasferire il valore di preset definito su **PV** nel counter **CV**. Ad ogni fronte di attivazione dell'ingresso **CD**, il valore del counter **CV** viene decrementato, quando il valore raggiunge 0, l'uscita **Q** viene settata ed il conteggio si arresta. Solo agendo sull'ingresso di load **LD** è possibile presettare il counter e fare ripartire un nuovo conteggio. **L'ingresso di load LD è prioritario sull'ingresso di decremento CD**. +-----------------------------------+-----------------------------------+ | **CD** (BOOL) | Comando decremento counter, ad | | | ogni fronte attivazione il valore | | | del counter CV si decrementa. | +-----------------------------------+-----------------------------------+ | **LD** (BOOL) | Comando di load, attivando | | | l'ingresso il valore di preset | | | PV, viene trasferito nel valore | | | del counter CV. | +-----------------------------------+-----------------------------------+ | **PV** (INT) | Valore di preset, attivando | | | l'ingresso di load LD, viene | | | trasferito nel valore del counter | | | CV. | +-----------------------------------+-----------------------------------+ | **Q** (BOOL) | Uscita counter, attiva se il | | | valore del counter CV raggiunge | | | il valore 0. | +-----------------------------------+-----------------------------------+ | **CV** (INT) | Valore counter, valore di | | | conteggio counter, quando | | | raggiunge il valore 0, l'uscita Q | | | si attiva ed il counter non si | | | decrementa più. | +-----------------------------------+-----------------------------------+ **Esempi** """""""""""""" Il counter è presettato a 10 ed il suo valore in uscita CV è copiato nella variabile **OutValue**. Attivando l'ingresso digitale **Di01M00** il counter viene presettato ed il suo valore in uscita CV è posto a 10, resettando anche l'uscita Q. Sul fronte di attivazione dell'ingresso digitale **Di00M00** il counter è decrementato di 1, quando il valore di conteggio si azzera, il conteggio si arresta e viene attivata l'uscita del counter Q che attiva l'uscita digitale **Do00M00**. Per fare ripartire il conteggio occorre attivare l'ingresso digitale **Di01M00** che presetta il counter. +---------------------------------------+ | **Definizione variabili** | +---------------------------------------+ | |image1| | +---------------------------------------+ **Esempio LD** *(PTP115A100, CTD_LD)* |image2| **Esempio IL** .. code-block:: none CAL FB_CTD (* Call the CTD function block *) LD 10 ST FB_CTD.PV (* Preset value *) LD Di00M01 ST FB_CTD.CD (* On the raising edge of digital input the counter count down *) LD Di01M00 ST FB_CTD.LD (* If the digital input is set the PV value is loaded *) LD FB_CTD.Q ST Do00M00 (* If the counter value is 0 the digital output is set *) LD FB_CTD.CV ST OutValue (* The counter value is copied to the variable *) **Esempio ST** .. code-block:: none FB_CTD(PV:=10); (* Call the CTD function block and preset counter *) FB_CTD.CD:=Di00M00; (* On the raising edge of digital input the counter count down *) FB_CTD.LD:=Di01M00; (* If the digital input is set the PV value is loaded *) Do00M00:=FB_CTD.Q; (* If the counter value is 0 the digital output is set *) OutValue:=FB_CTD.CV; (* The counter value is copied to the variable *) CTU, Counter Up ^^^^^^^^^^^^^^^^^ |image3| +----------+------------------+ | **Type** | **Library** | | | | +----------+------------------+ | FB | eLLabStdLib_B000 | +----------+------------------+ Questo blocco funzione esegue la gestione di un counter in incremento. Agendo sull'ingresso di reset **R** è possibile in qualsiasi momento azzerare il valore del counter **CV**. Ad ogni fronte di attivazione dell'ingresso **CU**, il valore del counter **CV** viene incrementato. Quando il valore del counter **CV** raggiunge il valore di preset, definito su **PV**, l'uscita **Q** viene settata ed il conteggio si arresta. Solo agendo sull'ingresso di reset **R** si potrà resettare il counter e fare ripartire un nuovo conteggio. **L'ingresso di reset R è prioritario sull'ingresso di incremento CU**. +-----------------------------------+-----------------------------------+ | **CU** (BOOL) | Comando incremento counter, ad | | | ogni fronte attivazione il valore | | | del counter CV si incrementa. | +-----------------------------------+-----------------------------------+ | **R** (BOOL) | Comando di reset, attivando | | | l'ingresso il valore del counter | | | CV si resetta. | +-----------------------------------+-----------------------------------+ | **PV** (INT) | Valore di preset, quando il | | | valore del counter CV raggiunge | | | questo valore l'uscita Q si | | | attiva ed il counter non si | | | incrementa più. | +-----------------------------------+-----------------------------------+ | **Q** (BOOL) | Uscita counter, attiva se il | | | valore del counter CV raggiunge | | | il valore definito in preset PV. | +-----------------------------------+-----------------------------------+ | **CV** (INT) | Valore counter, valore di | | | conteggio counter, quando | | | raggiunge il valore di preset PV, | | | l'uscita Q si attiva ed il | | | counter non si incrementa più. | +-----------------------------------+-----------------------------------+ **Esempi** """"""""""" Il counter è presettato a 10 ed il suo valore in uscita CV è copiato nella variabile **OutValue**. Attivando l'ingresso digitale **Di01M00** il counter viene resettato ed il suo valore in uscita CV è posto a 0, resettando anche l'uscita Q. Sul fronte di attivazione dell'ingresso digitale **Di00M00** il counter è incrementato di 1, quando il valore di conteggio raggiunge il valore di preset, il conteggio si arresta e viene attivata l'uscita del counter Q che attiva l'uscita digitale **Do00M00**. Per fare ripartire il conteggio occorre attivare l'ingresso digitale **Di01M00** che resetta il counter. +-----------------------------------------------------------------------+ | **Definizione variabili** | +-----------------------------------------------------------------------+ | |image6| | +-----------------------------------------------------------------------+ **Esempio LD** *(PTP115A100, CTU_LD)* |image7| **Esempio IL** .. code-block:: none CAL FBCTU (* Call the CTU function block *) LD 10 ST FBCTU.PV (* Preset counter *) LD Di00M00 ST FB_CTU.CU (* On the raising edge of digital input the counter count up *) LD Di01M00 ST FB_CTU.R (* If the digital input is set the counter is reset *) LD FBCTU.Q ST Do00M00 (* If the counter value has reached the preset the digital output is set *) LD FB_CTU.CV ST OutValue (* The counter value is copied to the variable *) CTUD, Counter Up/Down ^^^^^^^^^^^^^^^^^^^^^^ |image8| +----------+------------------+ | **Type** | **Library** | | | | +----------+------------------+ | FB | eLLabStdLib_B000 | +----------+------------------+ Questo blocco funzione esegue la gestione di un counter in incremento e decremento. Agendo sull'ingresso di reset R è possibile in qualsiasi momento azzerare il valore del counter **CV**. Agendo sull'ingresso di load **LD** è possibile in qualsiasi momento trasferire il valore di preset definito su **PV** nel counter **CV**. Ad ogni fronte di attivazione dell'ingresso **CU**, il valore del counter **CV** viene incrementato. Quando il valore del counter **CV** raggiunge il valore di preset, definito su **PV**, l'uscita **Q** viene settata ed il conteggio si arresta. Solo agendo sull'ingresso di reset **R** si potrà resettare il counter e fare ripartire un nuovo conteggio. Ad ogni fronte di attivazione dell'ingresso **CD**, il valore del counter **CV** viene decrementato, quando il valore raggiunge 0, l'uscita **Q** viene settata ed il conteggio si arresta. Solo agendo sull'ingresso di load **LD** è possibile presettare il counter e fare ripartire un nuovo conteggio. +-----------------------------------+-----------------------------------+ | **CU** (BOOL) | Comando incremento counter, ad | | | ogni fronte attivazione il valore | | | del counter CV si incrementa | +-----------------------------------+-----------------------------------+ | **CD** (BOOL) | Comando decremento counter, ad | | | ogni fronte attivazione il valore | | | del counter CV si decrementa. | +-----------------------------------+-----------------------------------+ | **R** (BOOL) | Comando di reset, attivando | | | l'ingresso il valore del counter | | | CV si resetta. | +-----------------------------------+-----------------------------------+ | **LD** (BOOL) | Comando di load, attivando | | | l'ingresso il valore di preset | | | PV, viene trasferito nel valore | | | del counter CV. | +-----------------------------------+-----------------------------------+ | **PV** (INT) | Valore di preset, quando il | | | valore del counter CV raggiunge | | | questo valore l'uscita Q si | | | attiva ed il counter non si | | | incrementa più. | +-----------------------------------+-----------------------------------+ | **QU** (BOOL) | Uscita counter up, attiva se il | | | valore del counter CV raggiunge | | | il valore definito in preset PV. | +-----------------------------------+-----------------------------------+ | **QD** (BOOL) | Uscita counter down, attiva se il | | | valore del counter CV raggiunge | | | il valore 0. | +-----------------------------------+-----------------------------------+ | **CV** (INT) | Valore counter, valore di | | | conteggio counter, quando | | | raggiunge il valore di preset PV, | | | l'uscita Q si attiva ed il | | | counter non si incrementa più. | +-----------------------------------+-----------------------------------+ **Esempi** """""""""""" Il counter è presettato a 10 ed il suo valore in uscita CV è copiato nella variabile **VarOut**. Attivando l'ingresso digitale **Di02M00** il counter viene resettato ed il suo valore in uscita CV è posto a 0, resettando anche l'uscita QU. Attivando l'ingresso digitale **Di03M00** il counter viene presettato ed il suo valore in uscita CV è posto a 10, resettando anche l'uscita QD. Sul fronte di attivazione dell'ingresso digitale **Di00M00** il counter è incrementato di 1, quando il valore di conteggio raggiunge il valore di preset, il conteggio si arresta e viene attivata l'uscita del counter QU che attiva l'uscita digitale **Do00M00**. Per fare ripartire il conteggio occorre attivare l'ingresso digitale **Di02M00** che resetta il counter. Sul fronte di attivazione dell'ingresso digitale **Di01M00** il counter è decrementato di 1, quando il valore di conteggio si azzera, il conteggio si arresta e viene attivata l'uscita del counter QD che attiva l'uscita digitale **Do01M00**. Per fare ripartire il conteggio occorre attivare l'ingresso digitale **Di03M00** che presetta il counter. +-----------------------------------------------------------------------+ | **Definizione variabili** | +-----------------------------------------------------------------------+ | |image11| | +-----------------------------------------------------------------------+ **Esempio LD** *(PTP115A100, CTUD_LD)* |image12| **Esempio IL** .. code-block:: none CAL FB_CTUD (* Call the CTUD function block *) LD 10 ST FB_CTUD.PV (* Preset value *) LD Di00M00 ST FB_CTUD.CU (* On the raising edge of digital input the counter count up *) LD Di01M00 ST FB_CTUD.CD (* On the raising edge of digital input the counter count down *) LD Di02M00 ST FB_CTUD.R (* If the digital input is set the counter is reset *) LD Di03M00 ST FB_CTUD.LD (* If the digital input is set the PV value is loaded *) LD FB_CTUD.QU ST Do00M00 (* If the counter value has reached the preset the digital output is set *) LD FB_CTUD.QD ST Do01M00 (* If the counter value is 0 the digital output is set *) LD FB_CTUD.CV ST OutValue (* The counter value is copied to the variable *) **Esempio ST** .. code-block:: none FB_CTUD(PV:=10); (* Call the CTD function block and preset counter *) FB_CTUD.CU:=Di00M00; (* On the raising edge of digital input the counter count up *) FB_CTUD.CD:=Di01M00; (* On the raising edge of digital input the counter count down *) FB_CTUD.R:=Di02M00; (* If the digital input is set the counter is reset *) FB_CTUD.LD:=Di03M00; (* If the digital input is set the PV value is loaded *) Do00M00:=FB_CTUD.QU; (* If the counter value has reached the preset the digital output is set *) Do01M00:=FB_CTUD.QD; (* If the counter value is 0 the digital output is set *) OutValue:=FBCTUD.CV; (* The counter value is copied to the variable *) .. |image0| image:: media/image1.jpg :width: 0.77153in :height: 0.93681in .. |image1| image:: media/image2.jpg :width: 7.08681in :height: 0.52361in .. |image2| image:: media/image3.jpg :width: 7.08681in :height: 1.35069in .. |image3| image:: media/image4.jpg :width: 0.74028in :height: 0.89792in .. |image4| image:: media/image5.jpg :width: 7.08681in :height: 0.52361in .. |image5| image:: media/image6.jpg :width: 7.08681in :height: 1.31111in .. |image6| image:: media/image5.jpg :width: 7.08681in :height: 0.52361in .. |image7| image:: media/image6.jpg :width: 7.08681in :height: 1.31111in .. |image8| image:: media/image7.jpg :width: 0.75208in :height: 1.25972in .. |image9| image:: media/image8.jpg :width: 7.08681in :height: 0.51181in .. |image10| image:: media/image9.jpg :width: 7.08681in :height: 1.79931in .. |image11| image:: media/image8.jpg :width: 7.08681in :height: 0.51181in .. |image12| image:: media/image9.jpg :width: 7.08681in :height: 1.79931in