Works in TwinCAT. Prepare for test in machine.

This commit is contained in:
Hakan Bastedt
2025-02-14 20:06:27 +01:00
parent 310a08cc67
commit e40d81e71c
11 changed files with 221 additions and 136 deletions

View File

@@ -138,7 +138,7 @@
</SubItem>
<SubItem>
<SubIdx>1</SubIdx>
<Name>ArcVoltage</Name>
<Name>RawData</Name>
<Type>UDINT</Type>
<BitSize>32</BitSize>
<BitOffs>16</BitOffs>
@@ -162,7 +162,31 @@
</SubItem>
<SubItem>
<SubIdx>1</SubIdx>
<Name>Voltage</Name>
<Name>CalculatedVoltage</Name>
<Type>UDINT</Type>
<BitSize>32</BitSize>
<BitOffs>16</BitOffs>
<Flags>
<Access>ro</Access>
</Flags>
</SubItem>
</DataType>
<DataType>
<Name>DT1A03</Name>
<BitSize>48</BitSize>
<SubItem>
<SubIdx>0</SubIdx>
<Name>Max SubIndex</Name>
<Type>USINT</Type>
<BitSize>8</BitSize>
<BitOffs>0</BitOffs>
<Flags>
<Access>ro</Access>
</Flags>
</SubItem>
<SubItem>
<SubIdx>1</SubIdx>
<Name>Status</Name>
<Type>UDINT</Type>
<BitSize>32</BitSize>
<BitOffs>16</BitOffs>
@@ -238,15 +262,15 @@
<DataType>
<Name>DT1C13ARR</Name>
<BaseType>UINT</BaseType>
<BitSize>48</BitSize>
<BitSize>64</BitSize>
<ArrayInfo>
<LBound>1</LBound>
<Elements>3</Elements>
<Elements>4</Elements>
</ArrayInfo>
</DataType>
<DataType>
<Name>DT1C13</Name>
<BitSize>64</BitSize>
<BitSize>80</BitSize>
<SubItem>
<SubIdx>0</SubIdx>
<Name>Max SubIndex</Name>
@@ -260,7 +284,7 @@
<SubItem>
<Name>Elements</Name>
<Type>DT1C13ARR</Type>
<BitSize>48</BitSize>
<BitSize>64</BitSize>
<BitOffs>16</BitOffs>
<Flags>
<Access>ro</Access>
@@ -436,7 +460,7 @@
</Object>
<Object>
<Index>#x1A01</Index>
<Name>ArcVoltage</Name>
<Name>RawData</Name>
<Type>DT1A01</Type>
<BitSize>48</BitSize>
<Info>
@@ -447,7 +471,7 @@
</Info>
</SubItem>
<SubItem>
<Name>ArcVoltage</Name>
<Name>RawData</Name>
<Info>
<DefaultValue>#x60010020</DefaultValue>
</Info>
@@ -459,7 +483,7 @@
</Object>
<Object>
<Index>#x1A02</Index>
<Name>Voltage</Name>
<Name>CalculatedVoltage</Name>
<Type>DT1A02</Type>
<BitSize>48</BitSize>
<Info>
@@ -470,7 +494,7 @@
</Info>
</SubItem>
<SubItem>
<Name>Voltage</Name>
<Name>CalculatedVoltage</Name>
<Info>
<DefaultValue>#x60020020</DefaultValue>
</Info>
@@ -480,6 +504,29 @@
<Access>ro</Access>
</Flags>
</Object>
<Object>
<Index>#x1A03</Index>
<Name>Status</Name>
<Type>DT1A03</Type>
<BitSize>48</BitSize>
<Info>
<SubItem>
<Name>Max SubIndex</Name>
<Info>
<DefaultValue>1</DefaultValue>
</Info>
</SubItem>
<SubItem>
<Name>Status</Name>
<Info>
<DefaultValue>#x60030008</DefaultValue>
</Info>
</SubItem>
</Info>
<Flags>
<Access>ro</Access>
</Flags>
</Object>
<Object>
<Index>#x1C00</Index>
<Name>Sync Manager Communication Type</Name>
@@ -548,12 +595,12 @@
<Index>#x1C13</Index>
<Name>Sync Manager 3 PDO Assignment</Name>
<Type>DT1C13</Type>
<BitSize>64</BitSize>
<BitSize>80</BitSize>
<Info>
<SubItem>
<Name>Max SubIndex</Name>
<Info>
<DefaultValue>3</DefaultValue>
<DefaultValue>4</DefaultValue>
</Info>
</SubItem>
<SubItem>
@@ -574,6 +621,12 @@
<DefaultValue>#x1A02</DefaultValue>
</Info>
</SubItem>
<SubItem>
<Name>PDO Mapping</Name>
<Info>
<DefaultValue>#x1A03</DefaultValue>
</Info>
</SubItem>
</Info>
<Flags>
<Access>ro</Access>
@@ -581,7 +634,7 @@
</Object>
<Object>
<Index>#x2000</Index>
<Name>VoltageScale</Name>
<Name>Scale</Name>
<Type>REAL</Type>
<BitSize>32</BitSize>
<Info>
@@ -591,6 +644,18 @@
<Access>ro</Access>
</Flags>
</Object>
<Object>
<Index>#x2001</Index>
<Name>Offset</Name>
<Type>REAL</Type>
<BitSize>32</BitSize>
<Info>
<DefaultValue>0</DefaultValue>
</Info>
<Flags>
<Access>ro</Access>
</Flags>
</Object>
<Object>
<Index>#x6000</Index>
<Name>Input12</Name>
@@ -606,8 +671,8 @@
</Object>
<Object>
<Index>#x6001</Index>
<Name>ArcVoltage</Name>
<Type>REAL</Type>
<Name>RawData</Name>
<Type>DINT</Type>
<BitSize>32</BitSize>
<Info>
<DefaultValue>0</DefaultValue>
@@ -619,7 +684,7 @@
</Object>
<Object>
<Index>#x6002</Index>
<Name>Voltage</Name>
<Name>CalculatedVoltage</Name>
<Type>REAL</Type>
<BitSize>32</BitSize>
<Info>
@@ -630,6 +695,19 @@
<PdoMapping>T</PdoMapping>
</Flags>
</Object>
<Object>
<Index>#x6003</Index>
<Name>Status</Name>
<Type>USINT</Type>
<BitSize>8</BitSize>
<Info>
<DefaultValue>0</DefaultValue>
</Info>
<Flags>
<Access>ro</Access>
<PdoMapping>T</PdoMapping>
</Flags>
</Object>
<Object>
<Index>#x7000</Index>
<Name>Output4</Name>
@@ -677,26 +755,37 @@
</TxPdo>
<TxPdo Fixed="true" Mandatory="true" Sm="3">
<Index>#x1A01</Index>
<Name>ArcVoltage</Name>
<Name>RawData</Name>
<Entry>
<Index>#x6001</Index>
<SubIndex>#x0</SubIndex>
<BitLen>32</BitLen>
<Name>ArcVoltage</Name>
<DataType>REAL</DataType>
<Name>RawData</Name>
<DataType>DINT</DataType>
</Entry>
</TxPdo>
<TxPdo Fixed="true" Mandatory="true" Sm="3">
<Index>#x1A02</Index>
<Name>Voltage</Name>
<Name>CalculatedVoltage</Name>
<Entry>
<Index>#x6002</Index>
<SubIndex>#x0</SubIndex>
<BitLen>32</BitLen>
<Name>Voltage</Name>
<Name>CalculatedVoltage</Name>
<DataType>REAL</DataType>
</Entry>
</TxPdo>
<TxPdo Fixed="true" Mandatory="true" Sm="3">
<Index>#x1A03</Index>
<Name>Status</Name>
<Entry>
<Index>#x6003</Index>
<SubIndex>#x0</SubIndex>
<BitLen>8</BitLen>
<Name>Status</Name>
<DataType>USINT</DataType>
</Entry>
</TxPdo>
<Mailbox DataLinkLayer="true">
<CoE SdoInfo="true" PdoAssign="false" PdoConfig="false" PdoUpload="true" CompleteAccess="false" />
</Mailbox>

