Skip to content

Commit 604d34e

Browse files
authored
full update xhc-whb04b-6 for 2.8
1 parent 208c55c commit 604d34e

3 files changed

Lines changed: 54 additions & 8 deletions

File tree

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ net pdnt.mode.is-mdi halui.mode.is-mdi
6666
net pdnt.mode.is-joint halui.mode.is-joint whb.halui.mode.is-joint
6767
net pdnt.mode.is-teleop halui.mode.is-teleop whb.halui.mode.is-teleop
6868

69+
# "is-homed" axis signal for allowing pendant when machine is not homed
70+
net pdnt.axis.X.is-homed halui.joint.0.is-homed whb.halui.joint.x.is-homed
71+
net pdnt.axis.Y.is-homed halui.joint.1.is-homed whb.halui.joint.y.is-homed
72+
net pdnt.axis.Z.is-homed halui.joint.2.is-homed whb.halui.joint.z.is-homed
6973

7074
# "selected axis" signals
7175
net pdnt.axis.X.select whb.halui.axis.x.select halui.axis.x.select
@@ -92,17 +96,17 @@ net pdnt.axis.z.jog-vel-mode whb.axis.z.jog-vel-mode
9296
# macro buttons to MDI commands
9397
net pdnt.macro-1 whb.button.macro-1 halui.mdi-command-01 # use MDI command from main.ini
9498
net pdnt.macro-2 whb.button.macro-2 halui.mdi-command-02 # use MDI command from main.ini or used for Hardcoded lube on/off
95-
net pdnt.reserved.for.spindle+ whb.button.macro-3 # Harcoded for spindle+ whb.halui.spindle.increase
96-
net pdnt.reserved.for.spindle- whb.button.macro-4 # Harcoded for spindle- whb.halui.spindle.decrease
99+
net pdnt.reserved.for.spindle+ whb.button.macro-3 # Hardcoded for spindle+ whb.halui.spindle.increase
100+
net pdnt.reserved.for.spindle- whb.button.macro-4 # Hardcoded for spindle- whb.halui.spindle.decrease
97101
net pdnt.macro-5 whb.button.macro-5 halui.mdi-command-05 # use MDI command from main.ini
98102
net pdnt.macro-6 whb.button.macro-6 halui.mdi-command-06 # use MDI command from main.ini
99103
net pdnt.macro-7 whb.button.macro-7 halui.mdi-command-07 # use MDI command from main.ini
100-
net pdnt.reserved.for.spindle.dir whb.button.macro-8 # Harcoded for spindle direction inside pendant
104+
net pdnt.reserved.for.spindle.dir whb.button.macro-8 # Hardcoded for spindle direction inside pendant
101105
net pdnt.macro-9 whb.button.macro-9 halui.mdi-command-09 # use MDI command from main.ini
102106
net pdnt.reserved.for.ABS-REL whb.button.macro-10 # Hardcoded for swap Dro Relative/Absolue
103107
net pdnt.macro-14 whb.button.macro-14 halui.mdi-command-14 # use MDI command from main.ini
104-
net pdnt.reserved.for.flood whb.button.macro-15 # Harcoded for halui.flood on/off
105-
net pdnt.reserved.for.mist whb.button.macro-16 # Harcoded for halui.mist on/off
108+
net pdnt.reserved.for.flood whb.button.macro-15 # Hardcoded for halui.flood on/off
109+
net pdnt.reserved.for.mist whb.button.macro-16 # Hardcoded for halui.mist on/off
106110

107111
net pdnt.macro.11 whb.button.macro-11 halui.mdi-command-11 # use MDI command from main.ini
108112
net pdnt.macro.12 whb.button.macro-12 halui.mdi-command-12 # use MDI command from main.ini

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

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,15 @@ Hal::~Hal()
118118
freeSimulatedPin((void**)(&memory->in.isModeMdi));
119119
freeSimulatedPin((void**)(&memory->in.isModeTeleop));
120120

121+
// If axis is not homed we need to ask Teleop mode but we need to bypass that if machine is homed
122+
// https://forum.linuxcnc.org/49-basic-configuration/40581-how-to-configure-a-xhc-whb04b-pendant
123+
freeSimulatedPin((void**)(&memory->in.JointXisHomed));
124+
freeSimulatedPin((void**)(&memory->in.JointYisHomed));
125+
freeSimulatedPin((void**)(&memory->in.JointZisHomed));
126+
freeSimulatedPin((void**)(&memory->in.JointAisHomed));
127+
freeSimulatedPin((void**)(&memory->in.JointBisHomed));
128+
freeSimulatedPin((void**)(&memory->in.JointCisHomed));
129+
121130
freeSimulatedPin((void**)(&memory->in.isMachineOn));
122131

