More code additions for bCNC – Running headless
Share on facebook
Share on twitter
Share on linkedin

To run remotely, there’s the option to forward Application windows to the host computer, however when thinking about automation, it might be best to make sure that the programs can still be run headless. I’m also going to add the code additions for removing some extra gCode from the files as they’re opened.

To add code additions to prematurely remove extra lines introduced by me outputting the file from fusion 360:

There is a function in called

def load(self, filename=None):

Adding a line to the section

for line in f:
if “G28” in line and “G91” in line:

G28 says to move to reference and G91 says to do it in incremental mode, not all at once. Fusion exports it to Z0 and if run, will hit a limit switch. Another option is to make it 5 instead of 0.

I’m also going to change the “wait till gcode finishes” to a wait until no movement style function. To do this, I had to include a checkStateChange flag to the function as when waiting for the device to home on the first instance, there will not be any motor positions to read, and therefore any comparisons will be pointless

Another Addition I want to make is to add a spot for the tool to go to when I want to change tool. I know the Y will be -5 in the motor space. The z will be negative 5 in the motor space and the x -100. The only thing important here is to make sure that z moves first as to take it out of the range of any workpiece.

The next large addition is to make a program that can be run at the press of a button. This program will need to perform a variety of patterns, and then return to an origin position. After returning to an origin position, it needs to capture a photo on the connected camera.

Installing the camera gave me grief, I needed to run this command

echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="03e7", MODE="0666"' | sudo tee /etc/udev/rules.d/80-movidius.rules
sudo udevadm control --reload-rules && sudo udevadm trigger

Please note, there are two depthai libraries around, version 1 and 2. For, version one will need to be installed, however for our cnc purposes, we’ll be using version 2 and taking from below.