Auto Touch

My Compass CNC can now measure the Z axis itself :slight_smile:
It is still possible to set Z yourself and confirm with the encoder, but if L+R is held down on the same screen, it automatically moves to the material and uses StallGuard to detect when the tool touches the material. I wouldn’t do this with sensitive milling cutters.
The right button or the encoder can be used to set the 0 position, or the right button can be used to return to manual zeroing.

So far, it works very well with the dummy router bit.
I need to test it with real material.

I still have a few ideas on my to-do list, but before I can tackle them, we/I need to standardize the GUI. Unfortunately, TcMenu is too powerful, and GEM doesn’t really fit with a round screen. We’ll probably have to build something ourselves.

I created a draft PR, because it is only LAB tested :slight_smile:

5 Likes

Very nice !!
Is it using diag pins like mentioned earlier or you are reading the status via UART?

I made it with Uart. No change to wiring required.
I had two problems, reading between the steps was too slow, I control the stepper motor with an interrupt timer for the reference run.
And the examples on the web are almost all wrong. The TMC2209 needs stealthchop to make stallguard work.

Woooo that looks great!! Can’t wait to pull that branch and try it. I love the way you incorporate the LR buttons to allow for manual Z probing as well.

Interestinggg. I have been considering moving the steppers to interrupts for standard runtime as well (for the same reason to make steps faster), but I have very little experience with interrupts. Do you see any immediate problems with using this same implementation alongside sensing and controls? I know grblHAL and some other gCode interpreters put the steppers on interrupts, but they also don’t necessarily have feedback in between the planning and actuation stages.

I totally agree. The current GUI is very barebones and the result of me doing the minimum viable product to get it working. As such the architecture is pretty unintuitive and not very well organized. I’d be happy to do a little brainstorm session to get something better going.

I’m not really an expert when it comes to interrupts either. The stepper is just super slow when I read the registers via UART because the process causes the motor to pause. With an interrupt, that doesn’t happen.
In principle, the stepper motors should run much more accurately because the timing is better, but I have no idea how that might affect the sensing. It doesn’t matter for the touch.

We could try GitHub - luni64/TeensyStep4 instead of AccelStepper.

I would be super interested in integrating that. I looked into it briefly a while ago, but it wasn’t a high enough priority to implement at that time. It seems like a pretty solid library

I stumbled on this thread a while ago while exploring different stepper libraries. The author made a nice little comparison table of different libraries:

Seems like fastAccelStepper could be a nice option too. The one thing about TeensyStep4 is that it doesn’t seem very well documented/tested

Writing low level code for timers is also generally not very difficult - it could be trivial to create an interrupt-driven step generator without any additional library, and would give you a lot of flexibility in how the planning/ action get meshed together.

1 Like

Might be a good time for me to start learning more about it. GrblHAL has a pretty good starting point with their step generation as well

2 Likes

As I mentioned elsewhere I’m playing with an esp32 port, leaving a high level API here would be useful (something like “step Z N steps”) rather than something closer to the hardware which might be more “switch direction pin 4, load timer 6 with N”, or queuing a request to do that if the timer is already stepping

2 Likes

Super valid. That’s pretty essential. I would hate my life trying to code something like “switch direction pin 4, load timer 6 with N” as well :laughing: I love high level stuff

1 Like

I think it’s perfectly valid to do that low level stuff below a HAL layer, I’m more asking for an abstraction to make porting easier

1 Like

We should decide on one microcontroller. We need quasi real-time, the current code looks like nothing, especially with the use of the various libs, but I am sure that the current results are only achieved at all thanks to the extremely fast CPU and the serial buffer of the Teensy. AccelStepper delivers fast results, runs on almost everything, but unfortunately it is not a clean control. The same applies to the PWM3360 Lib, where the burst could also be transferred to the Teensy via DMA.
Of course you can also create a good level of abstraction for interupt and DMA-based controls, but at the lowest level you should get everything out of the microcontroller that it can do and not just use what they all have in common and only let the CPU doeing it stuff.

Agreed, it would be great to decide on a more long-term microcontroller. I originally went with the Teensy because I have used it before and I wanted to make sure I’d have adequate speed and memory. That allowed me to admittedly be more crass with some of the code on first pass.

@matei is exploring STM32 integration. I’m also a bit partial towards ESP32 since I’ve worked with them before, they have integrated WiFi, and are being used on quite a few notable CNC projects (V1 obviously, then also FluidNC, Maslow, etc). Any particular bias @IceOnly ?

Also I mentioned this somewhere else, but it seems worthwhile to re-state: it might make sense to integrate into grblHAL with a plugin or fork at some point. This would probably be more long term, but I think it’s a good thing to keep in mind before putting a significant amount of time towards polishing the Compass firmware when a lot of the features have already been developed very well elsewhere. Not locked into that, though, just something to consider. I’d be curious to hear thoughts on that

1 Like

grblHAL is also interesting for Jackpot V1/V2 and it looks like it can run on SKRs too.

It might be nice to have at least an option to be able to run the same firmware family on all the V1 machines.

It’s interesting to consider your code being a plugin/extension to grblHAL

Wait, couldn’t we use this for edge finding as well?

Move the compass to just over the edge of the material, then have it gently plunge the bit (stop if it detects if there is material underneath), and have it gently move to the edge and when sensing motor stall note that position. Then do that 2 more times for the other edges and you should have a plane where you can do absolute positioning on right?

You did not need to delete your post! We are all pretty cool around here. Politics and spam are the no nos, lol

Yeah that could theoretically totally work