SCOUNT: Up/down counting with overshoot signaling
Original instructions
Function description
The SCOUNT function carries out up/down counting with overshoot signaling.
The additional parameters EN and ENO can be configured.
Representation in FBD
Representation:
Representation in LD
Representation:
Representation in IL
Representation:
LD Valid
SCOUNT Presel_Value, Count_Up, Count_Down, Minimum, Maximum, Mem_Word, Output_Qmin, Output_Qmax, Count_Value
Representation in ST
Representation:
SCOUNT(Valid, Presel_Value, Count_Up, Count_Down, Minimum, Maximum, Mem_Word, Output_Qmin, Output_Qmax, Count_Value);
Description of parameters
The following table describes the input parameters:
Parameter
Type
Comment
Enable
Enable input selected, the function is only executed if it is Valid = 1.
Presel_Value
Preset value, that is the initial count value.
Count_Up
Upcounter input, on each pulse, Count_Value is incremented by 1.
Count_Down
Downcounter input, on each pulse, Count_Value is decremented by 1.
Minimum
Minimum count value, when: Count_Value = Minimum,
Output_Qmin = 1.
Maximum
Maximum count value, when: Count_Value = Maximum,
Output_Qmin = 1.
The following table describes the input/output parameters:
Parameter
Type
Comment
Mem_Word
Integer used as an input and an output enabling up/down counter inputs to be stored:
  • bit 0, for Count_Up,
  • bit 1, for Count_Down
The following table describes the output parameters:
Parameter
Type
Comment
Output_Qmin
Output which indicates that the count value has reached the minimum threshold:
Count_Value = Minimum, Output_Qmin = 1
Output_Qmax
Output which indicates that the count value has reached the maximum threshold:
Count_Value = Maximum, Output_Qmax = 1
Count_Value
Current count value.
NOTE:
  • If (en) = 0 then the function is no longer enabled and on each call, we have:
    Output_Qmin = Output_Qmax = 0
    Mem_Word:X0 = Mem_Word:X1 = 0, Count_Value = Presel_Value
  • If Maximum > Minimum then:
    Count_ValueMaximum entails: Output_Qmax = 1 and Output_Qmin = 0
    Minimum < Count_Value < Maximum entails: Output_Qmax = Output_Qmin = 0
    Count_ValueMinimum entails: Output_Qmax = 0 and Output_Qmin = 1
  • If Maximum < Minimum then:
    MaximumCount_ValueMinimum entails: Output_Qmax = 1 and Output_Qmin = 0
    Count_Value < Maximum entails: Output_Qmax = 0 and Output_Qmin = 1
    Count_Value > Maximum entails: Output_Qmax = 1 and Output_Qmin = 0
  • If Maximum = Minimum then:
    Count_Value < Maximum and Minimum entails: Output_Qmax = 0 and Output_Qmin = 1
    Count_ValueMaximum and Minimum entails: Output_Qmax = 1 and Output_Qmin = 0
  • A modification of the Presel_Value parameter with Enable set to 1 has no impact on operation.
  • A negative value for the Presel_Value and Minimum parameters is interpreted as a nil value.
  • A value of less than 1 for the Maximum parameter is interpreted as equal to 1.
Timing diagram
Functional timing diagram: