Skip to content

Commit 5ca2199

Browse files
authored
Merge pull request #3810 from hdiethelm/xhc-whb04b-6-fix-v2
xhc-whb04b-6 fixes
2 parents 6dd95e9 + 4d57565 commit 5ca2199

File tree

4 files changed

+35
-21
lines changed

4 files changed

+35
-21
lines changed

src/hal/user_comps/xhc-whb04b-6/example-configuration.md renamed to src/hal/user_comps/xhc-whb04b-6/example-configuration.hal

File renamed without changes.

src/hal/user_comps/xhc-whb04b-6/hal.cc

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,8 +1324,9 @@ void Hal::setJogCounts(const HandWheelCounters& counters)
13241324
*memory->out.axisAJogCounts = counters.counts(HandWheelCounters::CounterNameToIndex::AXIS_A);
13251325
*memory->out.axisBJogCounts = counters.counts(HandWheelCounters::CounterNameToIndex::AXIS_B);
13261326
*memory->out.axisCJogCounts = counters.counts(HandWheelCounters::CounterNameToIndex::AXIS_C);
1327-
requestManualMode(false);
1328-
requestTeleopMode(false);
1327+
1328+
requestManualMode(false);
1329+
requestTeleopMode(false);
13291330
}
13301331
// ----------------------------------------------------------------------
13311332
void Hal::setFunction(bool enabled)
@@ -1340,6 +1341,13 @@ bool Hal::requestAutoMode(bool isRisingEdge)
13401341
// ----------------------------------------------------------------------
13411342
bool Hal::requestManualMode(bool isRisingEdge)
13421343
{
1344+
if(isRisingEdge && !*memory->in.isProgramIdle)
1345+
{
1346+
//Don't try to change to manual when not idle
1347+
//When a program is running, this will fail
1348+
//When an MDI command is active, this would stop it
1349+
return false;
1350+
}
13431351
return requestMode(isRisingEdge, memory->out.doModeManual, memory->in.isModeManual);
13441352
}
13451353
// ----------------------------------------------------------------------

