Added AnalogInput
This commit is contained in:
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# TcXaeShell Solution File, Format Version 11.00
|
# TcXaeShell Solution File, Format Version 11.00
|
||||||
VisualStudioVersion = 17.10.35827.194
|
VisualStudioVersion = 17.10.35827.194
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{B1E792BE-AA5F-4E3C-8C82-674BF9C0715B}") = "TwinCAT Projekt1", "TwinCAT Projekt1.tsproj", "{775BE4FD-89CE-48D5-8E68-5C84AF95981A}"
|
Project("{B1E792BE-AA5F-4E3C-8C82-674BF9C0715B}") = "BaseComponents", "BaseComponents.tsproj", "{775BE4FD-89CE-48D5-8E68-5C84AF95981A}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
317
TwinCAT Projekt1/BaseComponents.tsproj
Normal file
317
TwinCAT Projekt1/BaseComponents.tsproj
Normal file
@@ -0,0 +1,317 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<TcSmProject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.beckhoff.com/schemas/2012/07/TcSmProject" TcSmVersion="1.0" TcVersion="3.1.4026.19">
|
||||||
|
<DataTypes>
|
||||||
|
<DataType>
|
||||||
|
<Name GUID="{51F782DC-92E3-4391-9C7A-339EB87A42D8}" PersistentType="true">TestAlarms</Name>
|
||||||
|
<DisplayName TxtId=""><![CDATA[NewEventClass_DisplayText]]></DisplayName>
|
||||||
|
<EventId>
|
||||||
|
<Name Id="1">TestError</Name>
|
||||||
|
<DisplayName TxtId=""><![CDATA[Test Error ohne parameter]]></DisplayName>
|
||||||
|
<Severity>Error</Severity>
|
||||||
|
</EventId>
|
||||||
|
<EventId>
|
||||||
|
<Name Id="2">TestWarning</Name>
|
||||||
|
<DisplayName TxtId=""><![CDATA[Test Warning ohne Parameter]]></DisplayName>
|
||||||
|
<Severity>Warning</Severity>
|
||||||
|
</EventId>
|
||||||
|
<Hides>
|
||||||
|
<Hide GUID="{2C256031-B71B-4053-BBA0-1118C08EC292}"/>
|
||||||
|
</Hides>
|
||||||
|
</DataType>
|
||||||
|
</DataTypes>
|
||||||
|
<Project ProjectGUID="{775BE4FD-89CE-48D5-8E68-5C84AF95981A}" TargetNetId="5.167.199.178.1.1" Target64Bit="true" ShowHideConfigurations="#x6">
|
||||||
|
<System>
|
||||||
|
<Settings MaxCpus="2"/>
|
||||||
|
<Tasks>
|
||||||
|
<Task Id="3" Priority="20" CycleTime="100000" AmsPort="350" AdtTasks="true">
|
||||||
|
<Name>PlcTask</Name>
|
||||||
|
</Task>
|
||||||
|
</Tasks>
|
||||||
|
<TypeSystem>
|
||||||
|
<AdditionalTmcFile Name="BaseComponents_Events" File="..\..\gasflow\BaseComponents_Events.tmc"/>
|
||||||
|
</TypeSystem>
|
||||||
|
</System>
|
||||||
|
<Plc>
|
||||||
|
<Project GUID="{4E62D9E7-436C-457D-8DC4-82D2FEF91C96}" Name="PLC" PrjFilePath="PLC\PLC.plcproj" TmcFilePath="PLC\PLC.tmc" ReloadTmc="true" AmsPort="851" FileArchiveSettings="#x000e" CopyTmcToTarget="true" CopyTpyToTarget="false" SymbolicMapping="true">
|
||||||
|
<Instance Id="#x08502000" TcSmClass="TComPlcObjDef" KeepUnrestoredLinks="2" TmcHash="{367F99A2-7D94-70AB-79F0-621299EE7AC9}" TmcPath="PLC\PLC.tmc">
|
||||||
|
<Name>PLC Instance</Name>
|
||||||
|
<CLSID ClassFactory="TcPlc30">{08500001-0000-0000-F000-000000000064}</CLSID>
|
||||||
|
<Vars VarGrpType="1">
|
||||||
|
<Name>PlcTask Inputs</Name>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIErrorLowOn.iAnalogValue</Name>
|
||||||
|
<Comment><![CDATA[ Analog input value]]></Comment>
|
||||||
|
<Type>INT</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIErrorLowOn.xUnderrange</Name>
|
||||||
|
<Comment><![CDATA[ Card has detected an open circuit]]></Comment>
|
||||||
|
<Type>BOOL</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIErrorLowOn.xOverrange</Name>
|
||||||
|
<Comment><![CDATA[ Input is overloaded]]></Comment>
|
||||||
|
<Type>BOOL</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIErrorLowOn.xErrorCard</Name>
|
||||||
|
<Comment><![CDATA[ Input card has error
|
||||||
|
EL30xx also sets this if an underrange or overrange error is present]]></Comment>
|
||||||
|
<Type>BOOL</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIWarningLowOn.iAnalogValue</Name>
|
||||||
|
<Comment><![CDATA[ Analog input value]]></Comment>
|
||||||
|
<Type>INT</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIWarningLowOn.xUnderrange</Name>
|
||||||
|
<Comment><![CDATA[ Card has detected an open circuit]]></Comment>
|
||||||
|
<Type>BOOL</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIWarningLowOn.xOverrange</Name>
|
||||||
|
<Comment><![CDATA[ Input is overloaded]]></Comment>
|
||||||
|
<Type>BOOL</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIWarningLowOn.xErrorCard</Name>
|
||||||
|
<Comment><![CDATA[ Input card has error
|
||||||
|
EL30xx also sets this if an underrange or overrange error is present]]></Comment>
|
||||||
|
<Type>BOOL</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIWarningHighOn.iAnalogValue</Name>
|
||||||
|
<Comment><![CDATA[ Analog input value]]></Comment>
|
||||||
|
<Type>INT</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIWarningHighOn.xUnderrange</Name>
|
||||||
|
<Comment><![CDATA[ Card has detected an open circuit]]></Comment>
|
||||||
|
<Type>BOOL</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIWarningHighOn.xOverrange</Name>
|
||||||
|
<Comment><![CDATA[ Input is overloaded]]></Comment>
|
||||||
|
<Type>BOOL</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIWarningHighOn.xErrorCard</Name>
|
||||||
|
<Comment><![CDATA[ Input card has error
|
||||||
|
EL30xx also sets this if an underrange or overrange error is present]]></Comment>
|
||||||
|
<Type>BOOL</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIErrorHighOn.iAnalogValue</Name>
|
||||||
|
<Comment><![CDATA[ Analog input value]]></Comment>
|
||||||
|
<Type>INT</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIErrorHighOn.xUnderrange</Name>
|
||||||
|
<Comment><![CDATA[ Card has detected an open circuit]]></Comment>
|
||||||
|
<Type>BOOL</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIErrorHighOn.xOverrange</Name>
|
||||||
|
<Comment><![CDATA[ Input is overloaded]]></Comment>
|
||||||
|
<Type>BOOL</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIErrorHighOn.xErrorCard</Name>
|
||||||
|
<Comment><![CDATA[ Input card has error
|
||||||
|
EL30xx also sets this if an underrange or overrange error is present]]></Comment>
|
||||||
|
<Type>BOOL</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIOverrangeOn.iAnalogValue</Name>
|
||||||
|
<Comment><![CDATA[ Analog input value]]></Comment>
|
||||||
|
<Type>INT</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIOverrangeOn.xUnderrange</Name>
|
||||||
|
<Comment><![CDATA[ Card has detected an open circuit]]></Comment>
|
||||||
|
<Type>BOOL</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIOverrangeOn.xOverrange</Name>
|
||||||
|
<Comment><![CDATA[ Input is overloaded]]></Comment>
|
||||||
|
<Type>BOOL</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIOverrangeOn.xErrorCard</Name>
|
||||||
|
<Comment><![CDATA[ Input card has error
|
||||||
|
EL30xx also sets this if an underrange or overrange error is present]]></Comment>
|
||||||
|
<Type>BOOL</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIUnderrangeOn.iAnalogValue</Name>
|
||||||
|
<Comment><![CDATA[ Analog input value]]></Comment>
|
||||||
|
<Type>INT</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIUnderrangeOn.xUnderrange</Name>
|
||||||
|
<Comment><![CDATA[ Card has detected an open circuit]]></Comment>
|
||||||
|
<Type>BOOL</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIUnderrangeOn.xOverrange</Name>
|
||||||
|
<Comment><![CDATA[ Input is overloaded]]></Comment>
|
||||||
|
<Type>BOOL</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIUnderrangeOn.xErrorCard</Name>
|
||||||
|
<Comment><![CDATA[ Input card has error
|
||||||
|
EL30xx also sets this if an underrange or overrange error is present]]></Comment>
|
||||||
|
<Type>BOOL</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIErrorLowOff.iAnalogValue</Name>
|
||||||
|
<Comment><![CDATA[ Analog input value]]></Comment>
|
||||||
|
<Type>INT</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIErrorLowOff.xUnderrange</Name>
|
||||||
|
<Comment><![CDATA[ Card has detected an open circuit]]></Comment>
|
||||||
|
<Type>BOOL</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIErrorLowOff.xOverrange</Name>
|
||||||
|
<Comment><![CDATA[ Input is overloaded]]></Comment>
|
||||||
|
<Type>BOOL</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIErrorLowOff.xErrorCard</Name>
|
||||||
|
<Comment><![CDATA[ Input card has error
|
||||||
|
EL30xx also sets this if an underrange or overrange error is present]]></Comment>
|
||||||
|
<Type>BOOL</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIWarningLowOff.iAnalogValue</Name>
|
||||||
|
<Comment><![CDATA[ Analog input value]]></Comment>
|
||||||
|
<Type>INT</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIWarningLowOff.xUnderrange</Name>
|
||||||
|
<Comment><![CDATA[ Card has detected an open circuit]]></Comment>
|
||||||
|
<Type>BOOL</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIWarningLowOff.xOverrange</Name>
|
||||||
|
<Comment><![CDATA[ Input is overloaded]]></Comment>
|
||||||
|
<Type>BOOL</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIWarningLowOff.xErrorCard</Name>
|
||||||
|
<Comment><![CDATA[ Input card has error
|
||||||
|
EL30xx also sets this if an underrange or overrange error is present]]></Comment>
|
||||||
|
<Type>BOOL</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIWarningHighOff.iAnalogValue</Name>
|
||||||
|
<Comment><![CDATA[ Analog input value]]></Comment>
|
||||||
|
<Type>INT</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIWarningHighOff.xUnderrange</Name>
|
||||||
|
<Comment><![CDATA[ Card has detected an open circuit]]></Comment>
|
||||||
|
<Type>BOOL</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIWarningHighOff.xOverrange</Name>
|
||||||
|
<Comment><![CDATA[ Input is overloaded]]></Comment>
|
||||||
|
<Type>BOOL</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIWarningHighOff.xErrorCard</Name>
|
||||||
|
<Comment><![CDATA[ Input card has error
|
||||||
|
EL30xx also sets this if an underrange or overrange error is present]]></Comment>
|
||||||
|
<Type>BOOL</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIErrorHighOff.iAnalogValue</Name>
|
||||||
|
<Comment><![CDATA[ Analog input value]]></Comment>
|
||||||
|
<Type>INT</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIErrorHighOff.xUnderrange</Name>
|
||||||
|
<Comment><![CDATA[ Card has detected an open circuit]]></Comment>
|
||||||
|
<Type>BOOL</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIErrorHighOff.xOverrange</Name>
|
||||||
|
<Comment><![CDATA[ Input is overloaded]]></Comment>
|
||||||
|
<Type>BOOL</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIErrorHighOff.xErrorCard</Name>
|
||||||
|
<Comment><![CDATA[ Input card has error
|
||||||
|
EL30xx also sets this if an underrange or overrange error is present]]></Comment>
|
||||||
|
<Type>BOOL</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIUnderrangeOff.iAnalogValue</Name>
|
||||||
|
<Comment><![CDATA[ Analog input value]]></Comment>
|
||||||
|
<Type>INT</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIUnderrangeOff.xUnderrange</Name>
|
||||||
|
<Comment><![CDATA[ Card has detected an open circuit]]></Comment>
|
||||||
|
<Type>BOOL</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIUnderrangeOff.xOverrange</Name>
|
||||||
|
<Comment><![CDATA[ Input is overloaded]]></Comment>
|
||||||
|
<Type>BOOL</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIUnderrangeOff.xErrorCard</Name>
|
||||||
|
<Comment><![CDATA[ Input card has error
|
||||||
|
EL30xx also sets this if an underrange or overrange error is present]]></Comment>
|
||||||
|
<Type>BOOL</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIOverrangeOff.iAnalogValue</Name>
|
||||||
|
<Comment><![CDATA[ Analog input value]]></Comment>
|
||||||
|
<Type>INT</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIOverrangeOff.xUnderrange</Name>
|
||||||
|
<Comment><![CDATA[ Card has detected an open circuit]]></Comment>
|
||||||
|
<Type>BOOL</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIOverrangeOff.xOverrange</Name>
|
||||||
|
<Comment><![CDATA[ Input is overloaded]]></Comment>
|
||||||
|
<Type>BOOL</Type>
|
||||||
|
</Var>
|
||||||
|
<Var>
|
||||||
|
<Name>MAIN._fbAnalogInputTest._fbAIOverrangeOff.xErrorCard</Name>
|
||||||
|
<Comment><![CDATA[ Input card has error
|
||||||
|
EL30xx also sets this if an underrange or overrange error is present]]></Comment>
|
||||||
|
<Type>BOOL</Type>
|
||||||
|
</Var>
|
||||||
|
</Vars>
|
||||||
|
<Contexts>
|
||||||
|
<Context>
|
||||||
|
<Id>0</Id>
|
||||||
|
<Name>PlcTask</Name>
|
||||||
|
<ManualConfig>
|
||||||
|
<OTCID>#x02010030</OTCID>
|
||||||
|
</ManualConfig>
|
||||||
|
<Priority>20</Priority>
|
||||||
|
<CycleTime>10000000</CycleTime>
|
||||||
|
</Context>
|
||||||
|
</Contexts>
|
||||||
|
<TaskPouOids>
|
||||||
|
<TaskPouOid Prio="20" OTCID="#x08502001"/>
|
||||||
|
</TaskPouOids>
|
||||||
|
</Instance>
|
||||||
|
</Project>
|
||||||
|
</Plc>
|
||||||
|
<Analytics ConfigVersion="1.4">
|
||||||
|
<Name>ANALYTICS</Name>
|
||||||
|
<ImageId>437</ImageId>
|
||||||
|
<XmlProps><![CDATA[<Address>Hauptstraße 5, 32567 Berlin</Address><Latitude>123.41</Latitude><Longitude>43.4555</Longitude><SystemIdAlias /><DeviceProps></DeviceProps><SelectedDriverVersion>Latest</SelectedDriverVersion><StreamTargets><StreamTargetItem Id="c77d2d3a-36af-40a8-bced-d69e6e281117"><Name>Boot Project Path</Name><Type>FILE</Type><Directory>%TC_BOOTPRJPATH%</Directory><MqttConnectionSettings><Broker>127.0.0.1</Broker><BrokerPort>1883</BrokerPort><UserID /><WithCertificates>false</WithCertificates><CA_Certificate /><Cert_Certificate /><Key_Certificate /><CommunicationTimeout>30000000</CommunicationTimeout><KeepAlivePeriod>600000000</KeepAlivePeriod><TcpBufferSize>32768</TcpBufferSize><SecurityType>NO_SECURITY</SecurityType><Insecure>false</Insecure><IgnoreExpiration>false</IgnoreExpiration><IsPskIdCaseSensitive>false</IsPskIdCaseSensitive><IgnoreCnMismatch>false</IgnoreCnMismatch><TargetPaths>false</TargetPaths><PskMode>HexKey</PskMode></MqttConnectionSettings><TimeType>None</TimeType></StreamTargetItem></StreamTargets><ActivateAlyLogger>false</ActivateAlyLogger>]]></XmlProps>
|
||||||
|
</Analytics>
|
||||||
|
</Project>
|
||||||
|
</TcSmProject>
|
||||||
@@ -21,24 +21,55 @@
|
|||||||
<Compile Include="PlcTask.TcTTO">
|
<Compile Include="PlcTask.TcTTO">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="POUs\FB_Machine.TcPOU">
|
<Compile Include="POUs\Analog\FB_AnalogInput.TcPOU">
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="POUs\Analog\FB_AnalogOutput.TcPOU">
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="POUs\Analog\Types\ST_ANALOG_EW_CONFIG.TcDUT">
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="POUs\Analog\Types\ST_ANALOG_EW_DELAYS.TcDUT">
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="POUs\Analog\Types\ST_ANALOG_EW_LEVELS.TcDUT">
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="POUs\Analog\Types\ST_ANALOG_IO_CONFIG.TcDUT">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="POUs\MAIN.TcPOU">
|
<Compile Include="POUs\MAIN.TcPOU">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="POUs\Tests\FB_Machine.TcPOU">
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="POUs\Tests\MAIN_TESTS.TcPOU">
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="POUs\Unittests\AITests\FB_AnalogInputTest.TcPOU">
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="POUs\Utilities\FB_ReleaseSignal.TcPOU">
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="DUTs" />
|
<Folder Include="DUTs" />
|
||||||
<Folder Include="GVLs" />
|
<Folder Include="GVLs" />
|
||||||
|
<Folder Include="POUs\Analog" />
|
||||||
|
<Folder Include="POUs\Analog\Types" />
|
||||||
|
<Folder Include="POUs\Unittests" />
|
||||||
|
<Folder Include="POUs\Unittests\AITests" />
|
||||||
|
<Folder Include="POUs\Utilities" />
|
||||||
|
<Folder Include="POUs\Tests">
|
||||||
|
<ExcludeFromBuild>true</ExcludeFromBuild>
|
||||||
|
</Folder>
|
||||||
<Folder Include="VISUs" />
|
<Folder Include="VISUs" />
|
||||||
<Folder Include="POUs" />
|
<Folder Include="POUs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PlaceholderReference Include="SLM_Base">
|
|
||||||
<DefaultResolution>SLM_Base, * (Nikon SLM Solutions)</DefaultResolution>
|
|
||||||
<Namespace>SLM_Base</Namespace>
|
|
||||||
</PlaceholderReference>
|
|
||||||
<PlaceholderReference Include="Tc2_Standard">
|
<PlaceholderReference Include="Tc2_Standard">
|
||||||
<DefaultResolution>Tc2_Standard, * (Beckhoff Automation GmbH)</DefaultResolution>
|
<DefaultResolution>Tc2_Standard, * (Beckhoff Automation GmbH)</DefaultResolution>
|
||||||
<Namespace>Tc2_Standard</Namespace>
|
<Namespace>Tc2_Standard</Namespace>
|
||||||
@@ -56,6 +87,10 @@
|
|||||||
<Namespace>Tc3_Module</Namespace>
|
<Namespace>Tc3_Module</Namespace>
|
||||||
<SystemLibrary>true</SystemLibrary>
|
<SystemLibrary>true</SystemLibrary>
|
||||||
</PlaceholderReference>
|
</PlaceholderReference>
|
||||||
|
<PlaceholderReference Include="TcUnit">
|
||||||
|
<DefaultResolution>TcUnit, * (www.tcunit.org)</DefaultResolution>
|
||||||
|
<Namespace>TcUnit</Namespace>
|
||||||
|
</PlaceholderReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="PLC.tmc">
|
<None Include="PLC.tmc">
|
||||||
|
|||||||
633
TwinCAT Projekt1/PLC/POUs/Analog/FB_AnalogInput.TcPOU
Normal file
633
TwinCAT Projekt1/PLC/POUs/Analog/FB_AnalogInput.TcPOU
Normal file
@@ -0,0 +1,633 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<TcPlcObject Version="1.1.0.1">
|
||||||
|
<POU Name="FB_AnalogInput" Id="{532e1013-5a2e-43c7-8863-3ad112d7d7e8}" SpecialFunc="None">
|
||||||
|
<Declaration><![CDATA[FUNCTION_BLOCK FB_AnalogInput
|
||||||
|
VAR_INPUT
|
||||||
|
// Analog input value
|
||||||
|
iAnalogValue AT %I* : INT;
|
||||||
|
|
||||||
|
// Card has detected an open circuit
|
||||||
|
xUnderrange AT%I* : BOOL;
|
||||||
|
|
||||||
|
// Input is overloaded
|
||||||
|
xOverrange AT %I* : BOOL;
|
||||||
|
|
||||||
|
// Input card has error
|
||||||
|
// EL30xx also sets this if an underrange or overrange error is present
|
||||||
|
xErrorCard AT %I* : BOOL;
|
||||||
|
|
||||||
|
// IO config data
|
||||||
|
stAnalogIOConfig : REFERENCE TO ST_ANALOG_IO_CONFIG;
|
||||||
|
|
||||||
|
// Error and warning config data
|
||||||
|
stAnalogEWConfig : REFERENCE TO ST_ANALOG_EW_CONFIG;
|
||||||
|
|
||||||
|
// Global switch to dissable all errors
|
||||||
|
xReleaseErrors : BOOL := TRUE;
|
||||||
|
|
||||||
|
// Enables or dissables errors from min max values
|
||||||
|
xReleaseLimitErrors : BOOL := FALSE;
|
||||||
|
|
||||||
|
// Enables or dissables hardware errors
|
||||||
|
xReleaseHardwareErrors : BOOL := TRUE;
|
||||||
|
|
||||||
|
// Input to confirm all errors
|
||||||
|
xConfirmAlarms : BOOL;
|
||||||
|
|
||||||
|
// Input to tell the fb thats ist used inside a unit test
|
||||||
|
// Fb will not throw error messages
|
||||||
|
{attribute 'hide'}
|
||||||
|
xInUnitTestMode : BOOL := FALSE;
|
||||||
|
END_VAR
|
||||||
|
VAR_OUTPUT
|
||||||
|
// Scaled output value
|
||||||
|
rScaledValue : REAL;
|
||||||
|
|
||||||
|
// Error in function block
|
||||||
|
xError : BOOL;
|
||||||
|
|
||||||
|
// Warning active
|
||||||
|
xWarning : BOOL;
|
||||||
|
|
||||||
|
// Low level error
|
||||||
|
xErrorLow : BOOL;
|
||||||
|
|
||||||
|
// Low level warning
|
||||||
|
xWarningLow : BOOL;
|
||||||
|
|
||||||
|
// High level warning
|
||||||
|
xWarningHigh : BOOL;
|
||||||
|
|
||||||
|
//High level error
|
||||||
|
xErrorHigh : BOOL;
|
||||||
|
END_VAR
|
||||||
|
VAR
|
||||||
|
// Scaling factor for conversion
|
||||||
|
_rConversionFactor : REAL;
|
||||||
|
|
||||||
|
// Base offset for scaling factor
|
||||||
|
_rBaseOffset : REAL;
|
||||||
|
|
||||||
|
// Min warning level
|
||||||
|
_rMinWarningLevel : REAL;
|
||||||
|
|
||||||
|
// Max warning level
|
||||||
|
_rMaxWarningLevel : REAL;
|
||||||
|
|
||||||
|
// Min error level
|
||||||
|
_rMinErrorLevel : REAL;
|
||||||
|
|
||||||
|
// Max error level
|
||||||
|
_rMaxErrorLevel : REAL;
|
||||||
|
|
||||||
|
// Scaling config error
|
||||||
|
_xConfigError : BOOL := FALSE;
|
||||||
|
|
||||||
|
// Limits config error
|
||||||
|
_xEWConfigError : BOOL := FALSE;
|
||||||
|
|
||||||
|
// Delayed Signal warning low
|
||||||
|
_fbSignalDelayWarningLow : FB_ReleaseSignal;
|
||||||
|
|
||||||
|
// Delayed Signal warning high
|
||||||
|
_fbSignalDelayWarningHigh : FB_ReleaseSignal;
|
||||||
|
|
||||||
|
// Delayed Signal error low
|
||||||
|
_fbSignalDelayErrorLow : FB_ReleaseSignal;
|
||||||
|
|
||||||
|
// Delayed signal error high
|
||||||
|
_fbSignalDelayErrorHigh : FB_ReleaseSignal;
|
||||||
|
|
||||||
|
// Delayed signal for underrange error
|
||||||
|
_fbSignalDelayUnderrangeError : FB_ReleaseSignal;
|
||||||
|
|
||||||
|
// Delayed signal for overload error
|
||||||
|
_fbSignalDelayOverloadError : FB_ReleaseSignal;
|
||||||
|
|
||||||
|
// Delayed signal for card error
|
||||||
|
_fbSignalDelayCardError : FB_ReleaseSignal;
|
||||||
|
|
||||||
|
// Helper variables used in reset error flag
|
||||||
|
_xAlarmsActive : BOOL;
|
||||||
|
_xInputErrorsActive : BOOL;
|
||||||
|
|
||||||
|
// Max process value
|
||||||
|
_iAIMax : INT;
|
||||||
|
|
||||||
|
// Min process value
|
||||||
|
_iAIMin : INT;
|
||||||
|
|
||||||
|
// Clamped analog value
|
||||||
|
_iClampedAnalogValue : INT;
|
||||||
|
|
||||||
|
// Name of the function block
|
||||||
|
_sName : STRING;
|
||||||
|
|
||||||
|
//{attribute 'instance-path'}
|
||||||
|
//{attribute 'noinit'}
|
||||||
|
//_sDebugName : STRING;
|
||||||
|
|
||||||
|
// Alarm handlers
|
||||||
|
_fbAlarmCardError : FB_TcAlarm;
|
||||||
|
_fbAlarmUnderrange : FB_TcAlarm;
|
||||||
|
_fbAlarmOverload : FB_TcAlarm;
|
||||||
|
_fbAlarmConfigError : FB_TcAlarm;
|
||||||
|
|
||||||
|
_fbAlarmErrorLow : FB_TcAlarm;
|
||||||
|
_fbAlarmWarningLow : FB_TcAlarm;
|
||||||
|
_fbAlarmWarningHigh : FB_TcAlarm;
|
||||||
|
_fbAlarmErrorHigh : FB_TcAlarm;
|
||||||
|
END_VAR
|
||||||
|
]]></Declaration>
|
||||||
|
<Implementation>
|
||||||
|
<ST><![CDATA[// =========
|
||||||
|
// Prechecks
|
||||||
|
// =========
|
||||||
|
|
||||||
|
// Calculate scaling factors,
|
||||||
|
// scaling will be zero in case
|
||||||
|
// of invalid scaling parameters.
|
||||||
|
// Also checks if reference to config data is valid.
|
||||||
|
CalcScalingFactors();
|
||||||
|
|
||||||
|
// Check error and warning levels config
|
||||||
|
// Will later raise alarms if config is wrong
|
||||||
|
CheckEWLevels();
|
||||||
|
|
||||||
|
|
||||||
|
// ===========================
|
||||||
|
// Config error alarm handling
|
||||||
|
// ===========================
|
||||||
|
|
||||||
|
IF xReleaseErrors AND (_xConfigError OR (_xEWConfigError AND xReleaseLimitErrors)) THEN
|
||||||
|
// Latch error
|
||||||
|
xError := TRUE;
|
||||||
|
|
||||||
|
// Raise alarm
|
||||||
|
IF (NOT xInUnitTestMode) AND (NOT _fbAlarmConfigError.bRaised) THEN
|
||||||
|
_fbAlarmConfigError.Raise(0);
|
||||||
|
END_IF
|
||||||
|
END_IF
|
||||||
|
|
||||||
|
// Clear alarm and confirm
|
||||||
|
// Auto confirm because error can only be cleared
|
||||||
|
// throught user action
|
||||||
|
IF (NOT _xConfigError) AND (NOT _xEWConfigError) AND _fbAlarmConfigError.bRaised THEN
|
||||||
|
_fbAlarmConfigError.Clear(0, TRUE);
|
||||||
|
END_IF
|
||||||
|
|
||||||
|
|
||||||
|
// =============================================
|
||||||
|
// Abort if config parameter are not a valid ref
|
||||||
|
// =============================================
|
||||||
|
|
||||||
|
IF (NOT __ISVALIDREF(stAnalogIOConfig)) AND (NOT __ISVALIDREF(stAnalogEWConfig)) THEN
|
||||||
|
RETURN;
|
||||||
|
END_IF
|
||||||
|
|
||||||
|
|
||||||
|
// ========================
|
||||||
|
// Analog value calculation
|
||||||
|
// ========================
|
||||||
|
|
||||||
|
// Clamp analogue input levels
|
||||||
|
_iClampedAnalogValue := MAX(_iAIMin, iAnalogValue);
|
||||||
|
_iClampedAnalogValue := MIN(_iAIMax, _iClampedAnalogValue);
|
||||||
|
|
||||||
|
// Calc scaled value
|
||||||
|
rScaledValue := _iClampedAnalogValue * _rConversionFactor + _rBaseOffset;
|
||||||
|
|
||||||
|
|
||||||
|
// =========================
|
||||||
|
// Underrange alarm handling
|
||||||
|
// =========================
|
||||||
|
|
||||||
|
// Filter underrange error signal
|
||||||
|
_fbSignalDelayUnderrangeError(
|
||||||
|
xSignal:= xUnderrange,
|
||||||
|
xRelease:= stAnalogIOConfig.xUsed AND xReleaseErrors AND xReleaseHardwareErrors,
|
||||||
|
timOnDelay:= stAnalogEWConfig.stDelays.timHardwareSignalLevelOn,
|
||||||
|
timOffDelay:= stAnalogEWConfig.stDelays.timHardwareSignalLevelOff);
|
||||||
|
|
||||||
|
// Latch error signal
|
||||||
|
IF _fbSignalDelayUnderrangeError.xReleaseSignal THEN
|
||||||
|
xError := TRUE;
|
||||||
|
END_IF
|
||||||
|
|
||||||
|
// Raise alarm
|
||||||
|
IF _fbSignalDelayUnderrangeError.xReleaseSignal AND (NOT xInUnitTestMode) AND (NOT _fbAlarmUnderrange.bRaised) THEN
|
||||||
|
_fbAlarmUnderrange.Raise(0);
|
||||||
|
END_IF
|
||||||
|
|
||||||
|
// Clear alarm
|
||||||
|
IF (NOT _fbSignalDelayUnderrangeError.xReleaseSignal) AND _fbAlarmUnderrange.bRaised THEN
|
||||||
|
_fbAlarmUnderrange.Clear(0, FALSE);
|
||||||
|
END_IF
|
||||||
|
|
||||||
|
// Confirm alarm
|
||||||
|
IF xConfirmAlarms AND (_fbAlarmUnderrange.eConfirmationState = TcEventConfirmationState.WaitForConfirmation) THEN
|
||||||
|
_fbAlarmUnderrange.Confirm(0);
|
||||||
|
END_IF
|
||||||
|
|
||||||
|
|
||||||
|
// =========================
|
||||||
|
// Overload alarm handling
|
||||||
|
// =========================
|
||||||
|
|
||||||
|
// Filter overload error signal
|
||||||
|
_fbSignalDelayOverloadError(
|
||||||
|
xSignal:= xOverrange,
|
||||||
|
xRelease:= stAnalogIOConfig.xUsed AND xReleaseErrors AND xReleaseHardwareErrors,
|
||||||
|
timOnDelay:= stAnalogEWConfig.stDelays.timHardwareSignalLevelOn,
|
||||||
|
timOffDelay:= stAnalogEWConfig.stDelays.timHardwareSignalLevelOff);
|
||||||
|
|
||||||
|
// Latch error signal
|
||||||
|
IF _fbSignalDelayOverloadError.xReleaseSignal THEN
|
||||||
|
xError := TRUE;
|
||||||
|
END_IF
|
||||||
|
|
||||||
|
// Raise alarm
|
||||||
|
IF _fbSignalDelayOverloadError.xReleaseSignal AND (NOT xInUnitTestMode) AND (_fbAlarmOverload.bRaised) THEN
|
||||||
|
_fbAlarmOverload.Raise(0);
|
||||||
|
END_IF
|
||||||
|
|
||||||
|
// Clear alarm
|
||||||
|
IF (NOT _fbSignalDelayOverloadError.xReleaseSignal) AND _fbAlarmOverload.bRaised THEN
|
||||||
|
_fbAlarmOverload.Clear(0, FALSE);
|
||||||
|
END_IF
|
||||||
|
|
||||||
|
// Confirm alarm
|
||||||
|
IF xConfirmAlarms AND (_fbAlarmOverload.eConfirmationState = TcEventConfirmationState.WaitForConfirmation) THEN
|
||||||
|
_fbAlarmOverload.Confirm(0);
|
||||||
|
END_IF
|
||||||
|
|
||||||
|
|
||||||
|
// =========================
|
||||||
|
// Card alarm handling
|
||||||
|
// =========================
|
||||||
|
|
||||||
|
// Filter overload error signal
|
||||||
|
// EL30xx also sets this if an underrange or overrange error is present,
|
||||||
|
// so we filter this out
|
||||||
|
_fbSignalDelayCardError(
|
||||||
|
xSignal:= xErrorCard AND (NOT xUnderrange) AND (NOT xOverrange),
|
||||||
|
xRelease:= stAnalogIOConfig.xUsed AND xReleaseErrors AND xReleaseHardwareErrors,
|
||||||
|
timOnDelay:= stAnalogEWConfig.stDelays.timHardwareSignalLevelOn,
|
||||||
|
timOffDelay:= stAnalogEWConfig.stDelays.timHardwareSignalLevelOff);
|
||||||
|
|
||||||
|
// Latch error signal
|
||||||
|
IF _fbSignalDelayCardError.xReleaseSignal THEN
|
||||||
|
xError := TRUE;
|
||||||
|
END_IF
|
||||||
|
|
||||||
|
// Raise alarm
|
||||||
|
IF _fbSignalDelayCardError.xReleaseSignal AND (NOT xInUnitTestMode) AND (_fbAlarmCardError.bRaised) THEN
|
||||||
|
_fbAlarmCardError.Raise(0);
|
||||||
|
END_IF
|
||||||
|
|
||||||
|
// Clear alarm
|
||||||
|
IF (NOT _fbSignalDelayCardError.xReleaseSignal) AND _fbAlarmCardError.bRaised THEN
|
||||||
|
_fbAlarmCardError.Clear(0, FALSE);
|
||||||
|
END_IF
|
||||||
|
|
||||||
|
// Confirm alarm
|
||||||
|
IF xConfirmAlarms AND (_fbAlarmCardError.eConfirmationState = TcEventConfirmationState.WaitForConfirmation) THEN
|
||||||
|
_fbAlarmCardError.Confirm(0);
|
||||||
|
END_IF
|
||||||
|
|
||||||
|
|
||||||
|
// ===========================
|
||||||
|
// Error high alarm handling
|
||||||
|
// ===========================
|
||||||
|
|
||||||
|
_fbSignalDelayErrorHigh(
|
||||||
|
xSignal:= (rScaledValue >= _rMaxErrorLevel),
|
||||||
|
xRelease:= stAnalogIOConfig.xUsed AND xReleaseErrors AND xReleaseLimitErrors AND (NOT _xEWConfigError),
|
||||||
|
timOnDelay:= stAnalogEWConfig.stDelays.timErrorHighOn,
|
||||||
|
timOffDelay:= stAnalogEWConfig.stDelays.timErrorHighOff);
|
||||||
|
|
||||||
|
xErrorHigh := _fbSignalDelayErrorHigh.xReleaseSignal;
|
||||||
|
|
||||||
|
// Latch error
|
||||||
|
IF xErrorLow THEN
|
||||||
|
xError := TRUE;
|
||||||
|
END_IF
|
||||||
|
|
||||||
|
// Raise alarm
|
||||||
|
IF _fbSignalDelayErrorHigh.xReleaseSignal AND (NOT xInUnitTestMode) AND (NOT _fbAlarmErrorHigh.bRaised) THEN
|
||||||
|
_fbAlarmErrorHigh.Raise(0);
|
||||||
|
END_IF
|
||||||
|
|
||||||
|
// Clear alarm
|
||||||
|
IF (NOT _fbSignalDelayErrorHigh.xReleaseSignal) AND _fbAlarmErrorHigh.bRaised THEN
|
||||||
|
_fbAlarmErrorHigh.Clear(0, FALSE);
|
||||||
|
END_IF
|
||||||
|
|
||||||
|
// Confirm alarm
|
||||||
|
IF xConfirmAlarms AND (_fbAlarmErrorHigh.eConfirmationState = TcEventConfirmationState.WaitForConfirmation) THEN
|
||||||
|
_fbAlarmErrorHigh.Confirm(0);
|
||||||
|
END_IF
|
||||||
|
|
||||||
|
|
||||||
|
// ===========================
|
||||||
|
// Error low alarm handling
|
||||||
|
// ===========================
|
||||||
|
|
||||||
|
_fbSignalDelayErrorLow(
|
||||||
|
xSignal:= (rScaledValue <= _rMinErrorLevel),
|
||||||
|
xRelease:= stAnalogIOConfig.xUsed AND xReleaseErrors AND xReleaseLimitErrors AND (NOT _xEWConfigError),
|
||||||
|
timOnDelay:= stAnalogEWConfig.stDelays.timErrorLowOn,
|
||||||
|
timOffDelay:= stAnalogEWConfig.stDelays.timErrorLowOff);
|
||||||
|
|
||||||
|
xErrorLow := _fbSignalDelayErrorLow.xReleaseSignal;
|
||||||
|
|
||||||
|
// Latch error
|
||||||
|
IF xErrorLow THEN
|
||||||
|
xError := TRUE;
|
||||||
|
END_IF
|
||||||
|
|
||||||
|
// Raise alarm
|
||||||
|
IF _fbSignalDelayErrorLow.xReleaseSignal AND (NOT xInUnitTestMode) AND (NOT _fbAlarmErrorLow.bRaised) THEN
|
||||||
|
_fbAlarmErrorLow.Raise(0);
|
||||||
|
END_IF
|
||||||
|
|
||||||
|
// Clear alarm
|
||||||
|
IF (NOT _fbSignalDelayErrorLow.xReleaseSignal) AND _fbAlarmErrorLow.bRaised THEN
|
||||||
|
_fbAlarmErrorLow.Clear(0, FALSE);
|
||||||
|
END_IF
|
||||||
|
|
||||||
|
// Confirm alarm
|
||||||
|
IF xConfirmAlarms AND (_fbAlarmErrorLow.eConfirmationState = TcEventConfirmationState.WaitForConfirmation) THEN
|
||||||
|
_fbAlarmErrorLow.Confirm(0);
|
||||||
|
END_IF
|
||||||
|
|
||||||
|
|
||||||
|
// ===========================
|
||||||
|
// Warning high alarm handling
|
||||||
|
// ===========================
|
||||||
|
|
||||||
|
_fbSignalDelayWarningHigh(
|
||||||
|
xSignal:= (rScaledValue >= _rMaxWarningLevel),
|
||||||
|
xRelease:= stAnalogIOConfig.xUsed AND xReleaseErrors AND xReleaseLimitErrors AND (NOT _xEWConfigError),
|
||||||
|
timOnDelay:= stAnalogEWConfig.stDelays.timWarningHighOn,
|
||||||
|
timOffDelay:= stAnalogEWConfig.stDelays.timWarningHighOff);
|
||||||
|
|
||||||
|
xWarningHigh := _fbSignalDelayWarningHigh.xReleaseSignal;
|
||||||
|
|
||||||
|
// Raise alarm
|
||||||
|
IF _fbSignalDelayWarningHigh.xReleaseSignal AND (NOT xInUnitTestMode) AND (NOT _fbAlarmWarningHigh.bRaised) THEN
|
||||||
|
_fbAlarmWarningHigh.Raise(0);
|
||||||
|
END_IF
|
||||||
|
|
||||||
|
// Clear alarm
|
||||||
|
IF (NOT _fbSignalDelayWarningHigh.xReleaseSignal) AND _fbAlarmWarningHigh.bRaised THEN
|
||||||
|
_fbAlarmWarningHigh.Clear(0, FALSE);
|
||||||
|
END_IF
|
||||||
|
|
||||||
|
// Confirm alarm
|
||||||
|
IF xConfirmAlarms AND (_fbAlarmWarningHigh.eConfirmationState = TcEventConfirmationState.WaitForConfirmation) THEN
|
||||||
|
_fbAlarmWarningHigh.Confirm(0);
|
||||||
|
END_IF
|
||||||
|
|
||||||
|
|
||||||
|
// ===========================
|
||||||
|
// Warning low alarm handling
|
||||||
|
// ===========================
|
||||||
|
|
||||||
|
_fbSignalDelayWarningLow(
|
||||||
|
xSignal:= (rScaledValue <= _rMinWarningLevel),
|
||||||
|
xRelease:= stAnalogIOConfig.xUsed AND xReleaseErrors AND xReleaseLimitErrors AND (NOT _xEWConfigError),
|
||||||
|
timOnDelay:= stAnalogEWConfig.stDelays.timWarningLowOn,
|
||||||
|
timOffDelay:= stAnalogEWConfig.stDelays.timWarningLowOff);
|
||||||
|
|
||||||
|
xWarningLow := _fbSignalDelayWarningLow.xReleaseSignal;
|
||||||
|
|
||||||
|
// Raise alarm
|
||||||
|
IF _fbSignalDelayWarningLow.xReleaseSignal AND (NOT xInUnitTestMode) AND (NOT _fbAlarmWarningLow.bRaised) THEN
|
||||||
|
_fbAlarmWarningLow.Raise(0);
|
||||||
|
END_IF
|
||||||
|
|
||||||
|
// Clear alarm
|
||||||
|
IF (NOT _fbSignalDelayWarningLow.xReleaseSignal) AND _fbAlarmWarningLow.bRaised THEN
|
||||||
|
_fbAlarmWarningLow.Clear(0, FALSE);
|
||||||
|
END_IF
|
||||||
|
|
||||||
|
// Confirm alarm
|
||||||
|
IF xConfirmAlarms AND (_fbAlarmWarningLow.eConfirmationState = TcEventConfirmationState.WaitForConfirmation) THEN
|
||||||
|
_fbAlarmWarningLow.Confirm(0);
|
||||||
|
END_IF
|
||||||
|
|
||||||
|
|
||||||
|
// ============
|
||||||
|
// Warning flag
|
||||||
|
// ============
|
||||||
|
|
||||||
|
xWarning := xWarningLow OR xWarningHigh;
|
||||||
|
|
||||||
|
|
||||||
|
// ================
|
||||||
|
// Reset error flag
|
||||||
|
// ================
|
||||||
|
|
||||||
|
_xAlarmsActive := _fbAlarmConfigError.bActive
|
||||||
|
OR _fbAlarmUnderrange.bActive
|
||||||
|
OR _fbAlarmOverload.bActive
|
||||||
|
OR _fbAlarmCardError.bActive
|
||||||
|
OR _fbAlarmErrorHigh.bActive
|
||||||
|
OR _fbAlarmErrorLow.bActive;
|
||||||
|
|
||||||
|
_xInputErrorsActive := _fbSignalDelayUnderrangeError.xReleaseSignal
|
||||||
|
OR _fbSignalDelayOverloadError.xReleaseSignal
|
||||||
|
OR _fbSignalDelayCardError.xReleaseSignal;
|
||||||
|
|
||||||
|
IF xConfirmAlarms AND xError AND (NOT _xAlarmsActive) AND (NOT _xInputErrorsActive) AND (NOT _xConfigError) THEN
|
||||||
|
xError := FALSE;
|
||||||
|
END_IF]]></ST>
|
||||||
|
</Implementation>
|
||||||
|
<Method Name="CalcScalingFactors" Id="{e88dfbcd-1a0d-45a0-9d50-5ad8be2479c9}">
|
||||||
|
<Declaration><![CDATA[{attribute 'analysis' := '-56'}
|
||||||
|
METHOD PRIVATE CalcScalingFactors
|
||||||
|
VAR
|
||||||
|
_rNum : REAL;
|
||||||
|
_rDenom : REAL;
|
||||||
|
END_VAR
|
||||||
|
]]></Declaration>
|
||||||
|
<Implementation>
|
||||||
|
<ST><![CDATA[// Check for valid config ref
|
||||||
|
IF (NOT __ISVALIDREF(stAnalogIOConfig)) THEN
|
||||||
|
_xConfigError := TRUE;
|
||||||
|
RETURN;
|
||||||
|
END_IF
|
||||||
|
|
||||||
|
// _lrConversionFactor := (lrPVMax - lrPVMin)/(udiAIMax - udiAIMin) + (rPVMin - ((lrPVMax - lrPVMin)/(udiAIMax - udiAIMin)*udiAIMin))
|
||||||
|
// Splitted in two calculations to catch division by zero
|
||||||
|
_rNum := (stAnalogIOConfig.rPVMax - stAnalogIOConfig.rPVMin);
|
||||||
|
_rDenom := INT_TO_REAL(stAnalogIOConfig.iAIMax - stAnalogIOConfig.iAIMin);
|
||||||
|
|
||||||
|
// Do not divide by 0 or a negative number
|
||||||
|
IF _rDenom > 0.0 THEN
|
||||||
|
_rConversionFactor := _rNum/_rDenom;
|
||||||
|
_rBaseOffset := stAnalogIOConfig.rPVMin - (_rConversionFactor * INT_TO_REAL(stAnalogIOConfig.iAIMin));
|
||||||
|
_iAIMax := stAnalogIOConfig.iAIMax;
|
||||||
|
_iAIMin := stAnalogIOConfig.iAIMin;
|
||||||
|
_xConfigError := FALSE;
|
||||||
|
ELSE
|
||||||
|
// Division by zero happened
|
||||||
|
// Or denom was negative
|
||||||
|
// Set scaling to zero
|
||||||
|
_rConversionFactor := 0.0;
|
||||||
|
_rBaseOffset := 0.0;
|
||||||
|
_iAIMax := 0;
|
||||||
|
_iAIMin := 0;
|
||||||
|
_xConfigError := TRUE;
|
||||||
|
END_IF]]></ST>
|
||||||
|
</Implementation>
|
||||||
|
</Method>
|
||||||
|
<Method Name="CheckEWLevels" Id="{6fcb5a6d-e37d-4efd-ad76-02026f476863}">
|
||||||
|
<Declaration><![CDATA[METHOD PRIVATE CheckEWLevels
|
||||||
|
VAR
|
||||||
|
END_VAR
|
||||||
|
]]></Declaration>
|
||||||
|
<Implementation>
|
||||||
|
<ST><![CDATA[// Check for valid config ref
|
||||||
|
IF (NOT __ISVALIDREF(stAnalogEWConfig)) THEN
|
||||||
|
_xEWConfigError := TRUE;
|
||||||
|
RETURN;
|
||||||
|
END_IF
|
||||||
|
|
||||||
|
// Reset (E)rror (W)arning config error
|
||||||
|
_xEWConfigError := FALSE;
|
||||||
|
|
||||||
|
// Check for EW config error
|
||||||
|
IF stAnalogEWConfig.stLevels.rWarningMin <= stAnalogEWConfig.stLevels.rErrorMin THEN
|
||||||
|
_xEWConfigError := TRUE;
|
||||||
|
END_IF
|
||||||
|
|
||||||
|
IF stAnalogEWConfig.stLevels.rWarningMax >= stAnalogEWConfig.stLevels.rErrorMax THEN
|
||||||
|
_xEWConfigError := TRUE;
|
||||||
|
END_IF
|
||||||
|
|
||||||
|
IF stAnalogEWConfig.stLevels.rWarningMin >= stAnalogEWConfig.stLevels.rWarningMax THEN
|
||||||
|
_xEWConfigError := TRUE;
|
||||||
|
END_IF
|
||||||
|
|
||||||
|
|
||||||
|
// Only write error and warning levels when there was no config error
|
||||||
|
IF (NOT _xEWConfigError) THEN
|
||||||
|
// Recreate alarm messages with the newly set limits
|
||||||
|
// if values have been changed
|
||||||
|
{analysis -54}
|
||||||
|
IF (_rMinErrorLevel <> stAnalogEWConfig.stLevels.rErrorMin)
|
||||||
|
OR (_rMinWarningLevel <> stAnalogEWConfig.stLevels.rWarningMin)
|
||||||
|
OR (_rMaxWarningLevel <> stAnalogEWConfig.stLevels.rWarningMax)
|
||||||
|
OR (_rMaxErrorLevel <> stAnalogEWConfig.stLevels.rErrorMax) THEN
|
||||||
|
{analysis +54}
|
||||||
|
//CreateAlarmLimitsMSG();
|
||||||
|
END_IF
|
||||||
|
|
||||||
|
// Set new values
|
||||||
|
_rMinErrorLevel := stAnalogEWConfig.stLevels.rErrorMin;
|
||||||
|
_rMinWarningLevel := stAnalogEWConfig.stLevels.rWarningMin;
|
||||||
|
_rMaxWarningLevel := stAnalogEWConfig.stLevels.rWarningMax;
|
||||||
|
_rMaxErrorLevel := stAnalogEWConfig.stLevels.rErrorMax;
|
||||||
|
END_IF
|
||||||
|
]]></ST>
|
||||||
|
</Implementation>
|
||||||
|
</Method>
|
||||||
|
<Method Name="CreateAlarmLimitsMSG" Id="{d38eb5a5-80eb-4ab2-8c50-97431707ca20}">
|
||||||
|
<Declaration><![CDATA[{attribute 'analysis' := '-26'}
|
||||||
|
METHOD PRIVATE CreateAlarmLimitsMSG
|
||||||
|
VAR_INPUT
|
||||||
|
END_VAR
|
||||||
|
VAR
|
||||||
|
_sTempUnit : STRING;
|
||||||
|
_sTempErrorMin : STRING;
|
||||||
|
_sTempWarningMin : STRING;
|
||||||
|
_sTempWarningMax : STRING;
|
||||||
|
_sTempErrorMax : STRING;
|
||||||
|
END_VAR
|
||||||
|
]]></Declaration>
|
||||||
|
<Implementation>
|
||||||
|
<ST><![CDATA[// Check for valid ref
|
||||||
|
IF (NOT __ISVALIDREF(stAnalogEWConfig)) THEN
|
||||||
|
RETURN;
|
||||||
|
END_IF
|
||||||
|
|
||||||
|
// Check if analog value has unit
|
||||||
|
IF stAnalogIOConfig.sUnit <> '' THEN
|
||||||
|
_sTempUnit := CONCAT(' ', stAnalogIOConfig.sUnit);
|
||||||
|
ELSE
|
||||||
|
_sTempUnit := '';
|
||||||
|
END_IF
|
||||||
|
|
||||||
|
// Create message parameter strings
|
||||||
|
_sTempErrorMin := CONCAT(REAL_TO_STRING(stAnalogEWConfig.stLevels.rErrorMin), _sTempUnit);
|
||||||
|
_sTempWarningMin := CONCAT(REAL_TO_STRING(stAnalogEWConfig.stLevels.rWarningMin), _sTempUnit);
|
||||||
|
_sTempWarningMax := CONCAT(REAL_TO_STRING(stAnalogEWConfig.stLevels.rWarningMax), _sTempUnit);
|
||||||
|
_sTempErrorMax := CONCAT(REAL_TO_STRING(stAnalogEWConfig.stLevels.rErrorMax), _sTempUnit);
|
||||||
|
|
||||||
|
// Inser message parameters
|
||||||
|
_fbAlarmErrorLow.ipArguments.Clear().AddString(_sName).AddString(_sTempErrorMin);
|
||||||
|
_fbAlarmWarningLow.ipArguments.Clear().AddString(_sName).AddString(_sTempWarningMin);
|
||||||
|
_fbAlarmWarningHigh.ipArguments.Clear().AddString(_sName).AddString(_sTempWarningMax);
|
||||||
|
_fbAlarmErrorHigh.ipArguments.Clear().AddString(_sName).AddString(_sTempErrorMax);]]></ST>
|
||||||
|
</Implementation>
|
||||||
|
</Method>
|
||||||
|
<Method Name="CreateAlarmMSG" Id="{e4d0fc74-1711-410b-9ec3-4af08afbc236}">
|
||||||
|
<Declaration><![CDATA[METHOD PRIVATE CreateAlarmMSG
|
||||||
|
VAR_INPUT
|
||||||
|
END_VAR
|
||||||
|
]]></Declaration>
|
||||||
|
<Implementation>
|
||||||
|
<ST><![CDATA[_fbAlarmCardError.ipArguments.Clear().AddString(_sName);
|
||||||
|
_fbAlarmUnderrange.ipArguments.Clear().AddString(_sName);
|
||||||
|
_fbAlarmOverload.ipArguments.Clear().AddString(_sName);
|
||||||
|
_fbAlarmConfigError.ipArguments.Clear().AddString(_sName);]]></ST>
|
||||||
|
</Implementation>
|
||||||
|
</Method>
|
||||||
|
<Method Name="FB_init" Id="{27512538-cc2f-4100-8046-022de49f067a}">
|
||||||
|
<Declaration><![CDATA[//FB_Init ist immer implizit verfügbar und wird primär für die Initialisierung verwendet.
|
||||||
|
//Der Rückgabewert wird nicht ausgewertet. Für gezielte Einflussnahme können Sie
|
||||||
|
//die Methoden explizit deklarieren und darin mit dem Standard-Initialisierungscode
|
||||||
|
//zusätzlichen Code bereitstellen. Sie können den Rückgabewert auswerten.
|
||||||
|
METHOD FB_Init: BOOL
|
||||||
|
VAR_INPUT
|
||||||
|
bInitRetains: BOOL; // TRUE: Die Retain-Variablen werden initialisiert (Reset warm / Reset kalt)
|
||||||
|
bInCopyCode: BOOL; // TRUE: Die Instanz wird danach in den Kopiercode kopiert (Online-Change)
|
||||||
|
|
||||||
|
// Name of analogue io
|
||||||
|
sName : STRING(80);
|
||||||
|
END_VAR]]></Declaration>
|
||||||
|
<Implementation>
|
||||||
|
<ST><![CDATA[// Save io name
|
||||||
|
_sName := sName;
|
||||||
|
|
||||||
|
// Create alarm messages
|
||||||
|
CreateAlarmMSG();
|
||||||
|
CreateAlarmLimitsMSG();]]></ST>
|
||||||
|
</Implementation>
|
||||||
|
</Method>
|
||||||
|
<Property Name="Name" Id="{103c7177-ef49-4a4b-98b1-06578d5fce31}">
|
||||||
|
<Declaration><![CDATA[PROPERTY Name : STRING(80)]]></Declaration>
|
||||||
|
<Get Name="Get" Id="{02e85b3f-9933-4282-a9d2-1ab27eb22499}">
|
||||||
|
<Declaration><![CDATA[VAR
|
||||||
|
END_VAR
|
||||||
|
]]></Declaration>
|
||||||
|
<Implementation>
|
||||||
|
<ST><![CDATA[Name := _sName;]]></ST>
|
||||||
|
</Implementation>
|
||||||
|
</Get>
|
||||||
|
<Set Name="Set" Id="{4215abec-259f-45d7-a31e-437036d4e241}">
|
||||||
|
<Declaration><![CDATA[VAR
|
||||||
|
END_VAR
|
||||||
|
]]></Declaration>
|
||||||
|
<Implementation>
|
||||||
|
<ST><![CDATA[_sName := Name;
|
||||||
|
|
||||||
|
// After a name change, all error messages have to be changed
|
||||||
|
CreateAlarmMSG();]]></ST>
|
||||||
|
</Implementation>
|
||||||
|
</Set>
|
||||||
|
</Property>
|
||||||
|
</POU>
|
||||||
|
</TcPlcObject>
|
||||||
65
TwinCAT Projekt1/PLC/POUs/Analog/FB_AnalogOutput.TcPOU
Normal file
65
TwinCAT Projekt1/PLC/POUs/Analog/FB_AnalogOutput.TcPOU
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<TcPlcObject Version="1.1.0.1">
|
||||||
|
<POU Name="FB_AnalogOutput" Id="{5ea9527b-d363-4c01-ba95-f8c298545979}" SpecialFunc="None">
|
||||||
|
<Declaration><![CDATA[FUNCTION_BLOCK FINAL FB_AnalogOutput
|
||||||
|
VAR_INPUT
|
||||||
|
// Setpoint
|
||||||
|
rSetpoint : REAL;
|
||||||
|
|
||||||
|
// config data for analog output scaling
|
||||||
|
stScalingConfig : ST_ANALOG_IO_CONFIG;
|
||||||
|
|
||||||
|
// Global switch to dissable all errors
|
||||||
|
xReleaseErrors : BOOL := TRUE;
|
||||||
|
|
||||||
|
// Enables or dissables hardware errors
|
||||||
|
xReleaseHardwareErrors : BOOL := TRUE;
|
||||||
|
|
||||||
|
// Input to confirm all errors
|
||||||
|
xConfirmAlarms : BOOL;
|
||||||
|
|
||||||
|
// Input to tell the fb thats ist used inside a unit test
|
||||||
|
// Fb will not throw error messages
|
||||||
|
{attribute 'hide'}
|
||||||
|
xInUnitTestMode : BOOL := FALSE;
|
||||||
|
END_VAR
|
||||||
|
VAR_OUTPUT
|
||||||
|
iAnalogValue AT %Q* : INT;
|
||||||
|
|
||||||
|
// Error in function block
|
||||||
|
xError : BOOL;
|
||||||
|
END_VAR
|
||||||
|
VAR
|
||||||
|
// Setpoint
|
||||||
|
_rSetpointInternal : REAL;
|
||||||
|
|
||||||
|
// Name of the function block
|
||||||
|
_sName : STRING;
|
||||||
|
|
||||||
|
// Scaling factor for conversion
|
||||||
|
_rConversionFactor : REAL;
|
||||||
|
|
||||||
|
// Base offset for scaling factor
|
||||||
|
_rBaseOffset : REAL;
|
||||||
|
|
||||||
|
// Temporary calculated analog value
|
||||||
|
_rTempAnalogValue : REAL;
|
||||||
|
|
||||||
|
// Config error
|
||||||
|
_xConfigError : BOOL;
|
||||||
|
|
||||||
|
// Max process value
|
||||||
|
_rPVMax : REAL;
|
||||||
|
|
||||||
|
// Min process value
|
||||||
|
_rPVMin : REAL;
|
||||||
|
|
||||||
|
// Config error alarm
|
||||||
|
_fbAlarmConfigError : FB_TcAlarm;
|
||||||
|
END_VAR
|
||||||
|
]]></Declaration>
|
||||||
|
<Implementation>
|
||||||
|
<ST><![CDATA[]]></ST>
|
||||||
|
</Implementation>
|
||||||
|
</POU>
|
||||||
|
</TcPlcObject>
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<TcPlcObject Version="1.1.0.1">
|
||||||
|
<DUT Name="ST_ANALOG_EW_CONFIG" Id="{6f3ed88d-28a0-4a7f-a26a-6b822e47799e}">
|
||||||
|
<Declaration><![CDATA[TYPE ST_ANALOG_EW_CONFIG :
|
||||||
|
STRUCT
|
||||||
|
stLevels : ST_ANALOG_EW_LEVELS;
|
||||||
|
stDelays : ST_ANALOG_EW_DELAYS;
|
||||||
|
END_STRUCT
|
||||||
|
END_TYPE
|
||||||
|
]]></Declaration>
|
||||||
|
</DUT>
|
||||||
|
</TcPlcObject>
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<TcPlcObject Version="1.1.0.1">
|
||||||
|
<DUT Name="ST_ANALOG_EW_DELAYS" Id="{8b5ae408-253c-4618-ab64-5d8c4935716b}">
|
||||||
|
<Declaration><![CDATA[TYPE ST_ANALOG_EW_DELAYS :
|
||||||
|
STRUCT
|
||||||
|
{attribute 'OPC.UA.DA' := '1'}
|
||||||
|
timHardwareSignalLevelOn : TIME;
|
||||||
|
{attribute 'OPC.UA.DA' := '1'}
|
||||||
|
timHardwareSignalLevelOff : TIME;
|
||||||
|
|
||||||
|
{attribute 'OPC.UA.DA' := '1'}
|
||||||
|
timErrorLowOn : TIME;
|
||||||
|
{attribute 'OPC.UA.DA' := '1'}
|
||||||
|
timErrorLowOff : TIME;
|
||||||
|
{attribute 'OPC.UA.DA' := '1'}
|
||||||
|
timWarningLowOn : TIME;
|
||||||
|
{attribute 'OPC.UA.DA' := '1'}
|
||||||
|
timWarningLowOff : TIME;
|
||||||
|
{attribute 'OPC.UA.DA' := '1'}
|
||||||
|
timWarningHighOn : TIME;
|
||||||
|
{attribute 'OPC.UA.DA' := '1'}
|
||||||
|
timWarningHighOff : TIME;
|
||||||
|
{attribute 'OPC.UA.DA' := '1'}
|
||||||
|
timErrorHighOn : TIME;
|
||||||
|
{attribute 'OPC.UA.DA' := '1'}
|
||||||
|
timErrorHighOff : TIME;
|
||||||
|
END_STRUCT
|
||||||
|
END_TYPE
|
||||||
|
]]></Declaration>
|
||||||
|
</DUT>
|
||||||
|
</TcPlcObject>
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<TcPlcObject Version="1.1.0.1">
|
||||||
|
<DUT Name="ST_ANALOG_EW_LEVELS" Id="{40734543-a4f6-4336-bcfe-ac65f034a277}">
|
||||||
|
<Declaration><![CDATA[TYPE ST_ANALOG_EW_LEVELS :
|
||||||
|
STRUCT
|
||||||
|
{attribute 'OPC.UA.DA' := '1'}
|
||||||
|
rErrorMin : REAL;
|
||||||
|
{attribute 'OPC.UA.DA' := '1'}
|
||||||
|
rWarningMin : REAL;
|
||||||
|
{attribute 'OPC.UA.DA' := '1'}
|
||||||
|
rWarningMax : REAL;
|
||||||
|
{attribute 'OPC.UA.DA' := '1'}
|
||||||
|
rErrorMax : REAL;
|
||||||
|
END_STRUCT
|
||||||
|
END_TYPE
|
||||||
|
]]></Declaration>
|
||||||
|
</DUT>
|
||||||
|
</TcPlcObject>
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<TcPlcObject Version="1.1.0.1">
|
||||||
|
<DUT Name="ST_ANALOG_IO_CONFIG" Id="{ee57b40d-d65d-438f-80f9-912bc67bff84}">
|
||||||
|
<Declaration><![CDATA[TYPE ST_ANALOG_IO_CONFIG :
|
||||||
|
STRUCT
|
||||||
|
// Maximum analog value
|
||||||
|
{attribute 'OPC.UA.DA' := '1'}
|
||||||
|
iAIMax : INT;
|
||||||
|
|
||||||
|
// Minimum analog value
|
||||||
|
{attribute 'OPC.UA.DA' := '1'}
|
||||||
|
iAIMin : INT;
|
||||||
|
|
||||||
|
// Maximum process value
|
||||||
|
{attribute 'OPC.UA.DA' := '1'}
|
||||||
|
rPVMax : REAL;
|
||||||
|
|
||||||
|
// Minimum process value
|
||||||
|
{attribute 'OPC.UA.DA' := '1'}
|
||||||
|
rPVMin : REAL;
|
||||||
|
|
||||||
|
// Process unit (V, A, P, U/min, %, rpm etc)
|
||||||
|
{attribute 'OPC.UA.DA' := '1'}
|
||||||
|
sUnit : STRING;
|
||||||
|
|
||||||
|
// Analog IO is used
|
||||||
|
{attribute 'OPC.UA.DA' := '1'}
|
||||||
|
xUsed : BOOL := TRUE;
|
||||||
|
END_STRUCT
|
||||||
|
END_TYPE
|
||||||
|
]]></Declaration>
|
||||||
|
</DUT>
|
||||||
|
</TcPlcObject>
|
||||||
@@ -1,25 +1,14 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<TcPlcObject Version="1.1.0.1">
|
<TcPlcObject Version="1.1.0.1">
|
||||||
<POU Name="MAIN" Id="{c66c285f-4cfe-4893-8066-e22fe681dd3f}" SpecialFunc="None">
|
<POU Name="MAIN" Id="{f325d0cd-99c8-4d5b-980f-1fc96ab1417c}" SpecialFunc="None">
|
||||||
<Declaration><![CDATA[PROGRAM MAIN
|
<Declaration><![CDATA[PROGRAM MAIN
|
||||||
VAR
|
VAR
|
||||||
_fbMachine : FB_Machine(0, 'Machine');
|
// Analog I/O tests
|
||||||
|
_fbAnalogInputTest : FB_AnalogInputTest;
|
||||||
// Startup state machine
|
|
||||||
_iState : INT := 0;
|
|
||||||
END_VAR
|
END_VAR
|
||||||
]]></Declaration>
|
]]></Declaration>
|
||||||
<Implementation>
|
<Implementation>
|
||||||
<ST><![CDATA[CASE _iState OF
|
<ST><![CDATA[TcUnit.RUN();]]></ST>
|
||||||
0:
|
|
||||||
IF IsSuccessful(_fbMachine.InitialOP()) THEN
|
|
||||||
_fbMachine.CyclicOP();
|
|
||||||
_iState := 10;
|
|
||||||
END_IF
|
|
||||||
|
|
||||||
10:
|
|
||||||
_fbMachine.CyclicOP();
|
|
||||||
END_CASE]]></ST>
|
|
||||||
</Implementation>
|
</Implementation>
|
||||||
</POU>
|
</POU>
|
||||||
</TcPlcObject>
|
</TcPlcObject>
|
||||||
25
TwinCAT Projekt1/PLC/POUs/Tests/MAIN_TESTS.TcPOU
Normal file
25
TwinCAT Projekt1/PLC/POUs/Tests/MAIN_TESTS.TcPOU
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<TcPlcObject Version="1.1.0.1">
|
||||||
|
<POU Name="MAIN_TESTS" Id="{c66c285f-4cfe-4893-8066-e22fe681dd3f}" SpecialFunc="None">
|
||||||
|
<Declaration><![CDATA[PROGRAM MAIN_TESTS
|
||||||
|
VAR
|
||||||
|
_fbMachine : FB_Machine(0, 'Machine');
|
||||||
|
|
||||||
|
// Startup state machine
|
||||||
|
_iState : INT := 0;
|
||||||
|
END_VAR
|
||||||
|
]]></Declaration>
|
||||||
|
<Implementation>
|
||||||
|
<ST><![CDATA[CASE _iState OF
|
||||||
|
0:
|
||||||
|
IF IsSuccessful(_fbMachine.InitialOP()) THEN
|
||||||
|
_fbMachine.CyclicOP();
|
||||||
|
_iState := 10;
|
||||||
|
END_IF
|
||||||
|
|
||||||
|
10:
|
||||||
|
_fbMachine.CyclicOP();
|
||||||
|
END_CASE]]></ST>
|
||||||
|
</Implementation>
|
||||||
|
</POU>
|
||||||
|
</TcPlcObject>
|
||||||
1636
TwinCAT Projekt1/PLC/POUs/Unittests/AITests/FB_AnalogInputTest.TcPOU
Normal file
1636
TwinCAT Projekt1/PLC/POUs/Unittests/AITests/FB_AnalogInputTest.TcPOU
Normal file
File diff suppressed because it is too large
Load Diff
44
TwinCAT Projekt1/PLC/POUs/Utilities/FB_ReleaseSignal.TcPOU
Normal file
44
TwinCAT Projekt1/PLC/POUs/Utilities/FB_ReleaseSignal.TcPOU
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<TcPlcObject Version="1.1.0.1">
|
||||||
|
<POU Name="FB_ReleaseSignal" Id="{95131698-43c9-4438-8f9f-0d910656ef66}" SpecialFunc="None">
|
||||||
|
<Declaration><![CDATA[FUNCTION_BLOCK FINAL FB_ReleaseSignal
|
||||||
|
VAR_INPUT
|
||||||
|
// Signal to filter
|
||||||
|
xSignal : BOOL := FALSE;
|
||||||
|
|
||||||
|
// Release signal output
|
||||||
|
xRelease : BOOL := TRUE;
|
||||||
|
|
||||||
|
// Time for xSignal to be true before setting xReleaseSignal to true
|
||||||
|
timOnDelay : TIME := T#0MS;
|
||||||
|
|
||||||
|
// Time for xSignal to be false before setting xReleaseSignal to false
|
||||||
|
timOffDelay : TIME := T#0MS;
|
||||||
|
END_VAR
|
||||||
|
VAR_OUTPUT
|
||||||
|
// Filtered signal
|
||||||
|
xReleaseSignal : BOOL;
|
||||||
|
END_VAR
|
||||||
|
VAR
|
||||||
|
// Timer for on filtering
|
||||||
|
_fbOnDelayTimer : TON;
|
||||||
|
|
||||||
|
// Timer for off filtering
|
||||||
|
_fbOffDelayTimer : TON;
|
||||||
|
END_VAR
|
||||||
|
]]></Declaration>
|
||||||
|
<Implementation>
|
||||||
|
<ST><![CDATA[// Delay on signal if signal is released
|
||||||
|
_fbOnDelayTimer(IN:= xSignal AND xRelease, PT:= timOnDelay);
|
||||||
|
IF _fbOnDelayTimer.Q THEN
|
||||||
|
xReleaseSignal := TRUE;
|
||||||
|
END_IF
|
||||||
|
|
||||||
|
// Delay off signal, return false even if off timer is still active
|
||||||
|
_fbOffDelayTimer(IN:= (NOT xSignal), PT:= timOffDelay);
|
||||||
|
IF _fbOffDelayTimer.Q OR (NOT xRelease) THEN
|
||||||
|
xReleaseSignal := FALSE;
|
||||||
|
END_IF]]></ST>
|
||||||
|
</Implementation>
|
||||||
|
</POU>
|
||||||
|
</TcPlcObject>
|
||||||
@@ -12,6 +12,5 @@
|
|||||||
<Fb_exit>{fec05c77-54d5-4195-ac02-ecdaaad52f09}</Fb_exit>
|
<Fb_exit>{fec05c77-54d5-4195-ac02-ecdaaad52f09}</Fb_exit>
|
||||||
<CycleUpdate>{7536800f-d7c6-464d-a9c4-0b4ee7a1d592}</CycleUpdate>
|
<CycleUpdate>{7536800f-d7c6-464d-a9c4-0b4ee7a1d592}</CycleUpdate>
|
||||||
<PostCycleUpdate>{6dbfee29-f644-435d-b6e8-122b6f086f52}</PostCycleUpdate>
|
<PostCycleUpdate>{6dbfee29-f644-435d-b6e8-122b6f086f52}</PostCycleUpdate>
|
||||||
<ObjectProperties />
|
|
||||||
</Task>
|
</Task>
|
||||||
</TcPlcObject>
|
</TcPlcObject>
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
<?xml version="1.0"?>
|
|
||||||
<TcSmProject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.beckhoff.com/schemas/2012/07/TcSmProject" TcSmVersion="1.0" TcVersion="3.1.4026.19">
|
|
||||||
<DataTypes>
|
|
||||||
<DataType>
|
|
||||||
<Name GUID="{51F782DC-92E3-4391-9C7A-339EB87A42D8}" PersistentType="true">TestAlarms</Name>
|
|
||||||
<DisplayName TxtId=""><![CDATA[NewEventClass_DisplayText]]></DisplayName>
|
|
||||||
<EventId>
|
|
||||||
<Name Id="1">TestError</Name>
|
|
||||||
<DisplayName TxtId=""><![CDATA[Test Error ohne parameter]]></DisplayName>
|
|
||||||
<Severity>Error</Severity>
|
|
||||||
</EventId>
|
|
||||||
<EventId>
|
|
||||||
<Name Id="2">TestWarning</Name>
|
|
||||||
<DisplayName TxtId=""><![CDATA[Test Warning ohne Parameter]]></DisplayName>
|
|
||||||
<Severity>Warning</Severity>
|
|
||||||
</EventId>
|
|
||||||
<Hides>
|
|
||||||
<Hide GUID="{2C256031-B71B-4053-BBA0-1118C08EC292}"/>
|
|
||||||
</Hides>
|
|
||||||
</DataType>
|
|
||||||
</DataTypes>
|
|
||||||
<Project ProjectGUID="{775BE4FD-89CE-48D5-8E68-5C84AF95981A}" TargetNetId="5.167.199.178.1.1" Target64Bit="true" ShowHideConfigurations="#x6">
|
|
||||||
<System>
|
|
||||||
<Tasks>
|
|
||||||
<Task Id="3" Priority="20" CycleTime="100000" AmsPort="350" AdtTasks="true">
|
|
||||||
<Name>PlcTask</Name>
|
|
||||||
</Task>
|
|
||||||
</Tasks>
|
|
||||||
</System>
|
|
||||||
<Plc>
|
|
||||||
<Project GUID="{4E62D9E7-436C-457D-8DC4-82D2FEF91C96}" Name="PLC" PrjFilePath="PLC\PLC.plcproj" TmcFilePath="PLC\PLC.tmc" ReloadTmc="true" AmsPort="851" FileArchiveSettings="#x000e" CopyTmcToTarget="true" CopyTpyToTarget="false" SymbolicMapping="true">
|
|
||||||
<Instance Id="#x08502000" TcSmClass="TComPlcObjDef" KeepUnrestoredLinks="2" TmcHash="{99DE3247-9B81-8B43-2414-96A9FBE4A7AC}">
|
|
||||||
<Name>PLC Instance</Name>
|
|
||||||
<CLSID ClassFactory="TcPlc30">{08500001-0000-0000-F000-000000000064}</CLSID>
|
|
||||||
<Contexts>
|
|
||||||
<Context>
|
|
||||||
<Id>0</Id>
|
|
||||||
<Name>PlcTask</Name>
|
|
||||||
<ManualConfig>
|
|
||||||
<OTCID>#x02010030</OTCID>
|
|
||||||
</ManualConfig>
|
|
||||||
<Priority>20</Priority>
|
|
||||||
<CycleTime>10000000</CycleTime>
|
|
||||||
</Context>
|
|
||||||
</Contexts>
|
|
||||||
<TaskPouOids>
|
|
||||||
<TaskPouOid Prio="20" OTCID="#x08502001"/>
|
|
||||||
</TaskPouOids>
|
|
||||||
</Instance>
|
|
||||||
</Project>
|
|
||||||
</Plc>
|
|
||||||
<Analytics ConfigVersion="1.4">
|
|
||||||
<Name>ANALYTICS</Name>
|
|
||||||
<ImageId>437</ImageId>
|
|
||||||
<XmlProps><![CDATA[<Address>Hauptstraße 5, 32567 Berlin</Address><Latitude>123.41</Latitude><Longitude>43.4555</Longitude><SystemIdAlias /><DeviceProps></DeviceProps><SelectedDriverVersion>Latest</SelectedDriverVersion><StreamTargets><StreamTargetItem Id="c77d2d3a-36af-40a8-bced-d69e6e281117"><Name>Boot Project Path</Name><Type>FILE</Type><Directory>%TC_BOOTPRJPATH%</Directory><MqttConnectionSettings><Broker>127.0.0.1</Broker><BrokerPort>1883</BrokerPort><UserID /><WithCertificates>false</WithCertificates><CA_Certificate /><Cert_Certificate /><Key_Certificate /><CommunicationTimeout>30000000</CommunicationTimeout><KeepAlivePeriod>600000000</KeepAlivePeriod><TcpBufferSize>32768</TcpBufferSize><SecurityType>NO_SECURITY</SecurityType><Insecure>false</Insecure><IgnoreExpiration>false</IgnoreExpiration><IsPskIdCaseSensitive>false</IsPskIdCaseSensitive><IgnoreCnMismatch>false</IgnoreCnMismatch><TargetPaths>false</TargetPaths><PskMode>HexKey</PskMode></MqttConnectionSettings><TimeType>None</TimeType></StreamTargetItem></StreamTargets><ActivateAlyLogger>false</ActivateAlyLogger>]]></XmlProps>
|
|
||||||
</Analytics>
|
|
||||||
</Project>
|
|
||||||
</TcSmProject>
|
|
||||||
Reference in New Issue
Block a user