ROTATION_DIFFERENCE (FB) ¶ FUNCTION_BLOCK ROTATION_DIFFERENCE Computes the difference between two UINT values without rollover This function block receives two values e.g. from an motion encoder and calculates the difference between the two positions. If curValue := 65535 and lastValue := 15, a negative rotation is detected and diffValues := -16. If lastValue := 65535 and curValue := 15, a positive rotation is detected and diffValues := 16. InOut: Scope Name Type Comment Input curValue UINT Current value of rotation lastValue UINT Last value of rotation Output diffValues INT Difference between the two values without rollover
STATISTICS_INT (FB) ¶ FUNCTION_BLOCK STATISTICS_INT Calculates minimum, maximum, and average of an input value The calculation is done over time and can be reset in order to start a fresh caluclation/statistic. InOut: Scope Name Type Initial Comment Input IN INT Input value RESET BOOL TRUE : AVG set to 0, MN and MX to minimum and maximum possible integer values Output MN INT 32767 Minimum value MX INT -32768 Maximum value AVG INT Average value
STATISTICS_REAL (FB) ¶ FUNCTION_BLOCK STATISTICS_REAL Calculates minimum, maximum, and average of an input value The calculation is done over time and can be reset in order to begin a fresh caluclation/statistic. InOut: Scope Name Type Initial Comment Input IN REAL Input value RESET BOOL TRUE : AVG set to 0, MN and MX to minimum and maximum possible real values Output MN REAL 3.402823466E+38 Minimum value MX REAL -3.402823466E+38 Maximum value AVG REAL Average value
VARIANCE (FB) ¶ FUNCTION_BLOCK VARIANCE Calculates the mathematical variance of a variable over time In this case, over time means that the variance is extended for each call to the function block until a reset is done. InOut: Scope Name Type Comment Input IN REAL Input value RESET BOOL Reset Output OUT REAL Variance
Signals ¶ BLINK (FunctionBlock) FREQ_MEASURE (FunctionBlock) GEN (FunctionBlock)
BLINK (FB) ¶ FUNCTION_BLOCK BLINK Simulates a blinking signal (turning on and off for specific durations) InOut: Scope Name Type Comment Input ENABLE BOOL TRUE : Starts blinking FALSE : Stops blinking whereas OUT keeps its value TIMELOW TIME Time for OUT to be FALSE TIMEHIGH TIME Time for OUT to be TRUE Output OUT BOOL Output value, starts with FALSE and switches between TRUE and FALSE for the given high and low times
FREQ_MEASURE (FB) ¶ FUNCTION_BLOCK FREQ_MEASURE Measures the frequency of a signal InOut: Scope Name Type Initial Comment Input IN BOOL Input signal PERIODS INT (1..10) 1 A period is the time between two rising edges of the input signal. OUT will equal the average frequency during the given PERIODS (number of periods; minimal 1 maximal 10). The function block will not work unless this value is between 1 and 10. RESET BOOL Reset measurement Output OUT REAL Frequency [Hz] VALID BOOL FALSE : As long as the first measure has been finished. Or time distance between two rising edges > 3 * OUT . (Indicates that something is wrong with the inputs)
GEN (FB) ¶ FUNCTION_BLOCK GEN Generates periodic functions of different, given types The generation may be done relative to a specific time base or a given call-count base ( BASE ). An example set of available types of periodic functions are shown in the following image. InOut: Scope Name Type Initial Comment Input MODE GEN_MODE Types available: TRIANGLE : Triangular from - AMPLITUDE to + AMPLITUDE TRIANGLE_POS : Triangular from 0 to + AMPLITUDE SAWTOOTH_RISE : Sawtooth increasing from - AMPLITUDE to + AMPLITUDE SAWTOOTH_FALL : Sawtooth decreasing from + AMPLITUDE to - AMPLITUDE RECTANGLE : Rectangular switching from - AMPLITUDE to + AMPLITUDE SINE : Sine COSINE : Cosine BASE BOOL FALSE : Period referring to call ( CYCLES ) TRUE : Period referring to time ( PERIOD ) PERIOD TIME TIME#1s0ms Period time, only relevant if BASE = TRUE CYCLES INT 1000 Number of calls per period, only relevant if BASE = FALSE AMPLITUDE INT Amplitud of the function to be generated RESET BOOL TRUE : Sets OUT to zero Output OUT INT Generated function value
TimerSwitch ¶ A timer switch is a clock that switches a number of outputs on or off at set times. The switching times are individually configurable. The following snippet exposes the definition of a specific TimeZone . Example The main islands of New Zealand use New Zealand Standard Time (NZST), 12 hours in advance of UTC. During summer months — from the last Sunday in September until the first Sunday in April — daylight saving time (NZDT) is observed and clocks are advanced one hour. See: https://en.wikipedia.org/wiki/Time_in_New_Zealand tzTimeZoneNZST : TimeZone := ( iBias := 12 * 60 (* T#1M *) , asgPeriod := [ ( (* (NZDT -> NZST) - First Sunday in April at 03:00:00.000 (NZDT) *) sName:='NZST', dtDate := (uiMonth := 4, eWeekday := WEEKDAY.SUNDAY, uiDay := 1, uiHour := 3) ),( (* (NZST -> NZDT) - Last Sunday in September at 02:00:00.000 (NZST) *) sName := 'NZDT', dtDate := (uiMonth := 9, eWeekday := WEEKDAY.SUNDAY, uiDay := 5, uiHour := 2), iBias := 60 (* T#1M *) )] ); Note Due to current deficiencies in the compiler, no constants can be used for the tzTimeZone input of the TimerSwitch block. It is therefore necessary to declare a variable of type TimeZone and then assign the values of the predefined constants (e.g. TSW.gc_tzTimeZoneCET or TSW.gc_tzTimeZoneUTC ) to this variable. tzTimeZoneUTC : TimeZone := TSW.gc_tzTimeZoneUTC ; myTimerSwitch : TimerSwitch := ( tzTimeZone := tzTimeZoneUTC ); Due to another deficiencies in the compiler, the data type of the input aslSchedule of the TimerSwitch block is displayed wrongly. The following would be correct: FUNCTION_BLOCK PUBLIC FINAL TimerSwitch EXTENDS CBML.LConC IMPLEMENTS ITimeSwitch , IDateTimeProvider VAR_INPUT CONSTANT /// Source for the current date and time information in milliseconds since 1.1.1970 00:00:00.000 itfDateTimeProvider : IDateTimeProvider := Globals.g_dtpDateTimeProvider ; /// Compensation speed [ms/h] for the transition from one time zone period to another. tCompensationSpeed : TIME ; END_VAR VAR_IN_OUT (* CONSTANT *) /// Switching Schedule aslSchedule : ARRAY [*] OF Schedule ; END_VAR [...] Enums ERROR (Enum) PERIOD (Enum) WEEKDAY (Enum) FunctionBlocks DateTimeProvider (FunctionBlock) GetDateTime (Method) TimerSwitch (FunctionBlock) IDateTimeProvider GetDateTime (Method) Functions CombineDateTime (Function) DateTimeFromWeek (Function) DayOfWeek (Function) GetDateTime (Function) GetLocalDateTime (Function) GetTimeStampsDifference (Function) IsLeapYear (Function) JoinDateTime (Function) LocalDateTime (Function) SeparateDateTime (Function) SplitDateTime (Function) WeekOfYear (Function) GlobalConstants DAY_FLAGS (GVL) TSW (GVL) Interfaces IDateTimeProvider (Interface) GetDateTime (Method) Structs DateTime (Struct) Schedule (Struct) Segment (Struct) TimeZone (Struct) Types DAY (Alias) DAYS (Alias) HOUR (Alias) MILLISECOND (Alias) MINUTE (Alias) MONTH (Alias) SECOND (Alias) TZ_NAME (Alias) WEEK (Alias) YEAR (Alias)
Enums ¶ ERROR (Enum) PERIOD (Enum) WEEKDAY (Enum)