Skip to content

Commit 25a0121

Browse files
committed
qtplasmac: rework torch pulse
Previously holding a torch pulse past the timer end would cause a repeated 1mS drop out at the end of each repeat of the prescribed time interval. While probably benign, it was not ideal. Also reworked to not rely on setting the time to 0 to end a torch pulse. The GUI timer is now to show the time remaining on the button only and is independent of the component's torch pulse timer.
1 parent e98464e commit 25a0121

3 files changed

Lines changed: 93 additions & 71 deletions

File tree

share/qtvcp/screens/qtplasmac/qtplasmac_handler.py

Lines changed: 66 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION = '014.079'
1+
VERSION = '015.080'
22
LCNCVER = '2.10'
33

44
'''
@@ -1420,6 +1420,8 @@ def power_state(self, state):
14201420
STATUS.emit('update-machine-log', log, 'TIME')
14211421
else:
14221422
self.w.power.setChecked(False)
1423+
if self.tpButton and self.torchPulse:
1424+
self.torch_pulse_abort()
14231425
self.set_buttons_state([self.machineOnList, self.idleOnList, self.idleHomedList], False)
14241426
if self.ptButton and hal.get_value('plasmac.probe-test'):
14251427
self.probe_test_stop()
@@ -2038,9 +2040,7 @@ def abort_pressed(self):
20382040
STATUS.emit('update-machine-log', log, 'TIME')
20392041
return
20402042
elif self.torchPulse:
2041-
self.torch_pulse(True)
2042-
log = _translate('HandlerClass', 'Torch pulse aborted')
2043-
STATUS.emit('update-machine-log', log, 'TIME')
2043+
self.torch_pulse_abort()
20442044
else:
20452045
ACTION.ABORT()
20462046
if hal.get_value('plasmac.cut-recovery'):
@@ -2735,7 +2735,7 @@ def set_buttons_state(self, buttonLists, state):
27352735
for button in buttonList:
27362736
if state and STATUS.is_interp_paused() and button not in self.pausedValidList:
27372737
continue
2738-
if not state and button == self.tpButton and self.torchTimer.isActive():
2738+
if not state and button == self.tpButton and self.tpTimer.isActive():
27392739
continue
27402740
self.w[button].setEnabled(state)
27412741
if self.laserRecStatePin.get():
@@ -3626,7 +3626,7 @@ def set_button_color(self):
36263626
self.button_normal(button)
36273627

36283628
def cut_critical_toggle_check(self):
3629-
# self.halTogglePins format is: button name, run critical flag, button text
3629+
# self.halTogglePins format is: button name, run critical flag, button text, alt button text
36303630
checkDict = {
36313631
self.halTogglePins[halpin][2].replace('\n', ' '): halpin
36323632
for halpin in self.halTogglePins
@@ -3984,23 +3984,19 @@ def probe_timeout(self):
39843984
STATUS.emit('update-machine-log', log, 'TIME')
39853985

39863986
def torch_timeout(self):
3987-
if self.torchTime:
3988-
self.torchTime -= 0.1
3989-
self.torchTimer.start(100)
3990-
self.w[self.tpButton].setText(f'{self.torchTime:.1f}')
3991-
if self.torchTime <= 0:
3992-
self.torchTimer.stop()
3993-
self.torchTime = 0
3994-
if not self.w[self.tpButton].isDown() and not self.extPulsePin.get():
3995-
self.torch_pulse_states(True)
3996-
log = _translate('HandlerClass', 'Torch pulse completed')
3997-
STATUS.emit('update-machine-log', log, 'TIME')
3998-
else:
3999-
text0 = _translate('HandlerClass', 'TORCH')
4000-
text1 = _translate('HandlerClass', 'ON')
4001-
self.w[self.tpButton].setText(f'{text0}\n{text1}')
3987+
self.tpRemaining = max(0.0, self.tpRemaining - 0.1)
3988+
self.w[self.tpButton].setText(f'{self.tpRemaining:.1f}')
3989+
if self.tpRemaining > 0:
3990+
return
3991+
self.tpTimer.stop()
3992+
if not hal.get_value('plasmac.torch-pulse-hold') and not self.extPulsePin.get():
3993+
self.torch_pulse_states(True)
3994+
log = _translate('HandlerClass', 'Torch pulse completed')
3995+
STATUS.emit('update-machine-log', log, 'TIME')
40023996
else:
4003-
self.torchTimer.start(100)
3997+
text0 = _translate('HandlerClass', 'TORCH')
3998+
text1 = _translate('HandlerClass', 'ON')
3999+
self.w[self.tpButton].setText(f'{text0}\n{text1}')
40044000

40054001
def pulse_timer_timeout(self):
40064002
# halPulsePins format is: button name, pulse time, button text, remaining time, button number
@@ -4071,10 +4067,11 @@ def user_button_setup(self):
40714067
self.probeTimer = QTimer()
40724068
self.probeTimer.setSingleShot(True)
40734069
self.probeTimer.timeout.connect(self.probe_timeout)
4074-
self.torchTime = 0.0
4075-
self.torchTimer = QTimer()
4076-
self.torchTimer.setSingleShot(True)
4077-
self.torchTimer.timeout.connect(self.torch_timeout)
4070+
self.tpRemaining = 0.0
4071+
self.tpTimer = QTimer()
4072+
self.tpTimer.setSingleShot(False)
4073+
self.tpTimer.setInterval(100)
4074+
self.tpTimer.timeout.connect(self.torch_timeout)
40784075
self.pulseTime = 0
40794076
self.pulseTimer = QTimer()
40804077
self.pulseTimer.timeout.connect(self.pulse_timer_timeout)
@@ -4163,7 +4160,7 @@ def user_button_setup(self):
41634160
msg1 = _translate('HandlerClass', 'Check button code for invalid seconds argument')
41644161
STATUS.emit('error', linuxcnc.OPERATOR_ERROR, f'{head}:\n{msg0} #{bNum}\n{msg1}\n')
41654162
continue
4166-
self.tpTime = 3.0 if self.torchTime > 3.0 else self.tpTime
4163+
self.tpTime = 3.0 if self.tpTime > 3.0 else self.tpTime
41674164
else:
41684165
self.tpTime = 1.0
41694166
self.tpButton = f'button_{str(bNum)}'
@@ -4561,6 +4558,8 @@ def torch_enable_changed(self, state):
45614558
not hal.get_value('plasmac.consumable-changing'):
45624559
self.w[self.tpButton].setEnabled(True)
45634560
else:
4561+
if self.torchPulse:
4562+
self.torch_pulse_abort()
45644563
self.w[self.tpButton].setEnabled(False)
45654564

45664565
def ext_torch_enable_changed(self, state):
@@ -4740,28 +4739,47 @@ def ext_torch_pulse(self, state):
47404739

47414740
def torch_pulse(self, state):
47424741
if state:
4743-
if not self.torchTime and \
4744-
self.w.torch_enable.isChecked() and not hal.get_value('plasmac.torch-on'):
4745-
self.torchTime = self.tpTime
4746-
self.torchTimer.start(100)
4747-
self.torchPulse = True
4748-
hal.set_p('plasmac.torch-pulse-time', str(self.torchTime))
4749-
hal.set_p('plasmac.torch-pulse-start', '1')
4750-
self.w[self.tpButton].setText(f'{self.torchTime}')
4751-
self.button_active(self.tpButton)
4752-
self.torch_pulse_states(False)
4753-
log = _translate('HandlerClass', 'Torch pulse started')
4754-
STATUS.emit('update-machine-log', log, 'TIME')
4755-
else:
4756-
self.torchTimer.stop()
4757-
self.torchTime = 0.0
4758-
self.torch_pulse_states(True)
4742+
self.torch_pulse_pressed()
47594743
else:
4760-
hal.set_p('plasmac.torch-pulse-start', '0')
4761-
if self.torchTime == 0:
4762-
self.torch_pulse_states(True)
4763-
log = _translate('HandlerClass', 'Torch pulse ended manually')
4764-
STATUS.emit('update-machine-log', log, 'TIME')
4744+
self.torch_pulse_released()
4745+
4746+
def torch_pulse_pressed(self):
4747+
# second press while active aborts
4748+
if self.tpRemaining > 0:
4749+
self.torch_pulse_abort()
4750+
return
4751+
if hal.get_value('plasmac.torch-on'):
4752+
return
4753+
self.tpRemaining = self.tpTime
4754+
self.torchPulse = True
4755+
hal.set_p('plasmac.torch-pulse-time', str(self.tpRemaining))
4756+
hal.set_p('plasmac.torch-pulse-start', '1')
4757+
hal.set_p('plasmac.torch-pulse-hold', '1')
4758+
self.tpTimer.start()
4759+
self.w[self.tpButton].setText(f'{self.tpRemaining}')
4760+
self.button_active(self.tpButton)
4761+
self.torch_pulse_states(False)
4762+
log = _translate('HandlerClass', 'Torch pulse started')
4763+
STATUS.emit('update-machine-log', log, 'TIME')
4764+
4765+
def torch_pulse_released(self):
4766+
hal.set_p('plasmac.torch-pulse-start', '0')
4767+
hal.set_p('plasmac.torch-pulse-hold', '0')
4768+
if self.tpRemaining == 0:
4769+
self.torch_pulse_states(True)
4770+
log = _translate('HandlerClass', 'Torch pulse hold released')
4771+
STATUS.emit('update-machine-log', log, 'TIME')
4772+
4773+
def torch_pulse_abort(self):
4774+
hal.set_p('plasmac.torch-pulse-abort', '1')
4775+
QTimer.singleShot(50, lambda: hal.set_p('plasmac.torch-pulse-abort', '0'))
4776+
hal.set_p('plasmac.torch-pulse-start', '0')
4777+
hal.set_p('plasmac.torch-pulse-hold', '0')
4778+
self.tpTimer.stop()
4779+
self.tpRemaining = 0.0
4780+
self.torch_pulse_states(True)
4781+
log = _translate('HandlerClass', 'Torch pulse aborted')
4782+
STATUS.emit('update-machine-log', log, 'TIME')
47654783

47664784
def torch_pulse_states(self, state):
47674785
self.set_tab_jog_states(state)
@@ -4773,7 +4791,6 @@ def torch_pulse_states(self, state):
47734791
if self.w.gcode_display.lines() > 1:
47744792
self.w.run.setEnabled(state)
47754793
if state:
4776-
hal.set_p('plasmac.torch-pulse-time', '0')
47774794
self.w[self.tpButton].setText(self.tpText)
47784795
self.button_normal(self.tpButton)
47794796
self.torchPulse = False

share/qtvcp/screens/qtplasmac/versions.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ <h2>QtPlasmaC Version History - LinuxCNC 2.10</h2>
2626
</table>
2727
<br>
2828
<!--- ****** ADD NEXT VERSION BELOW THIS LINE ****** --->
29+
<br><b><u>015.080 2026 Feb 01</u></b>
30+
<ul style="margin:0;">
31+
<li>rework torch pulse</li>
32+
</ul>
33+
2934
<br><b><u>014.079 2026 Jan 01</u></b>
3035
<br><b>QtPlasmaC GUI</b>
3136
<ul style="margin:0;">

src/hal/components/plasmac.comp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ A plasma cutting table control component for use with the LinuxCNC 2.10.
77

88
=== VERSION
99

10-
014
10+
015
1111

1212
=== SUMMARY
1313

@@ -141,6 +141,8 @@ pin in float thc_sample_threshold = 1 "thc maximum arc voltage deviation a
141141
pin in float thc_threshold "thc threshold (volts), changes below this have no effect";
142142
pin in bit torch_enable "enable torch";
143143
pin in bit torch_off "turn torch off";
144+
pin in bit torch_pulse_abort "torch pulse abort";
145+
pin in bit torch_pulse_hold "torch pulse hold";
144146
pin in bit torch_pulse_start "torch pulse start";
145147
pin in float torch_pulse_time "torch pulse time (seconds)";
146148
pin in bit tube_cut "set the current job as tube cutting";
@@ -2088,28 +2090,26 @@ FUNCTION(_) {
20882090
}
20892091
break;
20902092
case TORCHPULSE:
2091-
/* single pulse the torch on and off */
2092-
if(!torch_on){
2093+
if (torch_pulse_abort || !torch_enable) {
2094+
torch_on = FALSE;
2095+
torch_pulse_timer = 0;
2096+
state = cut_recovering ? CUT_RECOVERY_ON : IDLE;
2097+
break;
2098+
}
2099+
if (!torch_on) {
20932100
torch_pulse_timer = torch_pulse_time;
2094-
if(torch_enable){
2095-
torch_on = TRUE;
2096-
}
2097-
}else{
2098-
if(torch_pulse_time == 0){
2099-
torch_pulse_timer = 0;
2100-
}
2101-
if(torch_pulse_timer > 0){
2102-
torch_pulse_timer -= fperiod;
2103-
}else{
2104-
torch_on = FALSE;
2105-
if(!torch_pulse_start){
2106-
if(cut_recovering){
2107-
state = CUT_RECOVERY_ON;
2108-
}else{
2109-
state = IDLE;
2110-
}
2111-
}
2112-
}
2101+
torch_on = TRUE;
2102+
break;
2103+
}
2104+
if (torch_pulse_timer > 0) {
2105+
torch_pulse_timer -= fperiod;
2106+
if (torch_pulse_timer < 0) torch_pulse_timer = 0;
2107+
}
2108+
if (torch_pulse_timer > 0 || torch_pulse_hold) {
2109+
torch_on = TRUE;
2110+
} else {
2111+
torch_on = FALSE;
2112+
state = cut_recovering ? CUT_RECOVERY_ON : IDLE;
21132113
}
21142114
break;
21152115
case PAUSED_MOTION:

0 commit comments

Comments
 (0)