Pass through step and direction for stepper driver control.

I’m working on a torch height controller for a plasma cutter.
No code written as yet as i’m seeking a direction to get the project started, this is the first step.

I need to intercept the step and direction signals form another Arduino (GRBL CNC) and have one of two operations carried out by a second arduino. the signals being received need to be either passed directly through to output pins or ignored and the second arduino produces the step and direction signals.

The idea is that when the CNC plasma table is being jogged, homed etc in its idle state the commands for the Z axis height are controlled by the GRBL controller but once the table/Z axis is positioned and the Arc enable signal is triggered the second arduino then controls the height of Z Axis based on feedback from a sensor.

The direction is simply a case of matching the digital input to a digital output but what would be a good method of doing the same with the step pulses.

I was thinking of using pulse in but i have got it into my head that the wait for pulse operation of pulsein will create a lag in the axis operation which in itself isn’t the end of the world. Perhaps using interrupts would be the more sensible route. How might i achieve it.

I have code written in other working projects that i intend to use for parsing commands from GRBL and driving stepper motors, its this basic step through operation i wish to start with.

THC Idea.png

Why would you need pulseIn()?

If you connect the CNC step signal to an INPUT pin on a second Arduino (plus GND) then the second Arduino can produce an output on another I/O pin that matches the state of the INPUT.

It may be wise to use the digitalWriteFast library as it is very much faster than a regular digitalRead() or digitalWrite().

Or you could use port manipulation for the output and a CHANGE interrupt to detect the INPUT state if you need the extra performance. Probably not if this is just for manual jogging.

...R

Thanks Rob,

I will write some code and give it a try with hardware. I will post the results back to this post when i've done it.