Skip to content

Commit dda5dd0

Browse files
committed
Merge branch '2.9'
2 parents 3108885 + 50ebf16 commit dda5dd0

3 files changed

Lines changed: 62 additions & 21 deletions

File tree

docs/src/gui/qtvcp-vcp-panels.adoc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,20 @@ loadusr qtvcp vismach_mill_xyz
275275
.QtVCP `vismach_mill_xyz` - 3-Axis Mill 3D View Panel
276276
image::images/qtvismach.png["QtVCP vismach_mill_xyz - 3-Axis Mill 3D View Panel",align="center"]
277277

278+
=== QtVCP `vismach_router_atc`
279+
280+
3D OpenGL view of a _3-Axis router style, gantry bed milling machine_. +
281+
This particular panel shows how to define and connect the model parts in the handler file, rather then importing the
282+
pre-built model from qtvcp's vismach library.
283+
284+
[source,{hal}]
285+
----
286+
loadusr qtvcp vismach_router_atc
287+
----
288+
289+
.QtVCP `vismach_router_atc` - 3-Axis Gantry Bed Mil 3D View Panel
290+
image::images/qtvismach_router_atc.png["QtVCP vismach_router_atc - 3-Axis Gantry Bed Mill 3D View Panel",align="center"]
291+
278292
=== QtVCP `vismach_scara`
279293

280294
3D OpenGL view of a _SCARA based milling machine_.

share/qtvcp/panels/vismach_router_atc/vismach_router_atc_handler.py

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,14 @@
1515
STATUS = Status()
1616
PATH = Path()
1717

18-
###### VISMACH MODEL CODE #################
18+
###########################################
19+
# **** VISMACH MODEL CODE **** #
20+
###########################################
21+
22+
# decided not to use separate component in example
1923
#import hal
2024

21-
#c = hal.component("3axisatcgui")
25+
#c = hal.component("router_atc")
2226
#c.newpin("joint0", hal.HAL_FLOAT, hal.HAL_IN)
2327
#c.newpin("joint1", hal.HAL_FLOAT, hal.HAL_IN)
2428
#c.newpin("joint2", hal.HAL_FLOAT, hal.HAL_IN)
@@ -29,21 +33,16 @@
2933
tool = Capture()
3034
tooltip = Capture()
3135

32-
33-
3436
# kinematic axis
3537
# axis_y -> axis_x -> axis_z -> tool
3638
# base -> work
3739

38-
3940
# tool
40-
4141
tool = Collection([tooltip, tool])
4242

4343

4444
# axis z
45-
print(PATH.PANELDIR)
46-
objfile = os.path.join(PATH.PANELDIR, "3axisatcgui/headz.obj")
45+
objfile = os.path.join(PATH.PANELDIR, "vismach_router_atc/headz.obj")
4746
axisz = AsciiOBJ(filename=objfile)
4847
axisz = Color([1,1,1,1],[axisz])
4948
axisz = Rotate([axisz],90,1,0,0)
@@ -52,18 +51,18 @@
5251
axisz = Translate([axisz],0,0,-77)
5352
#axisz = HalTranslate([axisz],c,"joint2",0,0,1)
5453
axisz = HalTranslate([axisz], None, "joint.2.pos-fb",0,0,1)
55-
# axis x
5654

57-
objfile = os.path.join(PATH.PANELDIR, "3axisatcgui/head.obj")
55+
# axis x
56+
objfile = os.path.join(PATH.PANELDIR, "vismach_router_atc/head.obj")
5857
head = AsciiOBJ(filename=objfile)
5958
head = Color([0.5,0.5,1,1],[head])
6059
head = Rotate([head],90,1,0,0)
6160
axisx = Collection([axisz, head])
6261
#axisx = HalTranslate([axisx],c,"joint0",1,0,0)
6362
axisx = HalTranslate([axisx],None, "joint.0.pos-fb",1,0,0)
64-
# axis y
6563

66-
objfile = os.path.join(PATH.PANELDIR, "3axisatcgui/gantri.obj")
64+
# axis y
65+
objfile = os.path.join(PATH.PANELDIR, "vismach_router_atc/gantri.obj")
6766
rack = AsciiOBJ(filename=objfile)
6867
rack = Color([0.7,0.7,0.4,0.4],[rack])
6968
rack = Rotate([rack],90,1,0,0)
@@ -72,20 +71,18 @@
7271
axisy = HalTranslate([axisy],None, "joint.1.pos-fb",0,1,0)
7372
machine = Collection([axisy])
7473

75-
76-
7774
# base
78-
objfile = os.path.join(PATH.PANELDIR, "3axisatcgui/rangka.obj")
75+
objfile = os.path.join(PATH.PANELDIR, "vismach_router_atc/rangka.obj")
7976
rangka = AsciiOBJ(filename=objfile)
8077
rangka = Color([1,1,1,1],[rangka])
8178
rangka = Rotate([rangka],90,1,0,0)
8279

83-
objfile = os.path.join(PATH.PANELDIR, "3axisatcgui/bed.obj")
80+
objfile = os.path.join(PATH.PANELDIR, "vismach_router_atc/bed.obj")
8481
bed = AsciiOBJ(filename=objfile)
8582
bed = Color([1,0.8,0.2,0.2],[bed])
8683
bed = Rotate([bed],90,1,0,0)
8784

