Real-Time Z-Axis Control with Inductive Sensor Feedback in G-Code

Hi everyone,

I’m using the MpCnc3Axis function to control three axes with G-code, but I need to ensure the Z-axis doesn’t collide with obstacles. To address this, I’m integrating an inductive sensor with an analog input to set a safe offset range for the Z-axis.

However, I’m encountering an issue: when I use the analog input for the Z-axis, the value isn’t updated in real-time. Instead, it retains the last sensor reading before the G-code line executes. This makes it difficult to accurately control the Z-axis in real-time, increasing the risk of collisions.

For example, when I use the code G01 X10 Y10 Z=AnalogInput, where ‘AnalogInput’ is a variable linked to the inductive sensor, the command moves to X10 Y10 and Z[last number] based on the last sensor value at the time of code execution. This doesn’t reflect real-time changes in sensor readings.

I’m looking for advice on how to program G-code so that the Z-axis adjusts continuously based on the latest analog sensor readings, allowing for real-time adjustments. Any suggestions on achieving real-time updates for this axis would be greatly appreciated.

1 Like

Hi Dario,

you could, for example, use the online path influence functionality to modify the z-position in real time, see B&R Online Help.

Just be careful and apply smooth signals, try to avoid “jumps”. You can also use filters in application to make sure the signals are smooth.

2 Likes

Hi Dario
at the time of code execution you can use one more variable and map that value in int data type and execute that to the z axis with move function

1 Like