buildbotics / bbctrl-firmware

Buildbotics CNC Controller Firmware
https://buildbotics.com/
Other
67 stars 24 forks source link

tool change doesn't work in tplang #351

Open DougCoffland opened 2 months ago

DougCoffland commented 2 months ago

The tool() command in tplang does not cause the 'tool-change' code on the SETTINGS->General page to execute.

I tried to work around this by creating a function that would prompt the user to change tools and then run through a probing sequence.

Unfortunately, I found that while the probe() command causes the axis to move down toward the probe, it does not see the probe when contact is made.

It also seems that it is not possible to set the position of an axis after probe contact is made.

Here is the code that I created for probing:

function changeTool(num,rpm,rate,depth) {
  rapid(0,127,38.1);
  message('change to tool ' + num + ' and attach probe');
  pause();
  feed(100);
  probe({z: depth});
  translate(0,0,19.05);
  message('remove probe');
  pause()
  rapid({z: 25});
  tool(num);
  speed(rpm);
  feed(rate);
  message('continue when up to speed');
  pause();
};
DougCoffland commented 2 months ago

It turns out that gcode files can be called from tpl files using the gcode command, like this:

gcode("test.gc");

In addition, an new command called gexec is being release with version 2.0.3 when allow you to execute individual gcode line like this: gexec("G0 X10")

This resolves the issue.

DougCoffland commented 2 months ago

I have not been able to get through a tool change in tplang. I am running V2.0.3rc2 and here's what I get:

When I try to run the program below above I immediately get an error that says "Switch not enabled: s23".

var my = require('mymachine.js').MyMachine;

units(METRIC);

var s = units();
message('units are ' + s);
pause()

message('feed rate is ' + feed());
pause();

function changeTool(num,rpm,rate,depth) {
  rapid(0,127,38.1);
  message('change to tool ' + num + ' and attach probe');
  pause();
  feed(100);
  probe({z: depth});
  translate(0,0,19.05);
  message('remove probe');
  pause()
  rapid({z: 25});
  tool(num);
  speed(rpm);
  feed(rate);
  message('continue when up to speed');
  pause();
};

changeTool(1,10000,2000,-5);

If I comment out the probe() command, the error goes away, of course it doesn't probe.

If try to run following code, it ends up setting the offset to 19.05 rather than setting the position to 19.05 and adjusting the offset accordingly.

units(METRIC);

gexec('g38.2 z-54 f100');
gexec('g92 z19.05');

Sometimes the actual position that gets set is a large number. Then, when I tell Z to move to some reasonable position so I can remove the bit, the bit drives into the table.

When I try this code with the same gcodes in another file, I get more non-sensible numbers in position and offset.

units(METRIC);

gcode('lib/onToolChange.gc');

I am guessing that the machine state does not get passed correctly between gcode and tplang when running gcode() or gexec();

At the moment, my priority is to get probe() fixed, but it would also be nice to have gexec() and gcode() working.