src/hal/user_comps/xhc-whb04b-6/pendant.cc

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ FeedRotaryButtonCodes::FeedRotaryButtonCodes() :
343343
{percent_60.code, &percent_60},
344344
{percent_100.code, &percent_100},
345345
{lead.code, &lead},
346+
{lead9B.code, &lead9B},
346347
{undefined.code, &undefined}
347348
}
348349
{
@@ -586,6 +587,11 @@ void FeedRotaryButton::setStepMode(HandwheelStepmodes::Mode stepMode)
586587
update();
587588
}
588589
// ----------------------------------------------------------------------
590+
void FeedRotaryButton::setStepMode_5_10(bool enable)
591+
{
592+
mIsStepMode_5_10 = enable;
593+
}
594+
// ----------------------------------------------------------------------
589595
HandwheelStepmodes::Mode FeedRotaryButton::stepMode() const
590596
{
591597
return mStepMode;
@@ -625,7 +631,7 @@ void FeedRotaryButton::update()
625631
mStepSize = mStepSizeMapper.getStepSize(second);
626632
mIsPermitted = mStepSizeMapper.isPermitted(second);
627633

628-
if (mIsStepMode_5_10 && mStepSize > 2) {mStepSize = 0;} // TODO DOES NOT WORK bool variable seems to be not synched inside pendant.h
634+
if (!mIsStepMode_5_10 && mStepSize > 2) {mStepSize = 1.0;}
629635

630636
}
631637
else if (mStepMode == HandwheelStepmodes::Mode::CON)
@@ -730,11 +736,6 @@ void Handwheel::enableVerbose(bool enable)
730736
}
731737
}
732738
// ----------------------------------------------------------------------
733-
void Handwheel::setMode(HandWheelCounters::CounterNameToIndex activeCounterMode)
734-
{
735-
mCounters.setActiveCounter(activeCounterMode);
736-
}
737-
// ----------------------------------------------------------------------
738739
void Handwheel::count(int8_t delta)
739740
{
740741
assert(mEventListener != nullptr);
@@ -1475,11 +1476,17 @@ bool Pendant::onJogDialEvent(const HandWheelCounters& counters, int8_t delta)
14751476
{
14761477
mHal.toggleFeedrateDecrease();
14771478
}
1478-
}
1479-
else if (!counters.isLeadCounterActive() && (feedButton.stepMode() == HandwheelStepmodes::Mode::CON || feedButton.stepMode() == HandwheelStepmodes::Mode::STEP))
1480-
{ // Normal Mode
1481-
mHal.setJogCounts(counters);
1482-
}
1479+
}
1480+
1481+
if (!counters.isLeadCounterActive())
1482+
{
1483+
//The counters must be set always if not in lead mode
1484+
//Otherwhise, the machine will move, sometimes a long distance in the following case:
1485+
//MGP mode -> Wheel turned -> CON or STEP mode -> After first wheel pulse
1486+
//due to the counters are increased in MPG mode but not set until the first wheel count event
1487+
//Setting them does not create a move in MPG mode due to the scale is zero
1488+
mHal.setJogCounts(counters);
1489+
}
14831490
}
14841491
mDisplay.onJogDialEvent(counters, delta);
14851492
return true;
@@ -1563,19 +1570,19 @@ void Pendant::dispatchAxisEventToHal(const KeyCode& axis, bool isActive)
15631570
}
15641571
}
15651572
// ----------------------------------------------------------------------
1566-
void Pendant::setLeadModeSpindle(bool /*enable*/)
1573+
void Pendant::setLeadModeSpindle(bool enable)
15671574
{
1568-
mIsLeadModeSpindle = true;
1575+
mIsLeadModeSpindle = enable;
15691576
}
15701577
// ----------------------------------------------------------------------
1571-
void Pendant::setLeadModeFeed(bool /*enable*/)
1578+
void Pendant::setLeadModeFeed(bool enable)
15721579
{
1573-
mIsLeadModeFeed = true;
1580+
mIsLeadModeFeed = enable;
15741581
}
15751582
// ----------------------------------------------------------------------
1576-
void Pendant::setStepMode_5_10(bool /*enable*/)
1583+
void Pendant::setStepMode_5_10(bool enable)
15771584
{
1578-
mIsStepMode_5_10 = true;
1585+
mCurrentButtonsState.feedButton().setStepMode_5_10(enable);
15791586
}
15801587
// ----------------------------------------------------------------------
15811588
Display::Display(const ButtonsState& currentButtonsState, Hal& hal, UsbOutPackageData& displayData) :

src/hal/user_comps/xhc-whb04b-6/pendant.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ class FeedRotaryButton : public RotaryButton
393393
~FeedRotaryButton();
394394
virtual bool setKeyCode(const KeyCode& keyCode) override;
395395
void setStepMode(HandwheelStepmodes::Mode stepMode);
396+
void setStepMode_5_10(bool enable);
396397
HandwheelStepmodes::Mode stepMode() const;
397398
float stepSize() const;
398399
bool isPermitted() const override;
@@ -440,7 +441,6 @@ class Handwheel
440441
Handwheel(const FeedRotaryButton& feedButton, KeyEventListener* listener = nullptr);
441442
~Handwheel();
442443
void enableVerbose(bool enable);
443-
void setMode(HandWheelCounters::CounterNameToIndex mode);
444444
void count(int8_t delta);
445445
const HandWheelCounters& counters() const;
446446
HandWheelCounters& counters();
@@ -588,7 +588,6 @@ class Pendant : public KeyEventListener
588588
//! if in Lead mode: if true jog wheel changes the spindle speed, changes the feed override otherwise
589589
bool mIsLeadModeSpindle = false;
590590
bool mIsLeadModeFeed = false;
591-
bool mIsStepMode_5_10 = false;
592591

593592
// float mScale;
594593
// float mMaxVelocity;

0 commit comments

Comments
 (0)