View File

@@ -34,7 +34,7 @@
#define SM3_act 1
#define MAX_MAPPINGS_SM2 1
#define MAX_MAPPINGS_SM3 3
#define MAX_MAPPINGS_SM3 4
#define MAX_RXPDO_SIZE 512
#define MAX_TXPDO_SIZE 512

View File

@@ -36,12 +36,21 @@
"sdo": {
"2000": {
"otype": "VAR",
"name": "VoltageScale",
"name": "Scale",
"access": "RO",
"dtype": "REAL32",
"value": "1",
"isSDOitem": true,
"data": "&Obj.VoltageScale"
"data": "&Obj.Scale"
},
"2001": {
"otype": "VAR",
"name": "Offset",
"access": "RO",
"dtype": "REAL32",
"value": "0",
"isSDOitem": true,
"data": "&Obj.Offset"
},
"A": {
"otype": "RECORD",
@@ -83,25 +92,36 @@
},
"6001": {
"otype": "VAR",
"name": "ArcVoltage",
"name": "RawData",
"access": "RO",
"pdo_mappings": [
"txpdo"
],
"dtype": "REAL32",
"dtype": "INTEGER32",
"value": "0",
"data": "&Obj.ArcVoltage"
"data": "&Obj.RawData"
},
"6002": {
"otype": "VAR",
"name": "Voltage",
"name": "CalculatedVoltage",
"access": "RO",
"pdo_mappings": [
"txpdo"
],
"dtype": "REAL32",
"value": "0",
"data": "&Obj.Voltage"
"data": "&Obj.CalculatedVoltage"
},
"6003": {
"otype": "VAR",
"name": "Status",
"access": "RO",
"pdo_mappings": [
"txpdo"
],
"dtype": "UNSIGNED8",
"value": "0",
"data": "&Obj.Status"
}
},
"rxpdo": {

View File

@@ -19,12 +19,15 @@ static const char acName1600_01[] = "Output4";
static const char acName1A00[] = "Input12";
static const char acName1A00_00[] = "Max SubIndex";
static const char acName1A00_01[] = "Input12";
static const char acName1A01[] = "ArcVoltage";
static const char acName1A01[] = "RawData";
static const char acName1A01_00[] = "Max SubIndex";
static const char acName1A01_01[] = "ArcVoltage";
static const char acName1A02[] = "Voltage";
static const char acName1A01_01[] = "RawData";
static const char acName1A02[] = "CalculatedVoltage";
static const char acName1A02_00[] = "Max SubIndex";
static const char acName1A02_01[] = "Voltage";
static const char acName1A02_01[] = "CalculatedVoltage";
static const char acName1A03[] = "Status";
static const char acName1A03_00[] = "Max SubIndex";
static const char acName1A03_01[] = "Status";
static const char acName1C00[] = "Sync Manager Communication Type";
static const char acName1C00_00[] = "Max SubIndex";
static const char acName1C00_01[] = "Communications Type SM0";
@@ -39,10 +42,13 @@ static const char acName1C13_00[] = "Max SubIndex";
static const char acName1C13_01[] = "PDO Mapping";
static const char acName1C13_02[] = "PDO Mapping";
static const char acName1C13_03[] = "PDO Mapping";
static const char acName2000[] = "VoltageScale";
static const char acName1C13_04[] = "PDO Mapping";
static const char acName2000[] = "Scale";
static const char acName2001[] = "Offset";
static const char acName6000[] = "Input12";
static const char acName6001[] = "ArcVoltage";
static const char acName6002[] = "Voltage";
static const char acName6001[] = "RawData";
static const char acName6002[] = "CalculatedVoltage";
static const char acName6003[] = "Status";
static const char acName7000[] = "Output4";
const _objd SDO1000[] =
@@ -89,6 +95,11 @@ const _objd SDO1A02[] =
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A02_00, 1, NULL},
{0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A02_01, 0x60020020, NULL},
};
const _objd SDO1A03[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A03_00, 1, NULL},
{0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A03_01, 0x60030008, NULL},
};
const _objd SDO1C00[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C00_00, 4, NULL},
@@ -104,14 +115,19 @@ const _objd SDO1C12[] =
};
const _objd SDO1C13[] =
{
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C13_00, 3, NULL},
{0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C13_00, 4, NULL},
{0x01, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C13_01, 0x1A00, NULL},
{0x02, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C13_02, 0x1A01, NULL},
{0x03, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C13_03, 0x1A02, NULL},
{0x04, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C13_04, 0x1A03, NULL},
};
const _objd SDO2000[] =
{
{0x0, DTYPE_REAL32, 32, ATYPE_RO, acName2000, 0x3f800000, &Obj.VoltageScale},
{0x0, DTYPE_REAL32, 32, ATYPE_RO, acName2000, 0x3f800000, &Obj.Scale},
};
const _objd SDO2001[] =
{
{0x0, DTYPE_REAL32, 32, ATYPE_RO, acName2001, 0x00000000, &Obj.Offset},
};
const _objd SDO6000[] =
{
@@ -119,11 +135,15 @@ const _objd SDO6000[] =
};
const _objd SDO6001[] =
{
{0x0, DTYPE_REAL32, 32, ATYPE_RO | ATYPE_TXPDO, acName6001, 0x00000000, &Obj.ArcVoltage},
{0x0, DTYPE_INTEGER32, 32, ATYPE_RO | ATYPE_TXPDO, acName6001, 0, &Obj.RawData},
};
const _objd SDO6002[] =
{
{0x0, DTYPE_REAL32, 32, ATYPE_RO | ATYPE_TXPDO, acName6002, 0x00000000, &Obj.Voltage},
{0x0, DTYPE_REAL32, 32, ATYPE_RO | ATYPE_TXPDO, acName6002, 0x00000000, &Obj.CalculatedVoltage},
};
const _objd SDO6003[] =
{
{0x0, DTYPE_UNSIGNED8, 8, ATYPE_RO | ATYPE_TXPDO, acName6003, 0, &Obj.Status},
};
const _objd SDO7000[] =
{
@@ -141,13 +161,16 @@ const _objectlist SDOobjects[] =
{0x1A00, OTYPE_RECORD, 1, 0, acName1A00, SDO1A00},
{0x1A01, OTYPE_RECORD, 1, 0, acName1A01, SDO1A01},
{0x1A02, OTYPE_RECORD, 1, 0, acName1A02, SDO1A02},
{0x1A03, OTYPE_RECORD, 1, 0, acName1A03, SDO1A03},
{0x1C00, OTYPE_ARRAY, 4, 0, acName1C00, SDO1C00},
{0x1C12, OTYPE_ARRAY, 1, 0, acName1C12, SDO1C12},
{0x1C13, OTYPE_ARRAY, 3, 0, acName1C13, SDO1C13},
{0x1C13, OTYPE_ARRAY, 4, 0, acName1C13, SDO1C13},
{0x2000, OTYPE_VAR, 0, 0, acName2000, SDO2000},
{0x2001, OTYPE_VAR, 0, 0, acName2001, SDO2001},
{0x6000, OTYPE_VAR, 0, 0, acName6000, SDO6000},
{0x6001, OTYPE_VAR, 0, 0, acName6001, SDO6001},
{0x6002, OTYPE_VAR, 0, 0, acName6002, SDO6002},
{0x6003, OTYPE_VAR, 0, 0, acName6003, SDO6003},
{0x7000, OTYPE_VAR, 0, 0, acName7000, SDO7000},
{0xffff, 0xff, 0xff, 0xff, NULL, NULL}
};

View File

@@ -14,8 +14,9 @@ typedef struct
/* Inputs */
int32_t Input12;
float ArcVoltage;
float Voltage;
int32_t RawData;
float CalculatedVoltage;
uint8_t Status;
/* Outputs */
@@ -23,7 +24,8 @@ typedef struct
/* Parameters */
float VoltageScale;
float Scale;
float Offset;
} _Objects;
extern _Objects Obj;