From 44a15a21f82cb89565269fcbfedf2954652c0c7f Mon Sep 17 00:00:00 2001 From: Hakan Bastedt Date: Wed, 6 Aug 2025 21:02:22 +0200 Subject: [PATCH] Updated encoder --- .../soes-esi/MetalMusings_EaserCAT_3000.xml | 288 ++++++++++++++++-- .../Firmware/lib/soes-esi/ecat_options.h | 4 +- .../Firmware/lib/soes-esi/esi.json | 45 ++- .../Firmware/lib/soes-esi/objectlist.c | 83 ++++- .../Firmware/lib/soes-esi/utypes.h | 9 +- .../Firmware/src/main.cpp | 24 +- 6 files changed, 382 insertions(+), 71 deletions(-) diff --git a/Cards/EaserCAT-3000-Digital-Stepper-Analog-Encoder-Frequency/Firmware/lib/soes-esi/MetalMusings_EaserCAT_3000.xml b/Cards/EaserCAT-3000-Digital-Stepper-Analog-Encoder-Frequency/Firmware/lib/soes-esi/MetalMusings_EaserCAT_3000.xml index 1085f9e..872a9e8 100755 --- a/Cards/EaserCAT-3000-Digital-Stepper-Analog-Encoder-Frequency/Firmware/lib/soes-esi/MetalMusings_EaserCAT_3000.xml +++ b/Cards/EaserCAT-3000-Digital-Stepper-Analog-Encoder-Frequency/Firmware/lib/soes-esi/MetalMusings_EaserCAT_3000.xml @@ -90,7 +90,7 @@ 1 - Scale + EncScale UDINT 32 16 @@ -507,6 +507,30 @@ + + DT1612 + 48 + + 0 + Max SubIndex + USINT + 8 + 0 + + ro + + + + 1 + EncIndexLatchEnable + UDINT + 32 + 16 + + ro + + + DT1A00 48 @@ -522,7 +546,7 @@ 1 - Velocity + EncPosition UDINT 32 16 @@ -546,7 +570,7 @@ 1 - Frequency + EncVelocity UDINT 32 16 @@ -675,6 +699,54 @@ + + DT1A07 + 48 + + 0 + Max SubIndex + USINT + 8 + 0 + + ro + + + + 1 + IndexByte + UDINT + 32 + 16 + + ro + + + + + DT1A08 + 48 + + 0 + Max SubIndex + USINT + 8 + 0 + + ro + + + + 1 + IndexStatus + UDINT + 32 + 16 + + ro + + + DT1C00ARR USINT @@ -710,15 +782,15 @@ DT1C12ARR UINT - 288 + 304 1 - 18 + 19 DT1C12 - 304 + 320 0 Max SubIndex @@ -732,7 +804,7 @@ Elements DT1C12ARR - 288 + 304 16 ro @@ -742,15 +814,15 @@ DT1C13ARR UINT - 112 + 144 1 - 7 + 9 DT1C13 - 128 + 160 0 Max SubIndex @@ -764,7 +836,7 @@ Elements DT1C13ARR - 112 + 144 16 ro @@ -889,7 +961,7 @@ #x1600 - Scale + EncScale DT1600 48 @@ -900,7 +972,7 @@ - Scale + EncScale #x70000020 @@ -1283,9 +1355,31 @@ + + #x1612 + EncIndexLatchEnable + DT1612 + 48 + + + Max SubIndex + + 1 + + + + EncIndexLatchEnable + + #x70120008 + + + + + + #x1A00 - Velocity + EncPosition DT1A00 48 @@ -1296,7 +1390,7 @@ - Velocity + EncPosition #x60000020 @@ -1307,7 +1401,7 @@ #x1A01 - Frequency + EncVelocity DT1A01 48 @@ -1318,7 +1412,7 @@ - Frequency + EncVelocity #x60010020 @@ -1437,6 +1531,50 @@ + + #x1A07 + IndexByte + DT1A07 + 48 + + + Max SubIndex + + 1 + + + + IndexByte + + #x60070020 + + + + + + + + #x1A08 + IndexStatus + DT1A08 + 48 + + + Max SubIndex + + 1 + + + + IndexStatus + + #x60080020 + + + + + + #x1C00 Sync Manager Communication Type @@ -1481,12 +1619,12 @@ #x1C12 Sync Manager 2 PDO Assignment DT1C12 - 304 + 320 Max SubIndex - 18 + 19 @@ -1597,6 +1735,12 @@ #x1611 + + PDO Mapping + + #x1612 + + @@ -1605,12 +1749,12 @@ #x1C13 Sync Manager 3 PDO Assignment DT1C13 - 128 + 160 Max SubIndex - 7 + 9 @@ -1655,6 +1799,18 @@ #x1A06 + + PDO Mapping + + #x1A07 + + + + PDO Mapping + + #x1A08 + + @@ -1673,7 +1829,7 @@ #x6000 - Velocity + EncPosition REAL 32 @@ -1686,7 +1842,7 @@ #x6001 - Frequency + EncVelocity REAL 32 @@ -1762,9 +1918,35 @@ T + + #x6007 + IndexByte + UDINT + 32 + + 0 + + + ro + T + + + + #x6008 + IndexStatus + UDINT + 32 + + 0 + + + ro + T + + #x7000 - Scale + EncScale REAL 32 @@ -1996,6 +2178,19 @@ R + + #x7012 + EncIndexLatchEnable + USINT + 8 + + 0 + + + ro + R + + @@ -2008,12 +2203,12 @@ Inputs #x1600 - Scale + EncScale #x7000 #x0 32 - Scale + EncScale REAL @@ -2204,25 +2399,36 @@ USINT + + #x1612 + EncIndexLatchEnable + + #x7012 + #x0 + 8 + EncIndexLatchEnable + USINT + + #x1A00 - Velocity + EncPosition #x6000 #x0 32 - Velocity + EncPosition REAL #x1A01 - Frequency + EncVelocity #x6001 #x0 32 - Frequency + EncVelocity REAL @@ -2281,6 +2487,28 @@ REAL + + #x1A07 + IndexByte + + #x6007 + #x0 + 32 + IndexByte + UDINT + + + + #x1A08 + IndexStatus + + #x6008 + #x0 + 32 + IndexStatus + UDINT + + diff --git a/Cards/EaserCAT-3000-Digital-Stepper-Analog-Encoder-Frequency/Firmware/lib/soes-esi/ecat_options.h b/Cards/EaserCAT-3000-Digital-Stepper-Analog-Encoder-Frequency/Firmware/lib/soes-esi/ecat_options.h index 2c142f3..734c77c 100755 --- a/Cards/EaserCAT-3000-Digital-Stepper-Analog-Encoder-Frequency/Firmware/lib/soes-esi/ecat_options.h +++ b/Cards/EaserCAT-3000-Digital-Stepper-Analog-Encoder-Frequency/Firmware/lib/soes-esi/ecat_options.h @@ -33,8 +33,8 @@ #define SM3_smc 0x20 #define SM3_act 1 -#define MAX_MAPPINGS_SM2 18 -#define MAX_MAPPINGS_SM3 7 +#define MAX_MAPPINGS_SM2 19 +#define MAX_MAPPINGS_SM3 9 #define MAX_RXPDO_SIZE 512 #define MAX_TXPDO_SIZE 512 diff --git a/Cards/EaserCAT-3000-Digital-Stepper-Analog-Encoder-Frequency/Firmware/lib/soes-esi/esi.json b/Cards/EaserCAT-3000-Digital-Stepper-Analog-Encoder-Frequency/Firmware/lib/soes-esi/esi.json index 486538f..0c60ca8 100755 --- a/Cards/EaserCAT-3000-Digital-Stepper-Analog-Encoder-Frequency/Firmware/lib/soes-esi/esi.json +++ b/Cards/EaserCAT-3000-Digital-Stepper-Analog-Encoder-Frequency/Firmware/lib/soes-esi/esi.json @@ -72,25 +72,25 @@ }, "6000": { "otype": "VAR", - "name": "Velocity", + "name": "EncPosition", "access": "RO", "pdo_mappings": [ "txpdo" ], "dtype": "REAL32", "value": "0", - "data": "&Obj.Velocity" + "data": "&Obj.EncPosition" }, "6001": { "otype": "VAR", - "name": "Frequency", + "name": "EncVelocity", "access": "RO", "pdo_mappings": [ "txpdo" ], "dtype": "REAL32", "value": "0", - "data": "&Obj.Frequency" + "data": "&Obj.EncVelocity" }, "6002": { "otype": "VAR", @@ -146,19 +146,41 @@ "dtype": "REAL32", "value": "0", "data": "&Obj.ActualPosition4" + }, + "6007": { + "otype": "VAR", + "name": "IndexByte", + "access": "RO", + "pdo_mappings": [ + "txpdo" + ], + "dtype": "UNSIGNED32", + "value": "0", + "data": "&Obj.IndexByte" + }, + "6008": { + "otype": "VAR", + "name": "IndexStatus", + "access": "RO", + "pdo_mappings": [ + "txpdo" + ], + "dtype": "UNSIGNED32", + "value": "0", + "data": "&Obj.IndexStatus" } }, "rxpdo": { "7000": { "otype": "VAR", - "name": "Scale", + "name": "EncScale", "access": "RO", "pdo_mappings": [ "rxpdo" ], "dtype": "REAL32", "value": "0", - "data": "&Obj.Scale" + "data": "&Obj.EncScale" }, "7001": { "otype": "VAR", @@ -281,6 +303,17 @@ "value": "0", "data": "&Obj.Enable4" }, + "7012": { + "otype": "VAR", + "name": "EncIndexLatchEnable", + "access": "RO", + "pdo_mappings": [ + "rxpdo" + ], + "dtype": "UNSIGNED8", + "value": "0", + "data": "&Obj.EncIndexLatchEnable" + }, "60664": { "otype": "VAR", "name": "ActualPosition", diff --git a/Cards/EaserCAT-3000-Digital-Stepper-Analog-Encoder-Frequency/Firmware/lib/soes-esi/objectlist.c b/Cards/EaserCAT-3000-Digital-Stepper-Analog-Encoder-Frequency/Firmware/lib/soes-esi/objectlist.c index bc32db7..4cfac5e 100755 --- a/Cards/EaserCAT-3000-Digital-Stepper-Analog-Encoder-Frequency/Firmware/lib/soes-esi/objectlist.c +++ b/Cards/EaserCAT-3000-Digital-Stepper-Analog-Encoder-Frequency/Firmware/lib/soes-esi/objectlist.c @@ -13,9 +13,9 @@ static const char acName1018_01[] = "Vendor ID"; static const char acName1018_02[] = "Product Code"; static const char acName1018_03[] = "Revision Number"; static const char acName1018_04[] = "Serial Number"; -static const char acName1600[] = "Scale"; +static const char acName1600[] = "EncScale"; static const char acName1600_00[] = "Max SubIndex"; -static const char acName1600_01[] = "Scale"; +static const char acName1600_01[] = "EncScale"; static const char acName1601[] = "Output4"; static const char acName1601_00[] = "Max SubIndex"; static const char acName1601_01[] = "Output4"; @@ -67,12 +67,15 @@ static const char acName1610_01[] = "Enable3"; static const char acName1611[] = "Enable4"; static const char acName1611_00[] = "Max SubIndex"; static const char acName1611_01[] = "Enable4"; -static const char acName1A00[] = "Velocity"; +static const char acName1612[] = "EncIndexLatchEnable"; +static const char acName1612_00[] = "Max SubIndex"; +static const char acName1612_01[] = "EncIndexLatchEnable"; +static const char acName1A00[] = "EncPosition"; static const char acName1A00_00[] = "Max SubIndex"; -static const char acName1A00_01[] = "Velocity"; -static const char acName1A01[] = "Frequency"; +static const char acName1A00_01[] = "EncPosition"; +static const char acName1A01[] = "EncVelocity"; static const char acName1A01_00[] = "Max SubIndex"; -static const char acName1A01_01[] = "Frequency"; +static const char acName1A01_01[] = "EncVelocity"; static const char acName1A02[] = "Input8"; static const char acName1A02_00[] = "Max SubIndex"; static const char acName1A02_01[] = "Input8"; @@ -88,6 +91,12 @@ static const char acName1A05_01[] = "ActualPosition3"; static const char acName1A06[] = "ActualPosition4"; static const char acName1A06_00[] = "Max SubIndex"; static const char acName1A06_01[] = "ActualPosition4"; +static const char acName1A07[] = "IndexByte"; +static const char acName1A07_00[] = "Max SubIndex"; +static const char acName1A07_01[] = "IndexByte"; +static const char acName1A08[] = "IndexStatus"; +static const char acName1A08_00[] = "Max SubIndex"; +static const char acName1A08_01[] = "IndexStatus"; static const char acName1C00[] = "Sync Manager Communication Type"; static const char acName1C00_00[] = "Max SubIndex"; static const char acName1C00_01[] = "Communications Type SM0"; @@ -114,6 +123,7 @@ static const char acName1C12_0f[] = "PDO Mapping"; static const char acName1C12_010[] = "PDO Mapping"; static const char acName1C12_11[] = "PDO Mapping"; static const char acName1C12_12[] = "PDO Mapping"; +static const char acName1C12_13[] = "PDO Mapping"; static const char acName1C13[] = "Sync Manager 3 PDO Assignment"; static const char acName1C13_00[] = "Max SubIndex"; static const char acName1C13_01[] = "PDO Mapping"; @@ -123,15 +133,19 @@ static const char acName1C13_04[] = "PDO Mapping"; static const char acName1C13_05[] = "PDO Mapping"; static const char acName1C13_06[] = "PDO Mapping"; static const char acName1C13_07[] = "PDO Mapping"; +static const char acName1C13_08[] = "PDO Mapping"; +static const char acName1C13_09[] = "PDO Mapping"; static const char acName2000[] = "BasePeriod"; -static const char acName6000[] = "Velocity"; -static const char acName6001[] = "Frequency"; +static const char acName6000[] = "EncPosition"; +static const char acName6001[] = "EncVelocity"; static const char acName6002[] = "Input8"; static const char acName6003[] = "ActualPosition1"; static const char acName6004[] = "ActualPosition2"; static const char acName6005[] = "ActualPosition3"; static const char acName6006[] = "ActualPosition4"; -static const char acName7000[] = "Scale"; +static const char acName6007[] = "IndexByte"; +static const char acName6008[] = "IndexStatus"; +static const char acName7000[] = "EncScale"; static const char acName7001[] = "Output4"; static const char acName7002[] = "CommandedPosition1"; static const char acName7003[] = "CommandedPosition2"; @@ -149,6 +163,7 @@ static const char acName700E[] = "Enable1"; static const char acName700F[] = "Enable2"; static const char acName7010[] = "Enable3"; static const char acName7011[] = "Enable4"; +static const char acName7012[] = "EncIndexLatchEnable"; const _objd SDO1000[] = { @@ -264,6 +279,11 @@ const _objd SDO1611[] = {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1611_00, 1, NULL}, {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1611_01, 0x70110008, NULL}, }; +const _objd SDO1612[] = +{ + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1612_00, 1, NULL}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1612_01, 0x70120008, NULL}, +}; const _objd SDO1A00[] = { {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A00_00, 1, NULL}, @@ -299,6 +319,16 @@ const _objd SDO1A06[] = {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A06_00, 1, NULL}, {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A06_01, 0x60060020, NULL}, }; +const _objd SDO1A07[] = +{ + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A07_00, 1, NULL}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A07_01, 0x60070020, NULL}, +}; +const _objd SDO1A08[] = +{ + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A08_00, 1, NULL}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A08_01, 0x60080020, NULL}, +}; const _objd SDO1C00[] = { {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C00_00, 4, NULL}, @@ -309,7 +339,7 @@ const _objd SDO1C00[] = }; const _objd SDO1C12[] = { - {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C12_00, 18, NULL}, + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C12_00, 19, NULL}, {0x01, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C12_01, 0x1600, NULL}, {0x02, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C12_02, 0x1601, NULL}, {0x03, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C12_03, 0x1602, NULL}, @@ -328,10 +358,11 @@ const _objd SDO1C12[] = {0x010, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C12_010, 0x160F, NULL}, {0x11, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C12_11, 0x1610, NULL}, {0x12, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C12_12, 0x1611, NULL}, + {0x13, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C12_13, 0x1612, NULL}, }; const _objd SDO1C13[] = { - {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C13_00, 7, NULL}, + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C13_00, 9, 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}, @@ -339,6 +370,8 @@ const _objd SDO1C13[] = {0x05, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C13_05, 0x1A04, NULL}, {0x06, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C13_06, 0x1A05, NULL}, {0x07, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C13_07, 0x1A06, NULL}, + {0x08, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C13_08, 0x1A07, NULL}, + {0x09, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C13_09, 0x1A08, NULL}, }; const _objd SDO2000[] = { @@ -346,11 +379,11 @@ const _objd SDO2000[] = }; const _objd SDO6000[] = { - {0x0, DTYPE_REAL32, 32, ATYPE_RO | ATYPE_TXPDO, acName6000, 0x00000000, &Obj.Velocity}, + {0x0, DTYPE_REAL32, 32, ATYPE_RO | ATYPE_TXPDO, acName6000, 0x00000000, &Obj.EncPosition}, }; const _objd SDO6001[] = { - {0x0, DTYPE_REAL32, 32, ATYPE_RO | ATYPE_TXPDO, acName6001, 0x00000000, &Obj.Frequency}, + {0x0, DTYPE_REAL32, 32, ATYPE_RO | ATYPE_TXPDO, acName6001, 0x00000000, &Obj.EncVelocity}, }; const _objd SDO6002[] = { @@ -372,9 +405,17 @@ const _objd SDO6006[] = { {0x0, DTYPE_REAL32, 32, ATYPE_RO | ATYPE_TXPDO, acName6006, 0x00000000, &Obj.ActualPosition4}, }; +const _objd SDO6007[] = +{ + {0x0, DTYPE_UNSIGNED32, 32, ATYPE_RO | ATYPE_TXPDO, acName6007, 0, &Obj.IndexByte}, +}; +const _objd SDO6008[] = +{ + {0x0, DTYPE_UNSIGNED32, 32, ATYPE_RO | ATYPE_TXPDO, acName6008, 0, &Obj.IndexStatus}, +}; const _objd SDO7000[] = { - {0x0, DTYPE_REAL32, 32, ATYPE_RO | ATYPE_RXPDO, acName7000, 0x00000000, &Obj.Scale}, + {0x0, DTYPE_REAL32, 32, ATYPE_RO | ATYPE_RXPDO, acName7000, 0x00000000, &Obj.EncScale}, }; const _objd SDO7001[] = { @@ -444,6 +485,10 @@ const _objd SDO7011[] = { {0x0, DTYPE_UNSIGNED8, 8, ATYPE_RO | ATYPE_RXPDO, acName7011, 0, &Obj.Enable4}, }; +const _objd SDO7012[] = +{ + {0x0, DTYPE_UNSIGNED8, 8, ATYPE_RO | ATYPE_RXPDO, acName7012, 0, &Obj.EncIndexLatchEnable}, +}; const _objectlist SDOobjects[] = { @@ -470,6 +515,7 @@ const _objectlist SDOobjects[] = {0x160F, OTYPE_RECORD, 1, 0, acName160F, SDO160F}, {0x1610, OTYPE_RECORD, 1, 0, acName1610, SDO1610}, {0x1611, OTYPE_RECORD, 1, 0, acName1611, SDO1611}, + {0x1612, OTYPE_RECORD, 1, 0, acName1612, SDO1612}, {0x1A00, OTYPE_RECORD, 1, 0, acName1A00, SDO1A00}, {0x1A01, OTYPE_RECORD, 1, 0, acName1A01, SDO1A01}, {0x1A02, OTYPE_RECORD, 1, 0, acName1A02, SDO1A02}, @@ -477,9 +523,11 @@ const _objectlist SDOobjects[] = {0x1A04, OTYPE_RECORD, 1, 0, acName1A04, SDO1A04}, {0x1A05, OTYPE_RECORD, 1, 0, acName1A05, SDO1A05}, {0x1A06, OTYPE_RECORD, 1, 0, acName1A06, SDO1A06}, + {0x1A07, OTYPE_RECORD, 1, 0, acName1A07, SDO1A07}, + {0x1A08, OTYPE_RECORD, 1, 0, acName1A08, SDO1A08}, {0x1C00, OTYPE_ARRAY, 4, 0, acName1C00, SDO1C00}, - {0x1C12, OTYPE_ARRAY, 18, 0, acName1C12, SDO1C12}, - {0x1C13, OTYPE_ARRAY, 7, 0, acName1C13, SDO1C13}, + {0x1C12, OTYPE_ARRAY, 19, 0, acName1C12, SDO1C12}, + {0x1C13, OTYPE_ARRAY, 9, 0, acName1C13, SDO1C13}, {0x2000, OTYPE_VAR, 0, 0, acName2000, SDO2000}, {0x6000, OTYPE_VAR, 0, 0, acName6000, SDO6000}, {0x6001, OTYPE_VAR, 0, 0, acName6001, SDO6001}, @@ -488,6 +536,8 @@ const _objectlist SDOobjects[] = {0x6004, OTYPE_VAR, 0, 0, acName6004, SDO6004}, {0x6005, OTYPE_VAR, 0, 0, acName6005, SDO6005}, {0x6006, OTYPE_VAR, 0, 0, acName6006, SDO6006}, + {0x6007, OTYPE_VAR, 0, 0, acName6007, SDO6007}, + {0x6008, OTYPE_VAR, 0, 0, acName6008, SDO6008}, {0x7000, OTYPE_VAR, 0, 0, acName7000, SDO7000}, {0x7001, OTYPE_VAR, 0, 0, acName7001, SDO7001}, {0x7002, OTYPE_VAR, 0, 0, acName7002, SDO7002}, @@ -506,5 +556,6 @@ const _objectlist SDOobjects[] = {0x700F, OTYPE_VAR, 0, 0, acName700F, SDO700F}, {0x7010, OTYPE_VAR, 0, 0, acName7010, SDO7010}, {0x7011, OTYPE_VAR, 0, 0, acName7011, SDO7011}, + {0x7012, OTYPE_VAR, 0, 0, acName7012, SDO7012}, {0xffff, 0xff, 0xff, 0xff, NULL, NULL} }; diff --git a/Cards/EaserCAT-3000-Digital-Stepper-Analog-Encoder-Frequency/Firmware/lib/soes-esi/utypes.h b/Cards/EaserCAT-3000-Digital-Stepper-Analog-Encoder-Frequency/Firmware/lib/soes-esi/utypes.h index 6648589..0b29590 100755 --- a/Cards/EaserCAT-3000-Digital-Stepper-Analog-Encoder-Frequency/Firmware/lib/soes-esi/utypes.h +++ b/Cards/EaserCAT-3000-Digital-Stepper-Analog-Encoder-Frequency/Firmware/lib/soes-esi/utypes.h @@ -13,17 +13,19 @@ typedef struct /* Inputs */ - float Velocity; - float Frequency; + float EncPosition; + float EncVelocity; uint8_t Input8; float ActualPosition1; float ActualPosition2; float ActualPosition3; float ActualPosition4; + uint32_t IndexByte; + uint32_t IndexStatus; /* Outputs */ - float Scale; + float EncScale; uint8_t Output4; float CommandedPosition1; float CommandedPosition2; @@ -41,6 +43,7 @@ typedef struct uint8_t Enable2; uint8_t Enable3; uint8_t Enable4; + uint8_t EncIndexLatchEnable; /* Parameters */ diff --git a/Cards/EaserCAT-3000-Digital-Stepper-Analog-Encoder-Frequency/Firmware/src/main.cpp b/Cards/EaserCAT-3000-Digital-Stepper-Analog-Encoder-Frequency/Firmware/src/main.cpp index c3ebe8c..33f42aa 100755 --- a/Cards/EaserCAT-3000-Digital-Stepper-Analog-Encoder-Frequency/Firmware/src/main.cpp +++ b/Cards/EaserCAT-3000-Digital-Stepper-Analog-Encoder-Frequency/Firmware/src/main.cpp @@ -83,8 +83,8 @@ void cb_set_outputs(void) // Get Master outputs, slave inputs, first operation for (int i = 0; i < 4; i++) digitalWrite(OUTPUTS[i], bitcheck(Obj.Output4, i) ? HIGH : LOW); // analogWrite(DAC1_pin, Obj.Voltage); - // Encoder1.setLatch(Obj.IndexLatchEnable); - // Encoder1.setScale(2000); + Encoder1.setLatch(Obj.EncIndexLatchEnable); + Encoder1.setScale(Obj.EncScale); posScale1 = Obj.StepsPerMM1; // Scale perhaps changed posScale2 = Obj.StepsPerMM2; @@ -108,25 +108,21 @@ void cb_set_outputs(void) // Get Master outputs, slave inputs, first operation void cb_get_inputs(void) // Set Master inputs, slave outputs, last operation { - Obj.Velocity = Obj.Scale * FrequencyMeasured; - float scale = 1; - if (Obj.Scale != 0.0) - scale = Obj.Scale; - Obj.Velocity = scale * sin(ESCvar.Time * 1e-8 * 6.28); // Test + float scale = 1; + if (Obj.EncScale != 0.0) + scale = Obj.EncScale; for (int i = 0; i < 8; i++) if (digitalRead(INPUTS[i]) == HIGH) bitSet(Obj.Input8, i); else bitClear(Obj.Input8, i); -#if 0 - Obj.IndexStatus = Encoder1.indexHappened(); - Obj.EncPos = Encoder1.currentPos(); - Obj.EncFrequency = Encoder1.frequency(longTime.extendTime(micros())); - Obj.IndexByte = Encoder1.getIndexState(); - Obj.Velocity = Obj.Scale * FrequencyMeasured; -#endif + Obj.IndexStatus = Encoder1.indexHappened(); + Obj.EncPosition = Encoder1.currentPos(); + Obj.IndexByte = Encoder1.getIndexState(); + Obj.EncVelocity = Obj.EncScale * FrequencyMeasured; + Obj.ActualPosition1 = Step->stepgen_array[0].pos_fb; Obj.ActualPosition2 = Step->stepgen_array[1].pos_fb; Obj.ActualPosition3 = Step->stepgen_array[2].pos_fb;