diff --git a/EEPROM_generator/index.html b/EEPROM_generator/index.html index 4fa7f27..4609771 100644 --- a/EEPROM_generator/index.html +++ b/EEPROM_generator/index.html @@ -55,7 +55,8 @@ - + + diff --git a/EEPROM_generator/src/constants.js b/EEPROM_generator/src/constants.js index a7f3793..f4a7a0d 100644 --- a/EEPROM_generator/src/constants.js +++ b/EEPROM_generator/src/constants.js @@ -28,11 +28,11 @@ const DTYPE = { INTEGER8 : 'INTEGER8', INTEGER16 : 'INTEGER16', INTEGER32 : 'INTEGER32', - INTEGER32 : 'INTEGER64', + INTEGER64 : 'INTEGER64', UNSIGNED8 : 'UNSIGNED8', UNSIGNED16 : 'UNSIGNED16', UNSIGNED32 : 'UNSIGNED32', - UNSIGNED32 : 'UNSIGNED64', + UNSIGNED64 : 'UNSIGNED64', REAL32 : 'REAL32', REAL64 : 'REAL64', VISIBLE_STRING : 'VISIBLE_STRING', diff --git a/Firmware/lib/soes/MetalMusings_EaserCAT_2000.xml b/Firmware/lib/soes/MetalMusings_EaserCAT_2000.xml index 917deff..9174c51 100755 --- a/Firmware/lib/soes/MetalMusings_EaserCAT_2000.xml +++ b/Firmware/lib/soes/MetalMusings_EaserCAT_2000.xml @@ -23,7 +23,7 @@ DT1018 - 272 + 144 0 Max SubIndex @@ -37,8 +37,8 @@ 1 Vendor ID - ULINT - 64 + UDINT + 32 16 ro @@ -47,9 +47,9 @@ 2 Product Code - ULINT - 64 - 80 + UDINT + 32 + 48 ro @@ -57,9 +57,9 @@ 3 Revision Number - ULINT - 64 - 144 + UDINT + 32 + 80 ro @@ -67,9 +67,9 @@ 4 Serial Number - ULINT - 64 - 208 + UDINT + 32 + 112 ro @@ -77,31 +77,7 @@ DT1600 - 80 - - 0 - Max SubIndex - USINT - 8 - 0 - - ro - - - - 1 - EncPosScale - ULINT - 64 - 16 - - ro - - - - - DT1601 - 80 + 48 0 Max SubIndex @@ -115,8 +91,32 @@ 1 IndexLatchEnable - ULINT - 64 + UDINT + 32 + 16 + + ro + + + + + DT1601 + 48 + + 0 + Max SubIndex + USINT + 8 + 0 + + ro + + + + 1 + CommandedPosition1 + UDINT + 32 16 ro @@ -125,7 +125,7 @@ DT1602 - 144 + 48 0 Max SubIndex @@ -138,28 +138,18 @@ 1 - CommandedPosition - ULINT - 64 + CommandedPosition2 + UDINT + 32 16 ro - - 2 - StepsPerMM - ULINT - 64 - 80 - - ro - - DT1603 - 144 + 48 0 Max SubIndex @@ -172,20 +162,34 @@ 1 - CommandedPosition - ULINT - 64 + StepsPerMM1 + UDINT + 32 16 ro + + + DT1604 + 48 - 2 - StepsPerMM - ULINT - 64 - 80 + 0 + Max SubIndex + USINT + 8 + 0 + + ro + + + + 1 + StepsPerMM2 + UDINT + 32 + 16 ro @@ -193,7 +197,7 @@ DT1A00 - 80 + 48 0 Max SubIndex @@ -207,8 +211,8 @@ 1 EncPos - ULINT - 64 + UDINT + 32 16 ro @@ -217,7 +221,7 @@ DT1A01 - 80 + 48 0 Max SubIndex @@ -231,8 +235,8 @@ 1 EncFrequency - ULINT - 64 + UDINT + 32 16 ro @@ -241,7 +245,7 @@ DT1A02 - 80 + 48 0 Max SubIndex @@ -255,8 +259,8 @@ 1 DiffT - ULINT - 64 + UDINT + 32 16 ro @@ -265,7 +269,7 @@ DT1A03 - 80 + 48 0 Max SubIndex @@ -279,8 +283,8 @@ 1 IndexByte - ULINT - 64 + UDINT + 32 16 ro @@ -289,7 +293,7 @@ DT1A04 - 80 + 48 0 Max SubIndex @@ -303,8 +307,8 @@ 1 IndexStatus - ULINT - 64 + UDINT + 32 16 ro @@ -313,7 +317,7 @@ DT1A05 - 80 + 48 0 Max SubIndex @@ -326,9 +330,9 @@ 1 - ActualPosition - ULINT - 64 + ActualPosition1 + UDINT + 32 16 ro @@ -337,7 +341,7 @@ DT1A06 - 80 + 48 0 Max SubIndex @@ -350,9 +354,9 @@ 1 - ActualPosition - ULINT - 64 + ActualPosition2 + UDINT + 32 16 ro @@ -361,7 +365,7 @@ DT1A07 - 80 + 48 0 Max SubIndex @@ -375,8 +379,8 @@ 1 D1 - ULINT - 64 + UDINT + 32 16 ro @@ -385,7 +389,7 @@ DT1A08 - 80 + 48 0 Max SubIndex @@ -399,8 +403,8 @@ 1 D2 - ULINT - 64 + UDINT + 32 16 ro @@ -409,7 +413,7 @@ DT1A09 - 80 + 48 0 Max SubIndex @@ -423,8 +427,8 @@ 1 D3 - ULINT - 64 + UDINT + 32 16 ro @@ -433,7 +437,7 @@ DT1A0A - 80 + 48 0 Max SubIndex @@ -447,8 +451,8 @@ 1 D4 - ULINT - 64 + UDINT + 32 16 ro @@ -490,15 +494,15 @@ DT1C12ARR UINT - 64 + 80 1 - 4 + 5 DT1C12 - 80 + 96 0 Max SubIndex @@ -512,7 +516,7 @@ Elements DT1C12ARR - 64 + 80 16 ro @@ -552,130 +556,8 @@ - DT6005 - 80 - - 0 - Max SubIndex - USINT - 8 - 0 - - ro - - - - 1 - ActualPosition - LREAL - 64 - 16 - - ro - T - - - - - DT6006 - 80 - - 0 - Max SubIndex - USINT - 8 - 0 - - ro - - - - 1 - ActualPosition - LREAL - 64 - 16 - - ro - T - - - - - DT7002 - 96 - - 0 - Max SubIndex - USINT - 8 - 0 - - ro - - - - 1 - CommandedPosition - LREAL - 64 - 16 - - ro - R - - - - 2 - StepsPerMM - INT - 16 - 80 - - ro - R - - - - - DT7003 - 96 - - 0 - Max SubIndex - USINT - 8 - 0 - - ro - - - - 1 - CommandedPosition - LREAL - 64 - 16 - - ro - R - - - - 2 - StepsPerMM - INT - 16 - 80 - - ro - R - - - - - ULINT - 64 + UDINT + 32 STRING(26) @@ -694,15 +576,7 @@ 16 - LREAL - 64 - - - UDINT - 32 - - - DINT + REAL 32 @@ -714,8 +588,8 @@ #x1000 Device Type - ULINT - 64 + UDINT + 32 5001 @@ -765,7 +639,7 @@ #x1018 Identity Object DT1018 - 272 + 144 Max SubIndex @@ -804,9 +678,9 @@ #x1600 - EncPosScale + IndexLatchEnable DT1600 - 80 + 48 Max SubIndex @@ -815,7 +689,7 @@ - EncPosScale + IndexLatchEnable #x70000020 @@ -827,9 +701,9 @@ #x1601 - IndexLatchEnable + CommandedPosition1 DT1601 - 80 + 48 Max SubIndex @@ -838,7 +712,7 @@ - IndexLatchEnable + CommandedPosition1 #x70010020 @@ -850,26 +724,20 @@ #x1602 - StepGenIn1 + CommandedPosition2 DT1602 - 144 + 48 Max SubIndex - 2 + 1 - CommandedPosition + CommandedPosition2 - #x70020140 - - - - StepsPerMM - - #x70020210 + #x70020020 @@ -879,26 +747,43 @@ #x1603 - StepGenIn2 + StepsPerMM1 DT1603 - 144 + 48 Max SubIndex - 2 + 1 - CommandedPosition + StepsPerMM1 - #x70030140 + #x70030010 + + + + + ro + + + + #x1604 + StepsPerMM2 + DT1604 + 48 + + + Max SubIndex + + 1 - StepsPerMM + StepsPerMM2 - #x70030210 + #x70040010 @@ -910,7 +795,7 @@ #x1A00 EncPos DT1A00 - 80 + 48 Max SubIndex @@ -921,7 +806,7 @@ EncPos - #x60000040 + #x60000020 @@ -933,7 +818,7 @@ #x1A01 EncFrequency DT1A01 - 80 + 48 Max SubIndex @@ -944,7 +829,7 @@ EncFrequency - #x60010040 + #x60010020 @@ -956,7 +841,7 @@ #x1A02 DiffT DT1A02 - 80 + 48 Max SubIndex @@ -967,7 +852,7 @@ DiffT - #x60020020 + #x60020010 @@ -979,7 +864,7 @@ #x1A03 IndexByte DT1A03 - 80 + 48 Max SubIndex @@ -1002,7 +887,7 @@ #x1A04 IndexStatus DT1A04 - 80 + 48 Max SubIndex @@ -1023,9 +908,9 @@ #x1A05 - StepGenOut1 + ActualPosition1 DT1A05 - 80 + 48 Max SubIndex @@ -1034,9 +919,9 @@ - ActualPosition + ActualPosition1 - #x60050140 + #x60050020 @@ -1046,9 +931,9 @@ #x1A06 - StepGenOut2 + ActualPosition2 DT1A06 - 80 + 48 Max SubIndex @@ -1057,9 +942,9 @@ - ActualPosition + ActualPosition2 - #x60060140 + #x60060020 @@ -1071,7 +956,7 @@ #x1A07 D1 DT1A07 - 80 + 48 Max SubIndex @@ -1082,7 +967,7 @@ D1 - #x60070020 + #x60070010 @@ -1094,7 +979,7 @@ #x1A08 D2 DT1A08 - 80 + 48 Max SubIndex @@ -1105,7 +990,7 @@ D2 - #x60080020 + #x60080010 @@ -1117,7 +1002,7 @@ #x1A09 D3 DT1A09 - 80 + 48 Max SubIndex @@ -1128,7 +1013,7 @@ D3 - #x60090020 + #x60090010 @@ -1140,7 +1025,7 @@ #x1A0A D4 DT1A0A - 80 + 48 Max SubIndex @@ -1151,7 +1036,7 @@ D4 - #x600A0020 + #x600A0010 @@ -1204,12 +1089,12 @@ #x1C12 Sync Manager 2 PDO Assignment DT1C12 - 80 + 96 Max SubIndex - 4 + 5 @@ -1236,6 +1121,12 @@ #x1603 + + PDO Mapping + + #x1604 + + ro @@ -1327,8 +1218,8 @@ #x6000 EncPos - LREAL - 64 + REAL + 32 0 @@ -1340,8 +1231,8 @@ #x6001 EncFrequency - LREAL - 64 + REAL + 32 0 @@ -1353,8 +1244,8 @@ #x6002 DiffT - UDINT - 32 + UINT + 16 0 @@ -1391,55 +1282,35 @@ #x6005 - StepGenOut1 - DT6005 - 80 + ActualPosition1 + REAL + 32 - - Max SubIndex - - 1 - - - - ActualPosition - - 0 - - + 0 ro + T #x6006 - StepGenOut2 - DT6006 - 80 + ActualPosition2 + REAL + 32 - - Max SubIndex - - 1 - - - - ActualPosition - - 0 - - + 0 ro + T #x6007 D1 - DINT - 32 + INT + 16 0 @@ -1451,8 +1322,8 @@ #x6008 D2 - DINT - 32 + INT + 16 0 @@ -1464,8 +1335,8 @@ #x6009 D3 - DINT - 32 + INT + 16 0 @@ -1477,8 +1348,8 @@ #x600A D4 - DINT - 32 + INT + 16 0 @@ -1489,19 +1360,6 @@ #x7000 - EncPosScale - DINT - 32 - - 0 - - - ro - R - - - - #x7001 IndexLatchEnable UDINT 32 @@ -1514,61 +1372,55 @@ - #x7002 - StepGenIn1 - DT7002 - 96 + #x7001 + CommandedPosition1 + REAL + 32 - - Max SubIndex - - 2 - - - - CommandedPosition - - 0 - - - - StepsPerMM - - 0 - - + 0 ro + R + + + + #x7002 + CommandedPosition2 + REAL + 32 + + 0 + + + ro + R #x7003 - StepGenIn2 - DT7003 - 96 + StepsPerMM1 + INT + 16 - - Max SubIndex - - 2 - - - - CommandedPosition - - 0 - - - - StepsPerMM - - 0 - - + 0 ro + R + + + + #x7004 + StepsPerMM2 + INT + 16 + + 0 + + + ro + R @@ -1583,20 +1435,9 @@ Inputs #x1600 - EncPosScale - - #x7000 - #x0 - 32 - EncPosScale - DINT - - - - #x1601 IndexLatchEnable - #x7001 + #x7000 #x0 32 IndexLatchEnable @@ -1604,38 +1445,46 @@ - #x1602 - StepGenIn1 + #x1601 + CommandedPosition1 - #x7002 - #x1 - 64 - CommandedPosition - LREAL + #x7001 + #x0 + 32 + CommandedPosition1 + REAL + + + #x1602 + CommandedPosition2 #x7002 - #x2 - 16 - StepsPerMM - INT + #x0 + 32 + CommandedPosition2 + REAL #x1603 - StepGenIn2 + StepsPerMM1 #x7003 - #x1 - 64 - CommandedPosition - LREAL - - - #x7003 - #x2 + #x0 16 - StepsPerMM + StepsPerMM1 + INT + + + + #x1604 + StepsPerMM2 + + #x7004 + #x0 + 16 + StepsPerMM2 INT @@ -1645,9 +1494,9 @@ #x6000 #x0 - 64 + 32 EncPos - LREAL + REAL @@ -1656,9 +1505,9 @@ #x6001 #x0 - 64 + 32 EncFrequency - LREAL + REAL @@ -1667,9 +1516,9 @@ #x6002 #x0 - 32 + 16 DiffT - UDINT + UINT @@ -1696,24 +1545,24 @@ #x1A05 - StepGenOut1 + ActualPosition1 #x6005 - #x1 - 64 - ActualPosition - LREAL + #x0 + 32 + ActualPosition1 + REAL #x1A06 - StepGenOut2 + ActualPosition2 #x6006 - #x1 - 64 - ActualPosition - LREAL + #x0 + 32 + ActualPosition2 + REAL @@ -1722,9 +1571,9 @@ #x6007 #x0 - 32 + 16 D1 - DINT + INT @@ -1733,9 +1582,9 @@ #x6008 #x0 - 32 + 16 D2 - DINT + INT @@ -1744,9 +1593,9 @@ #x6009 #x0 - 32 + 16 D3 - DINT + INT @@ -1755,9 +1604,9 @@ #x600A #x0 - 32 + 16 D4 - DINT + INT @@ -1777,7 +1626,7 @@ 2048 - 8006034C640000 + 80060344640000 diff --git a/Firmware/lib/soes/ecat_options.h b/Firmware/lib/soes/ecat_options.h index bdea3f1..c3c73f0 100755 --- a/Firmware/lib/soes/ecat_options.h +++ b/Firmware/lib/soes/ecat_options.h @@ -33,7 +33,7 @@ #define SM3_smc 0x20 #define SM3_act 1 -#define MAX_MAPPINGS_SM2 6 +#define MAX_MAPPINGS_SM2 5 #define MAX_MAPPINGS_SM3 11 #define MAX_RXPDO_SIZE 512 diff --git a/Firmware/lib/soes/ecat_slv.c b/Firmware/lib/soes/ecat_slv.c index e9c57d8..147a11a 100755 --- a/Firmware/lib/soes/ecat_slv.c +++ b/Firmware/lib/soes/ecat_slv.c @@ -191,7 +191,7 @@ void APP_setwatchdog (int watchdogcnt) * write ethercat inputs. Implement watch-dog counter to count-out if we have * made state change affecting the App.state. */ -void DIG_process (uint16_t ALEvent, uint8_t flags) +void DIG_process (uint8_t flags) { /* Handle watchdog */ if((flags & DIG_PROCESS_WD_FLAG) > 0) @@ -217,14 +217,14 @@ void DIG_process (uint16_t ALEvent, uint8_t flags) if ((flags & DIG_PROCESS_OUTPUTS_FLAG) > 0) { if(((CC_ATOMIC_GET(ESCvar.App.state) & APPSTATE_OUTPUT) > 0) && - (ALEvent & ESCREG_ALEVENT_SM2)) + (ESCvar.ALevent & ESCREG_ALEVENT_SM2)) { RXPDO_update(); CC_ATOMIC_SET(watchdog, ESCvar.watchdogcnt); /* Set outputs */ cb_set_outputs(); } - else if (ALEvent & ESCREG_ALEVENT_SM2) + else if (ESCvar.ALevent & ESCREG_ALEVENT_SM2) { RXPDO_update(); } @@ -339,7 +339,7 @@ void ecat_slv_poll (void) void ecat_slv (void) { ecat_slv_poll(); - DIG_process(ESCvar.ALevent, DIG_PROCESS_WD_FLAG | DIG_PROCESS_OUTPUTS_FLAG | + DIG_process(DIG_PROCESS_WD_FLAG | DIG_PROCESS_OUTPUTS_FLAG | DIG_PROCESS_APP_HOOK_FLAG | DIG_PROCESS_INPUTS_FLAG); } diff --git a/Firmware/lib/soes/ecat_slv.h b/Firmware/lib/soes/ecat_slv.h index b5d0d9d..c6053c0 100755 --- a/Firmware/lib/soes/ecat_slv.h +++ b/Firmware/lib/soes/ecat_slv.h @@ -36,7 +36,7 @@ void APP_setwatchdog (int watchdogcnt); * * @param[in] flags = User input what to execute */ -void DIG_process (uint16_t ALEvent, uint8_t flags); +void DIG_process (uint8_t flags); /** * Handler for SM change, SM0/1, AL CONTROL and EEPROM events, the application diff --git a/Firmware/lib/soes/eeprom.bin b/Firmware/lib/soes/eeprom.bin index 1156cd1..47287ef 100755 Binary files a/Firmware/lib/soes/eeprom.bin and b/Firmware/lib/soes/eeprom.bin differ diff --git a/Firmware/lib/soes/eeprom.hex b/Firmware/lib/soes/eeprom.hex index fd705c7..4291203 100755 --- a/Firmware/lib/soes/eeprom.hex +++ b/Firmware/lib/soes/eeprom.hex @@ -1,4 +1,4 @@ -:200000008006034C64000000000000000000EC00AA0A0000CCBCBB000200000001000000C1 +:2000000080060344640000000000000000001400AA0A0000CCBCBB000200000001000000A1 :20002000000000000000000000000000000000000010000200120002040000000000000096 :200040000000000000000000000000000000000000000000000000000000000000000000A0 :20006000000000000000000000000000000000000000000000000000000000000F00010070 diff --git a/Firmware/lib/soes/esi.json b/Firmware/lib/soes/esi.json index c330457..67ec7c5 100755 --- a/Firmware/lib/soes/esi.json +++ b/Firmware/lib/soes/esi.json @@ -57,7 +57,7 @@ "pdo_mappings": [ "txpdo" ], - "dtype": "REAL64", + "dtype": "REAL32", "value": "0", "data": "&Obj.EncPos" }, @@ -68,7 +68,7 @@ "pdo_mappings": [ "txpdo" ], - "dtype": "REAL64", + "dtype": "REAL32", "value": "0", "data": "&Obj.EncFrequency" }, @@ -79,7 +79,7 @@ "pdo_mappings": [ "txpdo" ], - "dtype": "UNSIGNED32", + "dtype": "UNSIGNED16", "value": "0", "data": "&Obj.DiffT" }, @@ -106,44 +106,26 @@ "data": "&Obj.IndexStatus" }, "6005": { - "otype": "RECORD", - "name": "StepGenOut1", + "otype": "VAR", + "name": "ActualPosition1", "access": "RO", - "items": [ - { - "name": "Max SubIndex" - }, - { - "name": "ActualPosition", - "dtype": "REAL64", - "data": "&Obj.StepGenOut1.ActualPosition", - "value": "0", - "access": "RO" - } - ], "pdo_mappings": [ "txpdo" - ] + ], + "dtype": "REAL32", + "value": "0", + "data": "&Obj.ActualPosition1" }, "6006": { - "otype": "RECORD", - "name": "StepGenOut2", + "otype": "VAR", + "name": "ActualPosition2", "access": "RO", - "items": [ - { - "name": "Max SubIndex" - }, - { - "name": "ActualPosition", - "dtype": "REAL64", - "data": "&Obj.StepGenOut2.ActualPosition", - "value": "0", - "access": "RO" - } - ], "pdo_mappings": [ "txpdo" - ] + ], + "dtype": "REAL32", + "value": "0", + "data": "&Obj.ActualPosition2" }, "6007": { "otype": "VAR", @@ -152,7 +134,7 @@ "pdo_mappings": [ "txpdo" ], - "dtype": "INTEGER32", + "dtype": "INTEGER16", "value": "0", "data": "&Obj.D1" }, @@ -163,7 +145,7 @@ "pdo_mappings": [ "txpdo" ], - "dtype": "INTEGER32", + "dtype": "INTEGER16", "value": "0", "data": "&Obj.D2" }, @@ -174,7 +156,7 @@ "pdo_mappings": [ "txpdo" ], - "dtype": "INTEGER32", + "dtype": "INTEGER16", "value": "0", "data": "&Obj.D3" }, @@ -185,24 +167,13 @@ "pdo_mappings": [ "txpdo" ], - "dtype": "INTEGER32", + "dtype": "INTEGER16", "value": "0", "data": "&Obj.D4" } }, "rxpdo": { "7000": { - "otype": "VAR", - "name": "EncPosScale", - "access": "RO", - "pdo_mappings": [ - "rxpdo" - ], - "dtype": "INTEGER32", - "value": "0", - "data": "&Obj.EncPosScale" - }, - "7001": { "otype": "VAR", "name": "IndexLatchEnable", "access": "RO", @@ -213,59 +184,49 @@ "value": "0", "data": "&Obj.IndexLatchEnable" }, - "7002": { - "otype": "RECORD", - "name": "StepGenIn1", + "7001": { + "otype": "VAR", + "name": "CommandedPosition1", "access": "RO", - "items": [ - { - "name": "Max SubIndex" - }, - { - "name": "CommandedPosition", - "dtype": "REAL64", - "data": "&Obj.StepGenIn1.CommandedPosition", - "value": "0", - "access": "RO" - }, - { - "name": "StepsPerMM", - "dtype": "INTEGER16", - "value": "0", - "access": "RO", - "data": "&Obj.StepGenIn1.StepsPerMM" - } - ], "pdo_mappings": [ "rxpdo" - ] + ], + "dtype": "REAL32", + "value": "0", + "data": "&Obj.CommandedPosition1" + }, + "7002": { + "otype": "VAR", + "name": "CommandedPosition2", + "access": "RO", + "pdo_mappings": [ + "rxpdo" + ], + "dtype": "REAL32", + "value": "0", + "data": "&Obj.CommandedPosition2" }, "7003": { - "otype": "RECORD", - "name": "StepGenIn2", + "otype": "VAR", + "name": "StepsPerMM1", "access": "RO", - "items": [ - { - "name": "Max SubIndex" - }, - { - "name": "CommandedPosition", - "dtype": "REAL64", - "data": "&Obj.StepGenIn2.CommandedPosition", - "value": "0", - "access": "RO" - }, - { - "name": "StepsPerMM", - "dtype": "INTEGER16", - "value": "0", - "access": "RO", - "data": "&Obj.StepGenIn2.StepsPerMM" - } - ], "pdo_mappings": [ "rxpdo" - ] + ], + "dtype": "INTEGER16", + "value": "0", + "data": "&Obj.StepsPerMM1" + }, + "7004": { + "otype": "VAR", + "name": "StepsPerMM2", + "access": "RO", + "pdo_mappings": [ + "rxpdo" + ], + "dtype": "INTEGER16", + "value": "0", + "data": "&Obj.StepsPerMM2" }, "60664": { "otype": "VAR", diff --git a/Firmware/lib/soes/objectlist.c b/Firmware/lib/soes/objectlist.c index 6603d45..05b5f05 100755 --- a/Firmware/lib/soes/objectlist.c +++ b/Firmware/lib/soes/objectlist.c @@ -13,20 +13,21 @@ 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[] = "EncPosScale"; +static const char acName1600[] = "IndexLatchEnable"; static const char acName1600_00[] = "Max SubIndex"; -static const char acName1600_01[] = "EncPosScale"; -static const char acName1601[] = "IndexLatchEnable"; +static const char acName1600_01[] = "IndexLatchEnable"; +static const char acName1601[] = "CommandedPosition1"; static const char acName1601_00[] = "Max SubIndex"; -static const char acName1601_01[] = "IndexLatchEnable"; -static const char acName1602[] = "StepGenIn1"; +static const char acName1601_01[] = "CommandedPosition1"; +static const char acName1602[] = "CommandedPosition2"; static const char acName1602_00[] = "Max SubIndex"; -static const char acName1602_01[] = "CommandedPosition"; -static const char acName1602_02[] = "StepsPerMM"; -static const char acName1603[] = "StepGenIn2"; +static const char acName1602_01[] = "CommandedPosition2"; +static const char acName1603[] = "StepsPerMM1"; static const char acName1603_00[] = "Max SubIndex"; -static const char acName1603_01[] = "CommandedPosition"; -static const char acName1603_02[] = "StepsPerMM"; +static const char acName1603_01[] = "StepsPerMM1"; +static const char acName1604[] = "StepsPerMM2"; +static const char acName1604_00[] = "Max SubIndex"; +static const char acName1604_01[] = "StepsPerMM2"; static const char acName1A00[] = "EncPos"; static const char acName1A00_00[] = "Max SubIndex"; static const char acName1A00_01[] = "EncPos"; @@ -42,12 +43,12 @@ static const char acName1A03_01[] = "IndexByte"; static const char acName1A04[] = "IndexStatus"; static const char acName1A04_00[] = "Max SubIndex"; static const char acName1A04_01[] = "IndexStatus"; -static const char acName1A05[] = "StepGenOut1"; +static const char acName1A05[] = "ActualPosition1"; static const char acName1A05_00[] = "Max SubIndex"; -static const char acName1A05_01[] = "ActualPosition"; -static const char acName1A06[] = "StepGenOut2"; +static const char acName1A05_01[] = "ActualPosition1"; +static const char acName1A06[] = "ActualPosition2"; static const char acName1A06_00[] = "Max SubIndex"; -static const char acName1A06_01[] = "ActualPosition"; +static const char acName1A06_01[] = "ActualPosition2"; static const char acName1A07[] = "D1"; static const char acName1A07_00[] = "Max SubIndex"; static const char acName1A07_01[] = "D1"; @@ -72,6 +73,7 @@ static const char acName1C12_01[] = "PDO Mapping"; static const char acName1C12_02[] = "PDO Mapping"; static const char acName1C12_03[] = "PDO Mapping"; static const char acName1C12_04[] = "PDO Mapping"; +static const char acName1C12_05[] = "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"; @@ -90,30 +92,21 @@ static const char acName6001[] = "EncFrequency"; static const char acName6002[] = "DiffT"; static const char acName6003[] = "IndexByte"; static const char acName6004[] = "IndexStatus"; -static const char acName6005[] = "StepGenOut1"; -static const char acName6005_00[] = "Max SubIndex"; -static const char acName6005_01[] = "ActualPosition"; -static const char acName6006[] = "StepGenOut2"; -static const char acName6006_00[] = "Max SubIndex"; -static const char acName6006_01[] = "ActualPosition"; +static const char acName6005[] = "ActualPosition1"; +static const char acName6006[] = "ActualPosition2"; static const char acName6007[] = "D1"; static const char acName6008[] = "D2"; static const char acName6009[] = "D3"; static const char acName600A[] = "D4"; -static const char acName7000[] = "EncPosScale"; -static const char acName7001[] = "IndexLatchEnable"; -static const char acName7002[] = "StepGenIn1"; -static const char acName7002_00[] = "Max SubIndex"; -static const char acName7002_01[] = "CommandedPosition"; -static const char acName7002_02[] = "StepsPerMM"; -static const char acName7003[] = "StepGenIn2"; -static const char acName7003_00[] = "Max SubIndex"; -static const char acName7003_01[] = "CommandedPosition"; -static const char acName7003_02[] = "StepsPerMM"; +static const char acName7000[] = "IndexLatchEnable"; +static const char acName7001[] = "CommandedPosition1"; +static const char acName7002[] = "CommandedPosition2"; +static const char acName7003[] = "StepsPerMM1"; +static const char acName7004[] = "StepsPerMM2"; const _objd SDO1000[] = { - {0x0, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1000, 5001, NULL}, + {0x0, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1000, 5001, NULL}, }; const _objd SDO1008[] = { @@ -130,87 +123,90 @@ const _objd SDO100A[] = const _objd SDO1018[] = { {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1018_00, 4, NULL}, - {0x01, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1018_01, 2730, NULL}, - {0x02, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1018_02, 12303564, NULL}, - {0x03, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1018_03, 2, NULL}, - {0x04, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1018_04, 1, &Obj.serial}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1018_01, 2730, NULL}, + {0x02, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1018_02, 12303564, NULL}, + {0x03, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1018_03, 2, NULL}, + {0x04, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1018_04, 1, &Obj.serial}, }; const _objd SDO1600[] = { {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1600_00, 1, NULL}, - {0x01, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1600_01, 0x70000020, NULL}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1600_01, 0x70000020, NULL}, }; const _objd SDO1601[] = { {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1601_00, 1, NULL}, - {0x01, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1601_01, 0x70010020, NULL}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1601_01, 0x70010020, NULL}, }; const _objd SDO1602[] = { - {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1602_00, 2, NULL}, - {0x01, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1602_01, 0x70020140, NULL}, - {0x02, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1602_02, 0x70020210, NULL}, + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1602_00, 1, NULL}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1602_01, 0x70020020, NULL}, }; const _objd SDO1603[] = { - {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1603_00, 2, NULL}, - {0x01, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1603_01, 0x70030140, NULL}, - {0x02, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1603_02, 0x70030210, NULL}, + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1603_00, 1, NULL}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1603_01, 0x70030010, NULL}, +}; +const _objd SDO1604[] = +{ + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1604_00, 1, NULL}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1604_01, 0x70040010, NULL}, }; const _objd SDO1A00[] = { {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A00_00, 1, NULL}, - {0x01, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1A00_01, 0x60000040, NULL}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A00_01, 0x60000020, NULL}, }; const _objd SDO1A01[] = { {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A01_00, 1, NULL}, - {0x01, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1A01_01, 0x60010040, NULL}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A01_01, 0x60010020, NULL}, }; const _objd SDO1A02[] = { {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A02_00, 1, NULL}, - {0x01, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1A02_01, 0x60020020, NULL}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A02_01, 0x60020010, NULL}, }; const _objd SDO1A03[] = { {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A03_00, 1, NULL}, - {0x01, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1A03_01, 0x60030020, NULL}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A03_01, 0x60030020, NULL}, }; const _objd SDO1A04[] = { {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A04_00, 1, NULL}, - {0x01, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1A04_01, 0x60040020, NULL}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A04_01, 0x60040020, NULL}, }; const _objd SDO1A05[] = { {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A05_00, 1, NULL}, - {0x01, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1A05_01, 0x60050140, NULL}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A05_01, 0x60050020, NULL}, }; const _objd SDO1A06[] = { {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A06_00, 1, NULL}, - {0x01, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1A06_01, 0x60060140, 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_UNSIGNED64, 64, ATYPE_RO, acName1A07_01, 0x60070020, NULL}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A07_01, 0x60070010, NULL}, }; const _objd SDO1A08[] = { {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A08_00, 1, NULL}, - {0x01, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1A08_01, 0x60080020, NULL}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A08_01, 0x60080010, NULL}, }; const _objd SDO1A09[] = { {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A09_00, 1, NULL}, - {0x01, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1A09_01, 0x60090020, NULL}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A09_01, 0x60090010, NULL}, }; const _objd SDO1A0A[] = { {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A0A_00, 1, NULL}, - {0x01, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1A0A_01, 0x600A0020, NULL}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A0A_01, 0x600A0010, NULL}, }; const _objd SDO1C00[] = { @@ -222,11 +218,12 @@ const _objd SDO1C00[] = }; const _objd SDO1C12[] = { - {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C12_00, 4, NULL}, + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C12_00, 5, 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}, {0x04, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C12_04, 0x1603, NULL}, + {0x05, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C12_05, 0x1604, NULL}, }; const _objd SDO1C13[] = { @@ -245,15 +242,15 @@ const _objd SDO1C13[] = }; const _objd SDO6000[] = { - {0x0, DTYPE_REAL64, 64, ATYPE_RO | ATYPE_TXPDO, acName6000, 0, &Obj.EncPos}, + {0x0, DTYPE_REAL32, 32, ATYPE_RO | ATYPE_TXPDO, acName6000, 0x00000000, &Obj.EncPos}, }; const _objd SDO6001[] = { - {0x0, DTYPE_REAL64, 64, ATYPE_RO | ATYPE_TXPDO, acName6001, 0, &Obj.EncFrequency}, + {0x0, DTYPE_REAL32, 32, ATYPE_RO | ATYPE_TXPDO, acName6001, 0x00000000, &Obj.EncFrequency}, }; const _objd SDO6002[] = { - {0x0, DTYPE_UNSIGNED32, 32, ATYPE_RO | ATYPE_TXPDO, acName6002, 0, &Obj.DiffT}, + {0x0, DTYPE_UNSIGNED16, 16, ATYPE_RO | ATYPE_TXPDO, acName6002, 0, &Obj.DiffT}, }; const _objd SDO6003[] = { @@ -265,49 +262,47 @@ const _objd SDO6004[] = }; const _objd SDO6005[] = { - {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName6005_00, 1, NULL}, - {0x01, DTYPE_REAL64, 64, ATYPE_RO, acName6005_01, 0, &Obj.StepGenOut1.ActualPosition}, + {0x0, DTYPE_REAL32, 32, ATYPE_RO | ATYPE_TXPDO, acName6005, 0x00000000, &Obj.ActualPosition1}, }; const _objd SDO6006[] = { - {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName6006_00, 1, NULL}, - {0x01, DTYPE_REAL64, 64, ATYPE_RO, acName6006_01, 0, &Obj.StepGenOut2.ActualPosition}, + {0x0, DTYPE_REAL32, 32, ATYPE_RO | ATYPE_TXPDO, acName6006, 0x00000000, &Obj.ActualPosition2}, }; const _objd SDO6007[] = { - {0x0, DTYPE_INTEGER32, 32, ATYPE_RO | ATYPE_TXPDO, acName6007, 0, &Obj.D1}, + {0x0, DTYPE_INTEGER16, 16, ATYPE_RO | ATYPE_TXPDO, acName6007, 0, &Obj.D1}, }; const _objd SDO6008[] = { - {0x0, DTYPE_INTEGER32, 32, ATYPE_RO | ATYPE_TXPDO, acName6008, 0, &Obj.D2}, + {0x0, DTYPE_INTEGER16, 16, ATYPE_RO | ATYPE_TXPDO, acName6008, 0, &Obj.D2}, }; const _objd SDO6009[] = { - {0x0, DTYPE_INTEGER32, 32, ATYPE_RO | ATYPE_TXPDO, acName6009, 0, &Obj.D3}, + {0x0, DTYPE_INTEGER16, 16, ATYPE_RO | ATYPE_TXPDO, acName6009, 0, &Obj.D3}, }; const _objd SDO600A[] = { - {0x0, DTYPE_INTEGER32, 32, ATYPE_RO | ATYPE_TXPDO, acName600A, 0, &Obj.D4}, + {0x0, DTYPE_INTEGER16, 16, ATYPE_RO | ATYPE_TXPDO, acName600A, 0, &Obj.D4}, }; const _objd SDO7000[] = { - {0x0, DTYPE_INTEGER32, 32, ATYPE_RO | ATYPE_RXPDO, acName7000, 0, &Obj.EncPosScale}, + {0x0, DTYPE_UNSIGNED32, 32, ATYPE_RO | ATYPE_RXPDO, acName7000, 0, &Obj.IndexLatchEnable}, }; const _objd SDO7001[] = { - {0x0, DTYPE_UNSIGNED32, 32, ATYPE_RO | ATYPE_RXPDO, acName7001, 0, &Obj.IndexLatchEnable}, + {0x0, DTYPE_REAL32, 32, ATYPE_RO | ATYPE_RXPDO, acName7001, 0x00000000, &Obj.CommandedPosition1}, }; const _objd SDO7002[] = { - {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7002_00, 2, NULL}, - {0x01, DTYPE_REAL64, 64, ATYPE_RO, acName7002_01, 0, &Obj.StepGenIn1.CommandedPosition}, - {0x02, DTYPE_INTEGER16, 16, ATYPE_RO, acName7002_02, 0, &Obj.StepGenIn1.StepsPerMM}, + {0x0, DTYPE_REAL32, 32, ATYPE_RO | ATYPE_RXPDO, acName7002, 0x00000000, &Obj.CommandedPosition2}, }; const _objd SDO7003[] = { - {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7003_00, 2, NULL}, - {0x01, DTYPE_REAL64, 64, ATYPE_RO, acName7003_01, 0, &Obj.StepGenIn2.CommandedPosition}, - {0x02, DTYPE_INTEGER16, 16, ATYPE_RO, acName7003_02, 0, &Obj.StepGenIn2.StepsPerMM}, + {0x0, DTYPE_INTEGER16, 16, ATYPE_RO | ATYPE_RXPDO, acName7003, 0, &Obj.StepsPerMM1}, +}; +const _objd SDO7004[] = +{ + {0x0, DTYPE_INTEGER16, 16, ATYPE_RO | ATYPE_RXPDO, acName7004, 0, &Obj.StepsPerMM2}, }; const _objectlist SDOobjects[] = @@ -319,8 +314,9 @@ const _objectlist SDOobjects[] = {0x1018, OTYPE_RECORD, 4, 0, acName1018, SDO1018}, {0x1600, OTYPE_RECORD, 1, 0, acName1600, SDO1600}, {0x1601, OTYPE_RECORD, 1, 0, acName1601, SDO1601}, - {0x1602, OTYPE_RECORD, 2, 0, acName1602, SDO1602}, - {0x1603, OTYPE_RECORD, 2, 0, acName1603, SDO1603}, + {0x1602, OTYPE_RECORD, 1, 0, acName1602, SDO1602}, + {0x1603, OTYPE_RECORD, 1, 0, acName1603, SDO1603}, + {0x1604, OTYPE_RECORD, 1, 0, acName1604, SDO1604}, {0x1A00, OTYPE_RECORD, 1, 0, acName1A00, SDO1A00}, {0x1A01, OTYPE_RECORD, 1, 0, acName1A01, SDO1A01}, {0x1A02, OTYPE_RECORD, 1, 0, acName1A02, SDO1A02}, @@ -333,22 +329,23 @@ const _objectlist SDOobjects[] = {0x1A09, OTYPE_RECORD, 1, 0, acName1A09, SDO1A09}, {0x1A0A, OTYPE_RECORD, 1, 0, acName1A0A, SDO1A0A}, {0x1C00, OTYPE_ARRAY, 4, 0, acName1C00, SDO1C00}, - {0x1C12, OTYPE_ARRAY, 4, 0, acName1C12, SDO1C12}, + {0x1C12, OTYPE_ARRAY, 5, 0, acName1C12, SDO1C12}, {0x1C13, OTYPE_ARRAY, 11, 0, acName1C13, SDO1C13}, {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}, {0x6004, OTYPE_VAR, 0, 0, acName6004, SDO6004}, - {0x6005, OTYPE_RECORD, 1, 0, acName6005, SDO6005}, - {0x6006, OTYPE_RECORD, 1, 0, acName6006, SDO6006}, + {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}, {0x6009, OTYPE_VAR, 0, 0, acName6009, SDO6009}, {0x600A, OTYPE_VAR, 0, 0, acName600A, SDO600A}, {0x7000, OTYPE_VAR, 0, 0, acName7000, SDO7000}, {0x7001, OTYPE_VAR, 0, 0, acName7001, SDO7001}, - {0x7002, OTYPE_RECORD, 2, 0, acName7002, SDO7002}, - {0x7003, OTYPE_RECORD, 2, 0, acName7003, SDO7003}, + {0x7002, OTYPE_VAR, 0, 0, acName7002, SDO7002}, + {0x7003, OTYPE_VAR, 0, 0, acName7003, SDO7003}, + {0x7004, OTYPE_VAR, 0, 0, acName7004, SDO7004}, {0xffff, 0xff, 0xff, 0xff, NULL, NULL} }; diff --git a/Firmware/lib/soes/utypes.h b/Firmware/lib/soes/utypes.h index 97fcd62..2da84f5 100755 --- a/Firmware/lib/soes/utypes.h +++ b/Firmware/lib/soes/utypes.h @@ -13,38 +13,25 @@ typedef struct /* Inputs */ - double EncPos; - double EncFrequency; - uint32_t DiffT; + float EncPos; + float EncFrequency; + uint16_t DiffT; uint32_t IndexByte; uint32_t IndexStatus; - struct - { - double ActualPosition; - } StepGenOut1; - struct - { - double ActualPosition; - } StepGenOut2; - int32_t D1; - int32_t D2; - int32_t D3; - int32_t D4; + float ActualPosition1; + float ActualPosition2; + int16_t D1; + int16_t D2; + int16_t D3; + int16_t D4; /* Outputs */ - int32_t EncPosScale; uint32_t IndexLatchEnable; - struct - { - double CommandedPosition; - int16_t StepsPerMM; - } StepGenIn1; - struct - { - double CommandedPosition; - int16_t StepsPerMM; - } StepGenIn2; + float CommandedPosition1; + float CommandedPosition2; + int16_t StepsPerMM1; + int16_t StepsPerMM2; } _Objects; diff --git a/Firmware/src/StepGen2.cpp b/Firmware/src/StepGen2.cpp index e16dd75..30d4fa2 100755 --- a/Firmware/src/StepGen2.cpp +++ b/Firmware/src/StepGen2.cpp @@ -39,7 +39,7 @@ uint32_t StepGen2::handleStepper(uint64_t irqTime) nSteps = commandedStepPosition - initialStepPosition; - if (abs(nSteps) < 1000) // Some small number + if (abs(nSteps) < 2) // Some small number { frequency = (abs(nSteps) + 1) / lcncCycleTime; Tpulses = abs(nSteps) / frequency; @@ -73,7 +73,7 @@ void StepGen2::startTimerCB() digitalWrite(dirPin, nSteps > 0 ? HIGH : LOW); // There will be a short break here for t2 usecs, in the future. timerPulseSteps = abs(nSteps); - pulseTimer->setMode(pulseTimerChan, TIMER_OUTPUT_COMPARE_PWM2, stepPin); + pulseTimer->setMode(pulseTimerChan, TIMER_OUTPUT_COMPARE_PWM1, stepPin); pulseTimer->setOverflow(timerFrequency, HERTZ_FORMAT); pulseTimer->setCaptureCompare(pulseTimerChan, 5, MICROSEC_COMPARE_FORMAT); // 5 usecs pulseTimer->resume(); diff --git a/Firmware/src/main.cpp b/Firmware/src/main.cpp index 13c6829..06b167b 100755 --- a/Firmware/src/main.cpp +++ b/Firmware/src/main.cpp @@ -25,27 +25,31 @@ StepGen2 Step(TIM1, 4, PA_11, PA12, pulseTimerCallback, TIM10, startTimerCallbac void pulseTimerCallback(void) { Step.pulseTimerCB(); } void startTimerCallback(void) { Step.startTimerCB(); } CircularBuffer Tim; -volatile uint64_t irqTime = 0, thenTime = 0; +volatile uint64_t irqTime = 0, thenTime = 0, nowTime = 0; volatile uint32_t ccnnt = 0; extend32to64 longTime; void cb_set_outputs(void) // Master outputs gets here, slave inputs, first operation { Encoder1.setLatch(Obj.IndexLatchEnable); - Encoder1.setScale(Obj.EncPosScale); + Encoder1.setScale(500); + + // Step2.reqPos(Obj.CommandedPosition2); + // Step2.setScale(Obj.StepsPerMM2); + // Step2.enable(1); + Obj.ActualPosition1 = Obj.CommandedPosition1; // Step1.actPos(); + Obj.ActualPosition2 = Obj.CommandedPosition2; // Step2.actPos(); } volatile uint32_t cmt; void handleStepper(void) { - digitalWrite(Step.dirPin, cmt++ % 2); + //digitalWrite(Step.dirPin, cmt++ % 2); Step.enabled = true; - Step.commandedPosition = Obj.StepGenIn1.CommandedPosition; - Obj.StepGenOut1.ActualPosition = Step.commandedPosition; - Step.stepsPerMM = Obj.StepGenIn1.StepsPerMM; - Step.stepsPerMM = 400; + Step.commandedPosition = Obj.CommandedPosition1; + Step.stepsPerMM = Obj.StepsPerMM1; Step.handleStepper(irqTime); - Obj.StepGenOut2.ActualPosition = Obj.StepGenIn2.CommandedPosition; + Obj.ActualPosition1 = Obj.CommandedPosition1; } void cb_get_inputs(void) // Set Master inputs, slave outputs, last operation @@ -55,7 +59,7 @@ void cb_get_inputs(void) // Set Master inputs, slave outputs, last operation Obj.EncFrequency = Encoder1.frequency(ESCvar.Time); Obj.IndexByte = Encoder1.getIndexState(); - uint32_t dTim = longTime.extendTime(micros()) - irqTime; // thenTime; // Debug. Getting jitter over the last 200 milliseconds + uint32_t dTim = nowTime - thenTime; // Debug. Getting jitter over the last 200 milliseconds Tim.push(dTim); uint32_t max_Tim = 0, min_Tim = UINT32_MAX; for (decltype(Tim)::index_t i = 0; i < Tim.size(); i++) @@ -72,7 +76,7 @@ void cb_get_inputs(void) // Set Master inputs, slave outputs, last operation Obj.D1 = Step.Tjitter; Obj.D2 = Step.Tstartf * 1e6; Obj.D3 = Step.dbg; - Obj.D4 = Obj.D1+Obj.D2-Obj.D3; + Obj.D4 = Obj.D1 + Obj.D2 - Obj.D3; } void ESC_interrupt_enable(uint32_t mask); @@ -114,9 +118,12 @@ void loop(void) uint32_t dTime; if (serveIRQ) { - CC_ATOMIC_SET(ESCvar.ALevent, ESC_ALeventread()); - DIG_process(ALEventIRQ, DIG_PROCESS_WD_FLAG | DIG_PROCESS_OUTPUTS_FLAG | - DIG_PROCESS_APP_HOOK_FLAG | DIG_PROCESS_INPUTS_FLAG); + nowTime = micros(); + /* Read local time from ESC*/ + ESC_read(ESCREG_LOCALTIME, (void *)&ESCvar.Time, sizeof(ESCvar.Time)); + ESCvar.Time = etohl(ESCvar.Time); + DIG_process(DIG_PROCESS_WD_FLAG | DIG_PROCESS_OUTPUTS_FLAG | + DIG_PROCESS_APP_HOOK_FLAG | DIG_PROCESS_INPUTS_FLAG); serveIRQ = 0; ESCvar.PrevTime = ESCvar.Time; } @@ -131,7 +138,6 @@ void sync0Handler(void) ALEventIRQ = ESC_ALeventread(); serveIRQ = 1; irqTime = longTime.extendTime(micros()); - digitalWrite(Step.dirPin, cnt++ % 2); } // Enable SM2 interrupts