Skip to content

Commit

Permalink
Merge pull request #66 from ZLLentz/enh_im4k2_24bits
Browse files Browse the repository at this point in the history
ENH: quickly set up 24-bit readouts for IM4K2 (similar to HE-style)
  • Loading branch information
ZLLentz authored Jun 27, 2024
2 parents 43aa225 + f751ea6 commit 24c8ec7
Show file tree
Hide file tree
Showing 10 changed files with 2,120 additions and 887 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<TcSmItem 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.4024.4" ClassName="CFlbTermDef" SubType="9099">
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<TcSmItem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.beckhoff.com/schemas/2012/07/TcSmItem" TcSmVersion="1.0" TcVersion="3.1.4022.30" ClassName="CFlbTermDef" SubType="9099">
<ImageDatas>
<ImageData Id="1000">424dd6020000000000003600000028000000100000000e0000000100180000000000a0020000c40e0000c40e00000000000000000000ff00ffc0c0c0c0c0c0c0c0c0c0c0c0808080808080808080808080808080808080ff00ffff00ffff00ffff00ffff00ffff00ffc0c0c0c0c0c0c0c0c0c0c0c0808080c0c0c0000000c0c0c0000000808080ff00ffff00ffff00ffff00ffff00ffff00ffc0c0c000bfff00bfffc0c0c0808080c0c0c000ffffc0c0c000ffff808080ff00ffff00ffff00ffff00ffff00ffff00ffc0c0c000bfff00bfffc0c0c0808080c0c0c0c0c0c0c0c0c0c0c0c0808080ff00ffff00ffff00ffff00ffff00ffff00ffc0c0c000bfff00bfffc0c0c0808080c0c0c0000000c0c0c0000000808080ff00ffff00ffff00ffff00ffff00ffff00ffc0c0c0c0c0c0c0c0c0c0c0c0808080c0c0c0ff0000c0c0c0ff0000808080ff00ffff00ffff00ffff00ffff00ffff00ffc0c0c0c0c0c0c0c0c0c0c0c0808080c0c0c0c0c0c0c0c0c0c0c0c0808080ff00ffff00ffff00ffff00ffff00ffff00ffc0c0c0c0c0c0c0c0c0c0c0c0808080c0c0c0000000c0c0c0000000808080ff00ffff00ffff00ffff00ffff00ffff00ffc0c0c000bfff00bfffc0c0c0808080c0c0c00000ffc0c0c00000ff808080ff00ffff00ffff00ffff00ffff00ffff00ffc0c0c000bfff00bfffc0c0c0808080c0c0c0c0c0c0c0c0c0c0c0c0808080ff00ffff00ffff00ffff00ffff00ffff00ffc0c0c000bfff00bfffc0c0c0808080c0c0c0000000c0c0c0000000808080ff00ffff00ffff00ffff00ffff00ffff00ffc0c0c0c0c0c0c0c0c0c0c0c0808080c0c0c0c0c0c0c0c0c0c0c0c0808080ff00ffff00ffff00ffff00ffff00ffff00ffc0c0c0c0c0c0c0c0c0c0c0c0808080c0c0c0008000c0c0c0008000808080ff00ffff00ffff00ffff00ffff00ffff00ffc0c0c0c0c0c0c0c0c0c0c0c0808080c0c0c0c0c0c0c0c0c0c0c0c0808080ff00ffff00ffff00ffff00ffff00ff</ImageData>
</ImageDatas>
Expand Down Expand Up @@ -28,8 +28,11 @@
<Box File="IM4K2-EL4004-E7.xti" Id="106">
<EtherCAT PortABoxInfo="#x01000069"/>
</Box>
<Box File="IM4K2-EL9011-E8.xti" Id="135">
<Box File="IM4K2-EL3602-E8.xti" Id="76">
<EtherCAT PortABoxInfo="#x0100006a"/>
</Box>
<Box File="IM4K2-EL9011-E9.xti" Id="135">
<EtherCAT PortABoxInfo="#x0100004c"/>
</Box>
</Box>
</TcSmItem>
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<TcSmItem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.beckhoff.com/schemas/2012/07/TcSmItem" TcSmVersion="1.0" TcVersion="3.1.4022.30" ClassName="CFlbTermDef" SubType="9099">
<DataTypes>
<DataType>
<Name GUID="{18071995-0000-0000-0000-002000000007}" IecBaseType="true" BitType="true" AutoDeleteType="true" HideSubItems="true">ARRAY [0..6] OF BIT</Name>
<BitSize>7</BitSize>
<BaseType GUID="{18071995-0000-0000-0000-000000000010}">BIT</BaseType>
<ArrayInfo>
<LBound>0</LBound>
<Elements>7</Elements>
</ArrayInfo>
</DataType>
</DataTypes>
<ImageDatas>
<ImageData Id="1000">424dd6020000000000003600000028000000100000000e0000000100180000000000a0020000c40e0000c40e00000000000000000000ff00ffff00ffff00ffff00ffff00ffff00ff808080808080808080808080808080ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffc0c0c0000000c0c0c0000000808080ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffc0c0c000ffffc0c0c000ffff808080ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffc0c0c0c0c0c0c0c0c0c0c0c0808080ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffc0c0c0000000c0c0c0000000808080ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffc0c0c0ff0000c0c0c0ff0000808080ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffc0c0c0c0c0c0c0c0c0c0c0c0808080ff00ffff00ffff00ffff00ffff00ff00ff0000ff0000ff0000ff0000ff0000ff00c0c0c0000000c0c0c0000000808080ff00ffff00ffff00ffff00ffff00ff00ff0000ff0000ff0000ff0000ff0000ff00c0c0c00000ffc0c0c00000ff808080ff00ffff00ffff00ffff00ffff00ff00ff0000ff0000ff0000ff0000ff0000ff00c0c0c0c0c0c0c0c0c0c0c0c0808080ff00ffff00ffff00ffff00ffff00ff00ff0000ff0000ff0000ff0000ff0000ff00c0c0c0000000c0c0c0000000808080ff00ffff00ffff00ffff00ffff00ff00ff0000ff0000ff0000ff0000ff0000ff00c0c0c0c0c0c0c0c0c0c0c0c0808080ff00ffff00ffff00ffff00ffff00ff00ff0000ff0000ff0000ff0000ff0000ff00c0c0c0008000c0c0c0008000808080ff00ffff00ffff00ffff00ffff00ff00ff0000ff0000ff0000ff0000ff0000ff00c0c0c0c0c0c0c0c0c0c0c0c0808080ff00ffff00ffff00ffff00ffff00ff</ImageData>
</ImageDatas>
<Box Id="76" BoxType="9099" BoxFlags="#x00000020">
<Name>__FILENAME__</Name>
<ImageId>1000</ImageId>
<EtherCAT SlaveType="2" PdiType="#x0005" MboxDataLinkLayer="true" StateMBoxPolling="true" CycleMBoxPollingTime="0" CoeType="7" FoeType="1" VendorId="#x00000002" ProductCode="#x0e123052" RevisionNo="#x00130000" InfoDataAddr="true" TimeoutMailbox2="2000" CheckRevisionNoType="3" PortPhys="51" MaxSlotCount="256" MaxSlotGroupCount="1" SlotPdoIncrement="1" SlotIndexIncrement="16" Type="EL3602 2Ch. Ana. Input +/-10Volt, Diff. 24bit" Desc="EL3602">
<SyncMan>001080002600010001000000800080008000001026010000</SyncMan>
<SyncMan>801080002200010002000000800080008000801022010000</SyncMan>
<SyncMan>001100000400000003000000000000000000001104000000</SyncMan>
<SyncMan>80110c002000010004000000000000000c00801120010000</SyncMan>
<Fmmu>0000000000000000801100010100000002000000000000000000000000000000</Fmmu>
<Fmmu>00000000000000000d0800010100000003000000000000000000000000000000</Fmmu>
<BootStrapData>0010f400f410f400</BootStrapData>
<Pdo Name="AI Inputs Channel 1" Index="#x1a00" Flags="#x0010" SyncMan="3">
<Entry Name="Underrange" Index="#x6000" Sub="#x01">
<Type>BIT</Type>
<Comment>
<![CDATA[Underrange event active]]>
</Comment>
</Entry>
<Entry Name="Overrange" Index="#x6000" Sub="#x02">
<Type>BIT</Type>
<Comment>
<![CDATA[Overrange event active]]>
</Comment>
</Entry>
<Entry Name="Limit 1" Index="#x6000" Sub="#x03">
<Type>BIT2</Type>
<Comment>
<![CDATA[Bit0: Value smaller/equal Limit1
Bit1: Value bigger/equal Limit1]]>
</Comment>
</Entry>
<Entry Name="Limit 2" Index="#x6000" Sub="#x05">
<Type>BIT2</Type>
<Comment>
<![CDATA[Bit0: Value smaller/equal Limit2
Bit1: Value bigger/equal Limit2]]>
</Comment>
</Entry>
<Entry Name="Error" Index="#x6000" Sub="#x07">
<Type>BIT</Type>
<Comment>
<![CDATA[Bit set when Over- or Underrange]]>
</Comment>
</Entry>
<Entry>
<Type GUID="{18071995-0000-0000-0000-002000000007}">ARRAY [0..6] OF BIT</Type>
</Entry>
<Entry Name="TxPDO State" Index="#x1800" Sub="#x07">
<Type>BIT</Type>
<Comment>
<![CDATA[TRUE when this TxPDO is not valid]]>
</Comment>
</Entry>
<Entry Name="TxPDO Toggle" Index="#x1800" Sub="#x09">
<Type>BIT</Type>
<Comment>
<![CDATA[Bit toggles everytime when new value available]]>
</Comment>
</Entry>
<Entry Name="Value" Index="#x6000" Sub="#x11" Flags="#x00010000">
<Type>DINT</Type>
</Entry>
</Pdo>
<Pdo Name="AI Inputs Channel 2" Index="#x1a01" Flags="#x0010" SyncMan="3">
<Entry Name="Underrange" Index="#x6010" Sub="#x01">
<Type>BIT</Type>
<Comment>
<![CDATA[Underrange event active]]>
</Comment>
</Entry>
<Entry Name="Overrange" Index="#x6010" Sub="#x02">
<Type>BIT</Type>
<Comment>
<![CDATA[Overrange event active]]>
</Comment>
</Entry>
<Entry Name="Limit 1" Index="#x6010" Sub="#x03">
<Type>BIT2</Type>
<Comment>
<![CDATA[Bit0: Value smaller/equal Limit1
Bit1: Value bigger/equal Limit1]]>
</Comment>
</Entry>
<Entry Name="Limit 2" Index="#x6010" Sub="#x05">
<Type>BIT2</Type>
<Comment>
<![CDATA[Bit0: Value smaller/equal Limit2
Bit1: Value bigger/equal Limit2]]>
</Comment>
</Entry>
<Entry Name="Error" Index="#x6010" Sub="#x07">
<Type>BIT</Type>
<Comment>
<![CDATA[Bit set when Over- or Underrange]]>
</Comment>
</Entry>
<Entry>
<Type GUID="{18071995-0000-0000-0000-002000000007}">ARRAY [0..6] OF BIT</Type>
</Entry>
<Entry Name="TxPDO State" Index="#x1801" Sub="#x07">
<Type>BIT</Type>
<Comment>
<![CDATA[TRUE when this TxPDO is not valid]]>
</Comment>
</Entry>
<Entry Name="TxPDO Toggle" Index="#x1801" Sub="#x09">
<Type>BIT</Type>
<Comment>
<![CDATA[Bit toggles everytime when new value available]]>
</Comment>
</Entry>
<Entry Name="Value" Index="#x6010" Sub="#x11" Flags="#x00010000">
<Type>DINT</Type>
</Entry>
</Pdo>
<CoeProfile ProfileNo="19665801"/>
<CoeProfile ProfileNo="19665801"/>
</EtherCAT>
</Box>
</TcSmItem>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<TcSmItem 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.4024.4" ClassName="CFlbTermDef" SubType="9099">
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<TcSmItem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.beckhoff.com/schemas/2012/07/TcSmItem" TcSmVersion="1.0" TcVersion="3.1.4022.30" ClassName="CFlbTermDef" SubType="9099">
<ImageDatas>
<ImageData Id="1000">424dd6020000000000003600000028000000100000000e0000000100180000000000a0020000c40e0000c40e00000000000000000000ff00ffff00ffff00ffff00ffff00ffff00ff808080808080808080ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffc0c0c0c0c0c0808080ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffc0c0c0c0c0c0808080ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffc0c0c0c0c0c0808080ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffc0c0c0c0c0c0808080ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffc0c0c0c0c0c0808080ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffc0c0c0c0c0c0808080ff00ffff00ffff00ffff00ffff00ffff00ffff00ff007fff007fff007fff007fff007fff007fffc0c0c0c0c0c0808080ff00ffff00ffff00ffff00ffff00ffff00ffff00ff007fff007fff007fff007fff007fff007fffc0c0c0c0c0c0808080ff00ffff00ffff00ffff00ffff00ffff00ffff00ff007fff007fff007fff007fff007fff007fffc0c0c0c0c0c0808080ff00ffff00ffff00ffff00ffff00ffff00ffff00ff007fff007fff007fff007fff007fff007fffc0c0c0c0c0c0808080ff00ffff00ffff00ffff00ffff00ffff00ffff00ff007fff007fff007fff007fff007fff007fffc0c0c0c0c0c0808080ff00ffff00ffff00ffff00ffff00ffff00ffff00ff007fff007fff007fff007fff007fff007fffc0c0c0c0c0c0808080ff00ffff00ffff00ffff00ffff00ffff00ffff00ff007fff007fff007fff007fff007fff007fffc0c0c0c0c0c0808080ff00ffff00ffff00ffff00ffff00ffff00ffff00ff</ImageData>
</ImageDatas>
Expand Down
19 changes: 13 additions & 6 deletions plc-kfe-rix-motion/_Config/PLC/kfe_rix_motion.xti
Original file line number Diff line number Diff line change
Expand Up @@ -2540,8 +2540,8 @@ External Setpoint Generation:
<Type>INT</Type>
</Var>
<Var>
<Name>PRG_IM4K2_PPM.fbIM4K2.fbPowerMeter.iVoltageINT</Name>
<Type>INT</Type>
<Name>PRG_IM4K2_PPM.fbIM4K2.fbPowerMeter.iVoltageDINT</Name>
<Type>DINT</Type>
</Var>
<Var>
<Name>PRG_IM4K2_PPM.fbIM4K2.fbPowerMeter.fbThermoCouple.bError</Name>
Expand All @@ -2564,7 +2564,7 @@ External Setpoint Generation:
<Comment>
<![CDATA[ Connect this input to the terminal]]>
</Comment>
<Type>INT</Type>
<Type>DINT</Type>
</Var>
<Var>
<Name>PRG_IM4K2_PPM.fbIM4K2.fbGige.fbGetIllPercent.iRaw</Name>
Expand Down Expand Up @@ -10777,6 +10777,13 @@ External Setpoint Generation:
</OwnerB>
</OwnerA>
</UnrestoredVarLinks>
<UnrestoredVarLinks ImportTime="2024-06-11T14:08:48">
<OwnerA Name="InputDst" Prefix="TIPC^kfe_rix_motion^kfe_rix_motion Instance" Type="1">
<OwnerB Name="TIID^PLC Rail (EtherCAT)^Power (EK1200)^Fiber Coupler (EK1521-0010)^Term 34 (EK1501-0010)^Term 50 (EK1122)^IM4K2-PPM (EK1100)^IM4K2-EL3062-E6">
<Link VarA="PRG_IM4K2_PPM.fbIM4K2.fbPowerMeter.iVoltageINT" TypeA="INT" InOutA="0" GuidA="{18071995-0000-0000-0000-000000000006}" VarB="AI Standard Channel 1^Value" AutoLink="true" RestoreInfo="ANotFound"/>
</OwnerB>
</OwnerA>
</UnrestoredVarLinks>
<TaskPouOids>
<TaskPouOid Prio="20" OTCID="#x08502001"/>
</TaskPouOids>
Expand Down Expand Up @@ -11246,9 +11253,6 @@ External Setpoint Generation:
<Link VarA="PlcTask Outputs^Main.M8.bBrakeRelease" VarB="Channel 1^Output" AutoLink="true"/>
<Link VarA="PlcTask Outputs^PRG_IM4K2_PPM.fbIM4K2.fbGige.bGigePower" VarB="Channel 2^Output" AutoLink="true"/>
</OwnerB>
<OwnerB Name="TIID^PLC Rail (EtherCAT)^Power (EK1200)^Fiber Coupler (EK1521-0010)^Term 34 (EK1501-0010)^Term 50 (EK1122)^IM4K2-PPM (EK1100)^IM4K2-EL3062-E6">
<Link VarA="PlcTask Inputs^PRG_IM4K2_PPM.fbIM4K2.fbPowerMeter.iVoltageINT" VarB="AI Standard Channel 1^Value" AutoLink="true"/>
</OwnerB>
<OwnerB Name="TIID^PLC Rail (EtherCAT)^Power (EK1200)^Fiber Coupler (EK1521-0010)^Term 34 (EK1501-0010)^Term 50 (EK1122)^IM4K2-PPM (EK1100)^IM4K2-EL3314-E4">
<Link VarA="PlcTask Inputs^PRG_IM4K2_PPM.fbIM4K2.fbPowerMeter.fbThermoCouple.bError" VarB="TC Inputs Channel 1^Status^Error" AutoLink="true"/>
<Link VarA="PlcTask Inputs^PRG_IM4K2_PPM.fbIM4K2.fbPowerMeter.fbThermoCouple.bOverrange" VarB="TC Inputs Channel 1^Status^Overrange" AutoLink="true"/>
Expand All @@ -11259,6 +11263,9 @@ External Setpoint Generation:
<Link VarA="PlcTask Inputs^PRG_IM4K2_PPM.fbIM4K2.fbYagThermoCouple.bUnderrange" VarB="TC Inputs Channel 2^Status^Underrange" AutoLink="true"/>
<Link VarA="PlcTask Inputs^PRG_IM4K2_PPM.fbIM4K2.fbYagThermoCouple.iRaw" VarB="TC Inputs Channel 2^Value" AutoLink="true"/>
</OwnerB>
<OwnerB Name="TIID^PLC Rail (EtherCAT)^Power (EK1200)^Fiber Coupler (EK1521-0010)^Term 34 (EK1501-0010)^Term 50 (EK1122)^IM4K2-PPM (EK1100)^IM4K2-EL3602-E8">
<Link VarA="PlcTask Inputs^PRG_IM4K2_PPM.fbIM4K2.fbPowerMeter.iVoltageDINT" VarB="AI Inputs Channel 1^Value" AutoLink="true"/>
</OwnerB>
<OwnerB Name="TIID^PLC Rail (EtherCAT)^Power (EK1200)^Fiber Coupler (EK1521-0010)^Term 34 (EK1501-0010)^Term 50 (EK1122)^IM4K2-PPM (EK1100)^IM4K2-EL4004-E7">
<Link VarA="PlcTask Outputs^PRG_IM4K2_PPM.fbIM4K2.fbGige.iIlluminatorINT" VarB="AO Outputs Channel 1^Analog output" AutoLink="true"/>
</OwnerB>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4022.18">
<POU Name="FB_AnalogInput_IM4K2" Id="{c3bf2f11-e399-406d-ba95-ae8960e90a27}" SpecialFunc="None">
<Declaration><![CDATA[FUNCTION_BLOCK FB_AnalogInput_IM4K2
(*
Converts the integer from an analog input terminal to a real unit value (e.g., volts)
2019-10-09 Zachary Lentz
*)
VAR_INPUT
// Connect this input to the terminal
iRaw AT %I*: DINT;
// The number of bits correlated with the terminal's max value. This is not necessarily the resolution parameter.
iTermBits: UINT;
// The fReal value correlated with the terminal's max value
fTermMax: LREAL;
// The fReal value correlated with the terminal's min value
fTermMin: LREAL;
// Value to scale the end result to
{attribute 'pytmc' := '
pv: RES
io: io
'}
fResolution : LREAL := 1;
{attribute 'pytmc' := '
pv: OFF
io: io
'}
fOffset : LREAL;
END_VAR
VAR_OUTPUT
// The real value read from the output
{attribute 'pytmc' := '
pv: VAL
io: i
'}
fReal: LREAL;
END_VAR
VAR
fScale: LREAL;
END_VAR]]></Declaration>
<Implementation>
<ST><![CDATA[IF fScale = 0 AND fTermMax > fTermMin THEN
fScale := (EXPT(2, iTermBits) - 1) / (fTermMax - fTermMin);
END_IF
IF fScale <> 0 THEN
fReal := iRaw / fScale + fTermMin;
fReal := fReal * fResolution + fOffset;
END_IF]]></ST>
</Implementation>
</POU>
</TcPlcObject>
Loading

0 comments on commit 24c8ec7

Please sign in to comment.