Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
en:software:devices:counter2 [2016/11/04 17:46] – [6.2. Gestione COUNTER2] qem103 | en:software:devices:counter2 [2020/07/13 14:52] (current) – qem103 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== DEVICE COUNTER2 ====== | ||
+ | |||
+ | ====== - Introduction ====== | ||
+ | |||
+ | * The internal device COUNTER2 is one tool that resides in the CPU that allows to manage the acquisition of count of a bidirectional incremental transducer. | ||
+ | * The value is converted internally into space and proposed in the unit of your choice to the user. | ||
+ | * Includes the functions of delta DELCNT incremental placements count and capture of the count on hardware interrupts.\\ Wiring and connections of the equipment described in this manual, shall comply with the European standard EN 60204-1. | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | |||
+ | ===== - Installation ===== | ||
+ | |||
+ | ==== - Device declaration in the configuration file (.CNF) ==== | ||
+ | |||
+ | In the configuration file (.CNF), the BUS section must be declared so that you have the hardware resources required for the implementation of the COUNTER2 device. There must be at least one bidirectional meter. The device can also use an interrupt line for the snap functions count on interrupt (such as uploading preset quota).\\ | ||
+ | In the INTDEVICE section of the .CNF file must be added the following definition: | ||
+ | <code QCL> | ||
+ | ; | ||
+ | ; Internal device declaration | ||
+ | ; | ||
+ | INTDEVICE | ||
+ | .. | ||
+ | < | ||
+ | </ | ||
+ | |||
+ | ^:info:^It is necessary that each definition are present on the same line. In case you do not want to assign a resource such as IntL, you still must enter in the appropriate field the string X.^ | ||
+ | |||
+ | where: | ||
+ | |<device name> | ||
+ | |COUNTER2|Keyword that identifies the device bi-directional meter.| | ||
+ | |TCamp|Sample time device (1÷255 ms).| | ||
+ | |QCTL|Address tab counter.| | ||
+ | |IntL|Hardware interrupt line number dedicated for transducer zero pulse during the capture phase of the count (to prevent the device uses this resource to put the X character).| | ||
+ | |||
+ | === - Example === | ||
+ | |||
+ | <code QCL> | ||
+ | ; | ||
+ | ; Internal device declaration | ||
+ | ; | ||
+ | INTDEVICE | ||
+ | Count COUNTER2 | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== - Operation ===== | ||
+ | |||
+ | ==== - Transducer resolution ==== | ||
+ | |||
+ | To use the device you must define the transducer resolution.\\ // | ||
+ | |||
+ | ==== - Operations with counting ==== | ||
+ | |||
+ | You can lock and unlock the updating with //CNTLOCK// and// | ||
+ | |||
+ | ==== - Fast acquisition of counting on hardware interrupts ==== | ||
+ | |||
+ | The //INTENBL// and //INTDSBL// commands enable and disable the interrupt line connected to the transducer' | ||
+ | |||
+ | ==== - Delta count ==== | ||
+ | |||
+ | ^:info:^The modify of the resolution value (// | ||
+ | |||
+ | The device always shows the absolute position of the axis; the counter change can be executed alsowith the direct writing in the new value on the //posit// paramenter.\\ | ||
+ | Wanting to steal 100 units of measure to the count you can: | ||
+ | // | ||
+ | This introduces an error because it imposes the location "// | ||
+ | The //DELCNT// command sum at the count an amount equal to the// | ||
+ | // | ||
+ | //DELCNT Axis// | ||
+ | |||
+ | === - Example === | ||
+ | |||
+ | The reading of the axis is of 2 units and is located at point A. You want to add to the count //posit// three units of measure.\\ | ||
+ | With the instructions: | ||
+ | // | ||
+ | the axis takes the new B position.\\ | ||
+ | With the instructions: | ||
+ | // | ||
+ | //DELCNT Axis//\\ | ||
+ | the axis takes the C position C. | ||
+ | |||
+ | {{: | ||
+ | |||
+ | Note that with the first instructions the axis took a delta less than 3 units and then introduced an error.\\ | ||
+ | If you need to send //DELCNT// commands in succession, It is convenient to calculate the greatness to be summed and send once the command; otherwise Beware not to send subsequent commands without a read statement on device parameter. | ||
+ | |||
+ | === - Example === | ||
+ | |||
+ | // | ||
+ | //DELCNT Axis//\\ | ||
+ | //WAIT Axis: | ||
+ | // | ||
+ | //DELCNT Axis// | ||
+ | |||
+ | |||
+ | ===== - Commands and parameters table ===== | ||
+ | |||
+ | ==== - Symbols used ==== | ||
+ | |||
+ | The **name** of the parameter, state oo command comando is shown to the left side of the table. | ||
+ | |||
+ | **R**\\ | ||
+ | Indicates whether its parameter or state is retentive (upon initialization of the device maintains the previously state defined), or the state assumes upon initialization of the device.\\ | ||
+ | If the device does not need to initialize the field " | ||
+ | R = Retentive\\ | ||
+ | 0 = Upon initialization of the device the value is forced to zero.\\ | ||
+ | 1 = Upon initialization of the device the value is forced to one.\\ | ||
+ | - = Upon initialization of the device is presented significant value. | ||
+ | |||
+ | **D**\\ | ||
+ | Indicates the size of the parameter.\\ | ||
+ | F = Flag\\ | ||
+ | B = Byte\\ | ||
+ | W = Word\\ | ||
+ | L = Long\\ | ||
+ | S = Single Float\\ | ||
+ | |||
+ | === - Conditions === | ||
+ | |||
+ | Describes all of the **conditions that is considered correct or because the command is accepted**.\\ | ||
+ | In some cases, limit values are specified for the acceptance of the parameter: if introduce any values outside the limits set, the data is still accepted; therefore appropriate controls of the application must be provided to ensure the proper functioning.\\ | ||
+ | To run a command, all conditions must be met; otherwise, the command is not sent. | ||
+ | |||
+ | **A**\\ | ||
+ | Indicates the **access mode**.\\ | ||
+ | R = Read.\\ | ||
+ | W = Write.\\ | ||
+ | RW = Read / Write. | ||
+ | |||
+ | ==== - Commands ==== | ||
+ | |||
+ | The commands were ranked by decreasing priority. For example, in the case of contemporary of //CNTLOCK// and// | ||
+ | |||
+ | ^Name^Conditions^Description^ | ||
+ | |CNTLOCK|st_init = 1|**Counter lock**\\ Blocks the acquisition of axis count even if the transducer continues to send signals. At this stage the possible displacement of the axis is not detected.\\ Activates the // | ||
+ | |CNTUNLOCK|st_init = 1|**Counter unlock**\\ Unlock the axis count. Is rehabilitated the updating of the count.\\ Disable the // | ||
+ | |CNTREV|st_init = 1|**Counter reverse**\\ Invert the phases of the transducer inside the card. Is then reversed the direction of the count (increase/ | ||
+ | |CNTDIR|st_init = 1|**Counter direct**\\ The axis counting is not reversed. Disable the // | ||
+ | |INTENBL|st_init = 1\\ capture> | ||
+ | |INTDSBL|st_init = 1|**Interrupt disable**\\ Disable the count capture.\\ Disable the // | ||
+ | |RSCAPTURE|st_init = 1|**Reset capture**\\ Disable the // | ||
+ | |DELCNT|st_init = 1\\ st_intenbl = 0|**Delta counter**\\ The count (axis position) is changed by adding algebraically the value specified in the delta parameter (//posit = posit + delta//).| | ||
+ | |||
+ | ==== - Parameters ==== | ||
+ | |||
+ | ^Name^D^R^A^Conditions^Description^ | ||
+ | |cntratio|L|R|R-W|No|**Counter ratio**\\ Defines how the transducer pulses must be multiplied so that the acquisition of movements is expressed in the unit of measure desired. By setting 100000 the count variation is 1 bit per pulse transducer.\\ Valid range: 374 ÷ 400000| | ||
+ | |posit|L|R|R-W|No|**Actual position**\\ Is the value of the instantaneous position of the axis.\\ Value expressed in units of measurement (Um).\\ Valid range: -999999 ÷ 999999| | ||
+ | |delta|L|R|R-W|No|**Delta counter**\\ Is the value that is added to the count when sending a DELCNT command.\\ Value expressed in units of measurement (Um).\\ Valid range: -999999 ÷ 999999.| | ||
+ | |capture|B|R|R-W|No|**Capture mode**\\ Defines how to count is captured on hardware interrupts.\\ **0** = Disable.\\ **1** = Single capture on falling edge.\\ **2** = Single capture on the rising edge.\\ **N.B.** The capture of the counting is enabled if the state st_intenbl = 1.| | ||
+ | |||
+ | ==== - Status ==== | ||
+ | |||
+ | ^Name^D^R^A^Conditions^Description^ | ||
+ | |st_cntlock|F|R|R|No|**Counter locked**\\ Counting signaling axis is blocked.\\ **0** = Axis count unlocked.\\ **1** = Axis count blocked.| | ||
+ | |st_cntrev|F|R|R|No|**Counter reversed**\\ Inverted axis count report.\\ **0** = Axis count not inverted.\\ **1** = Inverted axis count.| | ||
+ | |st_intenbl|F|0|R|No|**Interrupt enabled**\\ Reports enabling the capture of the count from hardware interrupt line. Is activated by the INTENBL command and disabled from INTDSBL command. Is automatically disabled to capture occurred.\\ **0** = Capture of the count is not enabled.\\ **1** = Capture of count enabled.| | ||
+ | |st_capture|F|0|R|No|**Counter capture**\\ Is activated at the capture of the count; is reset from the // | ||
+ | |||
+ | |||
+ | ===== - Limitations ===== | ||
+ | |||
+ | If you change the // | ||
+ | |||
+ | |||
+ | ===== - Application example ===== | ||
+ | |||
+ | ==== - Configuration file ==== | ||
+ | |||
+ | <code QCL> | ||
+ | ; | ||
+ | ; Module Name: Ex_Count.CNF | ||
+ | ; Author: QEM srl Date : 01/05/99 | ||
+ | ; System: QMove1 / QCL3 | ||
+ | ; Functionality: | ||
+ | ; | ||
+ | ; [1] - Sample application to use the COUNTER 2 device | ||
+ | ; | ||
+ | |||
+ | ; | ||
+ | ; Defining Constants | ||
+ | ; | ||
+ | CONST | ||
+ | |||
+ | ; | ||
+ | ; SYSTEM Variables Definition | ||
+ | ; | ||
+ | SYSTEM | ||
+ | slPrsPos | ||
+ | slSet1 | ||
+ | slSet2 | ||
+ | |||
+ | ; | ||
+ | ; GLOBAL Variables Definition | ||
+ | ; | ||
+ | GLOBAL | ||
+ | |||
+ | ; | ||
+ | ; TIMER Variables Definition | ||
+ | ; | ||
+ | TIMER | ||
+ | |||
+ | ; | ||
+ | ; DATAGROUP Definition | ||
+ | ; | ||
+ | ;DATAGROUP | ||
+ | |||
+ | ; | ||
+ | ; Bus Configuration | ||
+ | ; | ||
+ | BUS | ||
+ | 1 | ||
+ | 2 | ||
+ | 3 . | ||
+ | 4 . | ||
+ | |||
+ | ; | ||
+ | ; INPUT Variables Definition | ||
+ | ; | ||
+ | INPUT | ||
+ | ifAbilZ | ||
+ | ifAxeFermo | ||
+ | |||
+ | ; | ||
+ | ; OUTPUT Variables Definition | ||
+ | ; | ||
+ | OUTPUT | ||
+ | ofGTSet1 | ||
+ | ofLTSet2 | ||
+ | |||
+ | ; | ||
+ | ; Internal Device Declaration | ||
+ | ; | ||
+ | INTDEVICE | ||
+ | ;Name Typo | ||
+ | Axis | ||
+ | |||
+ | END | ||
+ | </ | ||
+ | |||
+ | ==== - COUNTER2 management ==== | ||
+ | |||
+ | <code QCL> | ||
+ | ; | ||
+ | ; File Name : TASK_00.MOD | ||
+ | ; Project | ||
+ | ; Description: | ||
+ | ; | ||
+ | |||
+ | ; | ||
+ | ; Initialization work Axis | ||
+ | ; | ||
+ | Axis: | ||
+ | ; | ||
+ | Axis: | ||
+ | IF slSet1 EQ 0 | ||
+ | slSet1 = 500 | ||
+ | ENDIF | ||
+ | IF slSet2 EQ 0 | ||
+ | slSet2 = 100 | ||
+ | ENDIF | ||
+ | |||
+ | ; | ||
+ | ; Preset search enabled at each step the limit switch | ||
+ | ; ------------------------------- variables used ------------------------------------- | ||
+ | ; slPrsPos : Preset quota set | ||
+ | ; | ||
+ | MAIN: | ||
+ | IF ifAbilZ | ||
+ | ;zero pulse transducer | ||
+ | INTENBL Axis ;Enables the capture of zero-pulse | ||
+ | ;transducer | ||
+ | ELSE | ||
+ | INTDSBL Axis ;Disable the zero pulse | ||
+ | ;transducer capture | ||
+ | ENDIF | ||
+ | | ||
+ | IF Axis: | ||
+ | IF ifAxeFermo | ||
+ | Axis:delta = -(Axis: | ||
+ | DELCNT Axis ; | ||
+ | RSCAPTURE Axis ;Reset the axis's st_capture | ||
+ | ENDIF | ||
+ | ENDIF | ||
+ | |||
+ | ; | ||
+ | ; Comparisons on counting | ||
+ | ; ----------------------------- variables used -------------------------------- | ||
+ | ; slSet1: Comparison quota for ofGTSet1 output | ||
+ | ; slSet1: Comparison quota for ofLTSet2 output | ||
+ | ; | ||
+ | IF Axis:posit GT slSet1 | ||
+ | SETOUT ofGTSet1 | ||
+ | ELSE | ||
+ | RESOUT ofGTSet1 | ||
+ | ENDIF | ||
+ | IF Axis:posit LT slSet2 | ||
+ | SETOUT ofLTSet2 | ||
+ | ELSE | ||
+ | RESOUT ofLTSet2 | ||
+ | ENDIF | ||
+ | |||
+ | ; | ||
+ | ; Final operations | ||
+ | ; | ||
+ | WAIT 1 | ||
+ | JUMP MAIN | ||
+ | | ||
+ | END | ||
+ | </ | ||
+ | |||