diff --git a/Firmware/include/StepGen.h b/Firmware/include/StepGen.h index dc2eff7..6b07d07 100755 --- a/Firmware/include/StepGen.h +++ b/Firmware/include/StepGen.h @@ -14,6 +14,7 @@ public: volatile uint32_t timerNewCycleTime; volatile double_t actualPosition; volatile double_t requestedPosition; + volatile uint8_t enabled; HardwareTimer *MyTim; uint16_t stepsPerMM; static uint32_t sync0CycleTime; @@ -32,6 +33,7 @@ public: void handleStepper(void); void timerCB(); void setScale(int16_t spm); + void enable(uint8_t yes); }; #endif \ No newline at end of file diff --git a/Firmware/lib/soes/MetalMusings_EaserCAT_2000.xml b/Firmware/lib/soes/MetalMusings_EaserCAT_2000.xml index 738a2d1..4428c6e 100755 --- a/Firmware/lib/soes/MetalMusings_EaserCAT_2000.xml +++ b/Firmware/lib/soes/MetalMusings_EaserCAT_2000.xml @@ -191,6 +191,40 @@ + + DT1604 + 144 + + 0 + Max SubIndex + USINT + 8 + 0 + + ro + + + + 1 + Enable1 + ULINT + 64 + 16 + + ro + + + + 2 + Padding 1 + ULINT + 64 + 80 + + ro + + + DT1A00 80 @@ -394,15 +428,15 @@ DT1C12ARR UINT - 64 + 80 1 - 4 + 5 DT1C12 - 80 + 96 0 Max SubIndex @@ -416,7 +450,7 @@ Elements DT1C12ARR - 64 + 80 16 ro @@ -613,6 +647,10 @@ INT 16 + + BOOL + 1 + @@ -810,6 +848,35 @@ ro + + #x1604 + Enable1 + DT1604 + 144 + + + Max SubIndex + + 2 + + + + Enable1 + + #x70040001 + + + + Padding 1 + + #x00000007 + + + + + ro + + #x1A00 EncPos @@ -1016,12 +1083,12 @@ #x1C12 Sync Manager 2 PDO Assignment DT1C12 - 80 + 96 Max SubIndex - 4 + 5 @@ -1048,6 +1115,12 @@ #x1603 + + PDO Mapping + + #x1604 + + ro @@ -1307,6 +1380,19 @@ ro + + #x7004 + Enable1 + BOOL + 1 + + 0 + + + ro + R + + @@ -1375,6 +1461,22 @@ INT + + #x1604 + Enable1 + + #x7004 + #x0 + 1 + Enable1 + BOOL + + + 0 + 0 + 7 + + #x1A00 EncPos diff --git a/Firmware/lib/soes/ecat_options.h b/Firmware/lib/soes/ecat_options.h index 7bc2f2b..990fb28 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 8 #define MAX_MAPPINGS_SM3 7 #define MAX_RXPDO_SIZE 512 diff --git a/Firmware/lib/soes/esi.json b/Firmware/lib/soes/esi.json index 23ea7ea..3324c97 100755 --- a/Firmware/lib/soes/esi.json +++ b/Firmware/lib/soes/esi.json @@ -223,6 +223,17 @@ "rxpdo" ] }, + "7004": { + "otype": "VAR", + "name": "Enable1", + "access": "RO", + "pdo_mappings": [ + "rxpdo" + ], + "dtype": "BOOLEAN", + "value": "0", + "data": "&Obj.Enable1" + }, "60664": { "otype": "VAR", "name": "ActualPosition", diff --git a/Firmware/lib/soes/objectlist.c b/Firmware/lib/soes/objectlist.c index b92939f..af63550 100755 --- a/Firmware/lib/soes/objectlist.c +++ b/Firmware/lib/soes/objectlist.c @@ -27,6 +27,10 @@ static const char acName1603[] = "StepGenIn2"; static const char acName1603_00[] = "Max SubIndex"; static const char acName1603_01[] = "CommandedPosition"; static const char acName1603_02[] = "StepsPerMM"; +static const char acName1604[] = "Enable1"; +static const char acName1604_00[] = "Max SubIndex"; +static const char acName1604_01[] = "Enable1"; +static const char acName1604_02[] = "Padding 1"; static const char acName1A00[] = "EncPos"; static const char acName1A00_00[] = "Max SubIndex"; static const char acName1A00_01[] = "EncPos"; @@ -60,6 +64,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,6 +95,7 @@ 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 acName7004[] = "Enable1"; const _objd SDO1000[] = { @@ -137,6 +143,12 @@ const _objd SDO1603[] = {0x01, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1603_01, 0x70030140, NULL}, {0x02, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1603_02, 0x70030210, NULL}, }; +const _objd SDO1604[] = +{ + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1604_00, 2, NULL}, + {0x01, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1604_01, 0x70040001, NULL}, + {0x02, DTYPE_UNSIGNED64, 64, ATYPE_RO, acName1604_02, 0x00000007, NULL}, +}; const _objd SDO1A00[] = { {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A00_00, 1, NULL}, @@ -182,11 +194,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[] = { @@ -249,6 +262,10 @@ const _objd SDO7003[] = {0x01, DTYPE_REAL64, 64, ATYPE_RO, acName7003_01, 0, &Obj.StepGenIn2.CommandedPosition}, {0x02, DTYPE_INTEGER16, 16, ATYPE_RO, acName7003_02, 0, &Obj.StepGenIn2.StepsPerMM}, }; +const _objd SDO7004[] = +{ + {0x0, DTYPE_BOOLEAN, 1, ATYPE_RO | ATYPE_RXPDO, acName7004, 0, &Obj.Enable1}, +}; const _objectlist SDOobjects[] = { @@ -261,6 +278,7 @@ const _objectlist SDOobjects[] = {0x1601, OTYPE_RECORD, 1, 0, acName1601, SDO1601}, {0x1602, OTYPE_RECORD, 2, 0, acName1602, SDO1602}, {0x1603, OTYPE_RECORD, 2, 0, acName1603, SDO1603}, + {0x1604, OTYPE_RECORD, 2, 0, acName1604, SDO1604}, {0x1A00, OTYPE_RECORD, 1, 0, acName1A00, SDO1A00}, {0x1A01, OTYPE_RECORD, 1, 0, acName1A01, SDO1A01}, {0x1A02, OTYPE_RECORD, 1, 0, acName1A02, SDO1A02}, @@ -269,7 +287,7 @@ const _objectlist SDOobjects[] = {0x1A05, OTYPE_RECORD, 1, 0, acName1A05, SDO1A05}, {0x1A06, OTYPE_RECORD, 1, 0, acName1A06, SDO1A06}, {0x1C00, OTYPE_ARRAY, 4, 0, acName1C00, SDO1C00}, - {0x1C12, OTYPE_ARRAY, 4, 0, acName1C12, SDO1C12}, + {0x1C12, OTYPE_ARRAY, 5, 0, acName1C12, SDO1C12}, {0x1C13, OTYPE_ARRAY, 7, 0, acName1C13, SDO1C13}, {0x6000, OTYPE_VAR, 0, 0, acName6000, SDO6000}, {0x6001, OTYPE_VAR, 0, 0, acName6001, SDO6001}, @@ -282,5 +300,6 @@ const _objectlist SDOobjects[] = {0x7001, OTYPE_VAR, 0, 0, acName7001, SDO7001}, {0x7002, OTYPE_RECORD, 2, 0, acName7002, SDO7002}, {0x7003, OTYPE_RECORD, 2, 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 f887e0d..cd93b85 100755 --- a/Firmware/lib/soes/utypes.h +++ b/Firmware/lib/soes/utypes.h @@ -41,6 +41,7 @@ typedef struct double CommandedPosition; int16_t StepsPerMM; } StepGenIn2; + uint8_t Enable1; } _Objects; diff --git a/Firmware/src/StepGen.cpp b/Firmware/src/StepGen.cpp index 8f7a9c4..bedc44c 100755 --- a/Firmware/src/StepGen.cpp +++ b/Firmware/src/StepGen.cpp @@ -12,6 +12,7 @@ StepGen::StepGen(TIM_TypeDef *Timer, uint32_t _timerChannel, PinName _stepPin, u actualPosition = 0; requestedPosition = 0; stepsPerMM = 0; + enabled = 0; dirPin = _dirPin; stepPin = _stepPin; @@ -37,8 +38,16 @@ double StepGen::actPos() return actualPosition; } +void StepGen::enable(uint8_t yes) +{ + enabled = yes; +} + void StepGen::handleStepper(void) { + if (!enabled) + return; + actPos(timerStepPosition / double(stepsPerMM)); double diffPosition = reqPos() - actPos(); diff --git a/Firmware/src/main.cpp b/Firmware/src/main.cpp index 2ac0178..c4ce843 100755 --- a/Firmware/src/main.cpp +++ b/Firmware/src/main.cpp @@ -46,8 +46,10 @@ void cb_set_outputs(void) // Master outputs gets here, slave inputs, first opera Step1.reqPos(Obj.StepGenIn1.CommandedPosition); Step1.setScale(Obj.StepGenIn1.StepsPerMM); + Step1.enable(Obj.Enable1); Step2.reqPos(Obj.StepGenIn2.CommandedPosition); Step2.setScale(Obj.StepGenIn2.StepsPerMM); + Step2.enable(Obj.Enable1); } void handleStepper(void) @@ -123,9 +125,8 @@ void sync0Handler(void) void ESC_interrupt_enable(uint32_t mask) { // Enable interrupt for SYNC0 or SM2 or SM3 - uint32_t user_int_mask = ESCREG_ALEVENT_DC_SYNC0 | - ESCREG_ALEVENT_SM2 | - ESCREG_ALEVENT_SM3; + // uint32_t user_int_mask = ESCREG_ALEVENT_DC_SYNC0 | ESCREG_ALEVENT_SM2 | ESCREG_ALEVENT_SM3; + uint32_t user_int_mask = ESCREG_ALEVENT_SM2; // Only SM2 if (mask & user_int_mask) { ESC_ALeventmaskwrite(ESC_ALeventmaskread() | (mask & user_int_mask)); @@ -144,9 +145,8 @@ void ESC_interrupt_enable(uint32_t mask) void ESC_interrupt_disable(uint32_t mask) { // Enable interrupt for SYNC0 or SM2 or SM3 - uint32_t user_int_mask = ESCREG_ALEVENT_DC_SYNC0 | - ESCREG_ALEVENT_SM2 | - ESCREG_ALEVENT_SM3; + // uint32_t user_int_mask = ESCREG_ALEVENT_DC_SYNC0 | ESCREG_ALEVENT_SM2 | ESCREG_ALEVENT_SM3; + uint32_t user_int_mask = ESCREG_ALEVENT_SM2; if (mask & user_int_mask) { @@ -160,11 +160,12 @@ void ESC_interrupt_disable(uint32_t mask) } extern "C" uint32_t ESC_SYNC0cycletime(void); + // Setup of DC uint16_t dc_checker(void) { // Indicate we run DC - ESCvar.dcsync = 0; + ESCvar.dcsync = 1; StepGen::sync0CycleTime = ESC_SYNC0cycletime() / 1000; return 0; }