modelCounter
Extends from Interfaces.BaseCounter (Partial interface of a generic counter).
Information
Description
Model of an Up-Down counter.
At each time step Ts the inputs are read and the new output values Q and
CV are computed.
In the former image, are reported the S (Set), R (Reset), CU (CountUP),
CD (CountDown) signals.
The latter images contains the CV (Current Value) and the PV(Preset Value).

The counter update the CV when the Set signal rises, then for each rising edge of the Count Up (CU)
or Count Down (CD) signals the CV is incremented or decremented by 1.
The Set signal has to be high during this phase, otherwise the rising edges are not detected.
When the Reset (R) signal rises, the counter is reset to zero.
Constraints
The current value CV must be
0 <= CV <= MaxWhere Max is the module of the counter.
Parameters
| Type | Name | Default | Description |
|---|---|---|---|
| Real | Ts (from BaseCounter) | 0.01 | Sampling time [s] |
| Integer | Max (from BaseCounter) | 999 | module of counter |
Connectors
| Type | Name | Default | Description |
|---|---|---|---|
| Modelica.Blocks.Interfaces.BooleanInput | CU (from BaseCounter) | Count Up: The counter is incremented by 1 if the signal state changes from 0 to 1 | |
| Modelica.Blocks.Interfaces.BooleanInput | CD (from BaseCounter) | Count Down: The counter is decremented by 1 if the signal state changes from 0 to 1 | |
| Modelica.Blocks.Interfaces.BooleanInput | S (from BaseCounter) | set: Sets the counter with the value at the Preset Value (PV) | |
| Modelica.Blocks.Interfaces.BooleanInput | R (from BaseCounter) | reset: Sets the counter whit the value 0, and stop the counting | |
| Modelica.Blocks.Interfaces.IntegerInput | PV (from BaseCounter) | Preset Value | |
| Modelica.Blocks.Interfaces.IntegerOutput | CV (from BaseCounter) | Current Value | |
| Modelica.Blocks.Interfaces.BooleanOutput | Q (from BaseCounter) | status of the counter (1: counting, 0: not counting) |
Components
| Type | Name | Default | Description |
|---|---|---|---|
| Integer | Value | ||
| Boolean | CUd | ||
| Boolean | CDd | ||
| Boolean | Sd |
Revisions
- First release of the Industrial Control Systems: April-May 2012
- List of revisions:
- 11 May 2012 (author: Marco Bonvini)
- Main Authors:
- Marco Bonvini; <bonvini@elet.polimi.it>
- Alberto Leva <leva@elet.polimi.it>
- Politecnico di Milano
- Dipartimento di Elettronica e Informazione
- Via Ponzio 34/5
- 20133 Milano - ITALIA -
- Copyright:
- Copyright © 2010-2012, Marco Bonvini and Alberto Leva.
- The IndustrialControlSystems package is free software; it can be redistributed and/or modified under the terms of the Modelica license, see the license conditions and the accompanying disclaimer in the documentation of package Modelica in file "Modelica/package.mo".