88-
objfile = os.path.join(PATH.PANELDIR, "3axisatcgui/atc.obj")
85+
objfile = os.path.join(PATH.PANELDIR, "vismach_router_atc/atc.obj")
8986
atc = AsciiOBJ(filename=objfile)
9087
atc = Color([0.5,0.5,0.5,0.5],[atc])
9188
atc = Rotate([atc],90,1,0,0)
@@ -96,6 +93,20 @@
9693

9794
model = Collection([base, machine])
9895

96+
# uncomment for a DRO HUD
97+
#myhud = HalHud()
98+
#myhud.set_background_color(0,.1,.2,0)
99+
#myhud.show_top("Router_atc")
100+
#myhud.show_top("------------")
101+
#myhud.add_pin('axis-x: ',"{:10.4f}","axis.x.pos-cmd")
102+
#myhud.add_pin('axis-y: ',"{:10.4f}","axis.y.pos-cmd")
103+
#myhud.add_pin('axis-z: ',"{:10.4f}","axis.z.pos-cmd")
104+
#myhud.show("-------------")
105+
106+
###########################################
107+
# model window #
108+
###########################################
109+
99110
# we want to embed with qtvcp so build a window to display
100111
# the model
101112
class VisWindow(QWidget):
@@ -130,6 +141,7 @@ def __init__(self):
130141
# **** instantiate libraries section **** #
131142
###########################################
132143
STATUS = Status()
144+
133145
###################################
134146
# **** HANDLER CLASS SECTION **** #
135147
###################################

src/hal/components/carousel.comp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ pin in float rev-dc "Velocity or duty cycle when reverse rotation is desired";
116116
pin in float hold-dc "Duty cycle when carousel is in-position (to hold against stop)";
117117
pin in float align-dc """Use this pin to set the speed of a slower alignment move once the changer is in position. Such a system almost
118118
certainly needs decel-time setting too""";
119-
pin in float decel-time "Time to wait for carousel to stop before final alignment";
119+
pin in float decel-time "Time to wait for carousel to stop before final alignment and position check";
120120
pin in signed counts "Connect to the rawcounts of an encoder or a stepgen in 'counts' mode";
121121
pin in signed scale = 100 "The number of stepgen or encoder counts between successive pockets";
122122
pin in signed width = 0 "How far each side of the exact scale to signal a new pocket";
@@ -167,6 +167,8 @@ int default_dir = 2;
167167
int default_sense = 4;
168168
int default_parity = 0;
169169

170+
static bool err_once = 0;
171+
170172
#define MAX_CHAN 8
171173
static int pockets[MAX_CHAN] = {-1};
172174
RTAPI_MP_ARRAY_INT(pockets, MAX_CHAN, "The number of pockets in each carousel")
@@ -202,6 +204,7 @@ FUNCTION(_){
202204
for(mask = new_pos >> 1 ; mask != 0 ; mask = mask >> 1){
203205
new_pos ^= mask;
204206
}
207+
if (new_pos == 0) new_pos = inst_pockets; // all zeros != pocket zero
205208
break;
206209
case 'B': // Straight Binary
207210
align_pin = strobe;
@@ -380,7 +383,7 @@ FUNCTION(_){
380383
motor_vel = rev_dc;
381384
timer = rev_pulse;
382385
state = 3;
383-
} else if (align_dc != 0) {
386+
} else if (decel_time > 0) {
384387
// stop and prepare for alignment
385388
motor_vel = 0;
386389
timer = decel_time;
@@ -390,7 +393,7 @@ FUNCTION(_){
390393
motor_rev = 0;
391394
motor_vel = hold_dc;
392395
active = 0;
393-
if (enable) ready = 1;
396+
if (enable && current_position == mod_pocket) ready = 1;
394397
state = 9;
395398
}
396399
break;
@@ -407,6 +410,10 @@ FUNCTION(_){
407410
case 5: //Waiting for carousel to stop
408411
timer -= fperiod;
409412
if (timer > 0) return;
413+
if (align_dc == 0){
414+
state = 8;
415+
break;
416+
}
410417
motor_vel = -align_dc;
411418
if (motor_dir == 1) {
412419
state = 6;
@@ -429,11 +436,17 @@ FUNCTION(_){
429436
motor_rev = 0;
430437
motor_vel = hold_dc;
431438
active = 0;
432-
if (enable) ready = 1;
439+
// final safety check for in-position
440+
if (enable && current_position == mod_pocket) ready = 1;
433441
state = 9;
434442
break;
435443
case 9: //waiting for enable to go false
444+
if (! ready && ! err_once){
445+
rtapi_print_msg(RTAPI_MSG_ERR, "The toolchanger has failed the final alignment check");
446+
err_once = 1;
447+
}
436448
if (enable) return;
449+
err_once = 0;
437450
state = 0;
438451
break;
439452
case 10: // start of homing
@@ -498,6 +511,8 @@ EXTRA_SETUP(){
498511
if (pockets[extra_arg] > 0) default_pockets = pockets[extra_arg];
499512
if (encoding[extra_arg] == NULL) {
500513
//it's already default_code
514+
} else if (strncmp(encoding[extra_arg], "gray", 4) == 0) {
515+
default_code = 'G';
501516
} else if (strncmp(encoding[extra_arg], "binary", 6) == 0) {
502517
default_code = 'B';
503518
} else if (strncmp(encoding[extra_arg], "bcd", 3) == 0) {

0 commit comments

Comments
 (0)