123132
constexpr size_t pinsCount = sizeof(memory->out.button_pin) / sizeof(hal_bit_t * );
@@ -543,6 +552,18 @@ void Hal::init(const MetaButtonCodes* metaButtons, const KeyCodes& keyCodes)
543552
newHalBit(HAL_IN, &(memory->in.isModeManual), mHalCompId, "%s.halui.mode.is-manual", mComponentPrefix);
544553
newHalBit(HAL_IN, &(memory->in.isModeMdi), mHalCompId, "%s.halui.mode.is-mdi", mComponentPrefix);
545554
newHalBit(HAL_IN, &(memory->in.isModeTeleop), mHalCompId, "%s.halui.mode.is-teleop", mComponentPrefix);
555+
556+
557+
// If axis is not homed we need to ask Teleop mode but we need to bypass that if machine is homed
558+
// https://forum.linuxcnc.org/49-basic-configuration/40581-how-to-configure-a-xhc-whb04b-pendant
559+
newHalBit(HAL_IN, &(memory->in.JointXisHomed), mHalCompId, "%s.halui.joint.x.is-homed", mComponentPrefix);
560+
newHalBit(HAL_IN, &(memory->in.JointYisHomed), mHalCompId, "%s.halui.joint.y.is-homed", mComponentPrefix);
561+
newHalBit(HAL_IN, &(memory->in.JointZisHomed), mHalCompId, "%s.halui.joint.z.is-homed", mComponentPrefix);
562+
newHalBit(HAL_IN, &(memory->in.JointAisHomed), mHalCompId, "%s.halui.joint.a.is-homed", mComponentPrefix);
563+
newHalBit(HAL_IN, &(memory->in.JointBisHomed), mHalCompId, "%s.halui.joint.b.is-homed", mComponentPrefix);
564+
newHalBit(HAL_IN, &(memory->in.JointCisHomed), mHalCompId, "%s.halui.joint.c.is-homed", mComponentPrefix);
565+
566+
546567
newHalBit(HAL_OUT, &(memory->out.doModeAuto), mHalCompId, "%s.halui.mode.auto", mComponentPrefix);
547568
newHalBit(HAL_OUT, &(memory->out.doModeJoint), mHalCompId, "%s.halui.mode.joint", mComponentPrefix);
548569
newHalBit(HAL_OUT, &(memory->out.doModeManual), mHalCompId, "%s.halui.mode.manual", mComponentPrefix);
@@ -986,7 +1007,7 @@ void Hal::toggleSpindleDirection(bool enabled)
9861007
}
9871008
else
9881009
{
989-
*memory->out.spindleDoRunReverse = true;
1010+
*memory->out.spindleDoRunReverse = true;
9901011
*memory->out.spindleDoIncrease = true;
9911012
}
9921013
}
@@ -1298,8 +1319,16 @@ void Hal::setPin(bool enabled, const char* pinName)
12981319
// ----------------------------------------------------------------------
12991320
void Hal::setJogCounts(const HandWheelCounters& counters)
13001321
{
1301-
requestManualMode(true);
1302-
requestTeleopMode(true);
1322+
// If axis is not homed we need to ask Teleop mode but we need to bypass that if machine is homed
1323+
// https://forum.linuxcnc.org/49-basic-configuration/40581-how-to-configure-a-xhc-whb04b-pendant
1324+
if (*memory->out.axisXSelect && false == *memory->in.JointXisHomed) {requestTeleopMode(true);}
1325+
else if (*memory->out.axisYSelect && false == *memory->in.JointYisHomed) {requestTeleopMode(true);}
1326+
else if (*memory->out.axisZSelect && false == *memory->in.JointZisHomed) {requestTeleopMode(true);}
1327+
else if (*memory->out.axisASelect && false == *memory->in.JointAisHomed) {requestTeleopMode(true);}
1328+
else if (*memory->out.axisBSelect && false == *memory->in.JointBisHomed) {requestTeleopMode(true);}
1329+
else if (*memory->out.axisCSelect && false == *memory->in.JointCisHomed) {requestTeleopMode(true);}
1330+
{requestManualMode(true);}
1331+
13031332
*memory->out.axisXJogCounts = counters.counts(HandWheelCounters::CounterNameToIndex::AXIS_X);
13041333
*memory->out.axisYJogCounts = counters.counts(HandWheelCounters::CounterNameToIndex::AXIS_Y);
13051334
*memory->out.axisZJogCounts = counters.counts(HandWheelCounters::CounterNameToIndex::AXIS_Z);

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,19 @@ class HalMemory
158158
//! to be connected to \ref halui.mode.is-teleop
159159
hal_bit_t* isModeTeleop{nullptr};
160160

161+
162+
// If axis is not homed we need to ask Teleop mode but we need to bypass that if machine is homed
163+
// https://forum.linuxcnc.org/49-basic-configuration/40581-how-to-configure-a-xhc-whb04b-pendant
164+
hal_bit_t* JointXisHomed{nullptr};
165+
hal_bit_t* JointYisHomed{nullptr};
166+
hal_bit_t* JointZisHomed{nullptr};
167+
hal_bit_t* JointAisHomed{nullptr};
168+
hal_bit_t* JointBisHomed{nullptr};
169+
hal_bit_t* JointCisHomed{nullptr};
170+
171+
172+
173+
161174
//! to be connected to \ref halui.machine.is-on
162175
hal_bit_t* isMachineOn{nullptr};
163176

0 commit comments

Comments
 (0)