Skip to content

Commit

Permalink
Add new SCALE function block for signal processing
Browse files Browse the repository at this point in the history
Created a new XML file defining the SCALE function block for scaling input values to desired output range in the signal processing library.
  • Loading branch information
franz-hoepfinger-4diac authored and azoitl committed Sep 19, 2024
1 parent 496a475 commit 5aef5b0
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions data/typelibrary/signalprocessing-1.0.0/typelib/SCALE.fct
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<Function Name="SCALE" Comment="Scaling Function Block">
<Identification Standard="61499-1" Description="Copyright (c) 2024 HR Agrartechnik GmbH &#10; &#10;This program and the accompanying materials are made &#10;available under the terms of the Eclipse Public License 2.0 &#10;which is available at https://www.eclipse.org/legal/epl-2.0/ &#10; &#10;SPDX-License-Identifier: EPL-2.0&#10;&#10;was inspired by this Video: &#10;EP2 - CODESYS: Create Scaling Function Block&#10;https://www.youtube.com/watch?v=Ir6QAxxDarI" >
</Identification>
<VersionInfo Organization="HR Agrartechnik GmbH" Version="1.0" Author="Franz Höpfinger" Date="2024-09-19">
</VersionInfo>
<CompilerInfo packageName="signalprocessing">
</CompilerInfo>
<InterfaceList>
<EventInputs>
<Event Name="REQ" Type="Event" Comment="">
<With Var="IN"/>
<With Var="MAX1"/>
<With Var="MIN1"/>
<With Var="MAX2"/>
<With Var="MIN2"/>
</Event>
</EventInputs>
<EventOutputs>
<Event Name="CNF" Type="Event" Comment="">
<With Var=""/>
</Event>
</EventOutputs>
<InputVars>
<VarDeclaration Name="IN" Type="REAL" Comment="Input to be Scaled"/>
<VarDeclaration Name="MAX1" Type="REAL" Comment="Maximum Input"/>
<VarDeclaration Name="MIN1" Type="REAL" Comment="Minimum Input"/>
<VarDeclaration Name="MAX2" Type="REAL" Comment="Maximum Ouput"/>
<VarDeclaration Name="MIN2" Type="REAL" Comment="Minimum Output"/>
</InputVars>
<OutputVars>
<VarDeclaration Name="" Type="REAL" Comment=""/>
</OutputVars>
</InterfaceList>
<FunctionBody>
<ST><![CDATA[PACKAGE signalprocessing;
(* Scaling Function Block *)
FUNCTION SCALE : REAL
VAR_INPUT
IN : REAL; // Input to be Scaled
MAX1 : REAL; // Maximum Input
MIN1 : REAL; // Minimum Input
MAX2 : REAL; // Maximum Ouput
MIN2 : REAL; // Minimum Output
END_VAR
SCALE := (IN - MIN1) * (MAX2 - MIN2) / (MAX1 - MIN1) + MIN2;
END_FUNCTION
]]></ST>
</FunctionBody>
</Function>

0 comments on commit 5aef5b0

Please sign in to comment.