Page 1 of 1

Halt and safe Z move

Posted: Wed Sep 29, 2021 11:15 pm
by axeman
Hello,
I am having trouble getting the Z-axis to move to safeZ height after implementing a feedhold/halt in Gcode through a C program.
The purpose of the C program is to include thermal protection for the spindle and run the C-program when a thermal switch opens.
The program runs fine except that the spindle does not move up to a safeZ height.
i.e. it executes feedhold and halts the Gcode program and also turns spindle off but it does not raise the spindle.
Actually, it has executed on occasion including safeZ move, but 99% of the time it does not move Z-axis at all.

I can leave it as is but this creates potential to push the run button again, which will simply continue the G code without restarting the spindle. By making a Z-axis move the Gcode will not start without the 'restart' dialogue popup, allowing the user to review conditions and restart the spindle. This is safer, and is what I would like to achieve.
Help with this would be much appreciated.

I am using KStep and Konnect boards with KFlop board.
KMotion435f

Laurence

Re: Halt and safe Z move

Posted: Thu Sep 30, 2021 4:50 pm
by TomKerekes
Hi Laurence,

Are you invoking this from Feedhold or Halt or ??

It might be a race condition. You should not command a Move while a Job is running and moving the Axis. The Code initiates a Feedhold and tells KMotionCNC to Halt. The DoPC Command will return after KMotionCNC has accepted the Halt Command but the Job may not have halted yet. So you might add a delay before commanding Z. Or monitor JOB_ACTIVE until it goes false with:

while (JOB_ACTIVE) ;

HTH

Re: Halt and safe Z move

Posted: Fri Oct 01, 2021 2:42 am
by axeman
Thank you Tom,
Putting in the code:

while (JOB_ACTIVE) ;

did the trick.

Cheers,
Laurence

Re: Halt and safe Z move

Posted: Fri Oct 01, 2021 8:35 pm
by axeman
Tom,
I have attached the updated, and fully operational, C program for any who may be interested.
I have placed it in the 'loop forever' section in my machines Init program to monitor for spindle thermal protection.

Also, I was wondering where I can find a list of all the functions like the JOB_ACTIVE function you provided.
I find most of these simply by searching through the various C programs that are included in the Kmotion download but is there a list with definitions available?

Regards,
Laurence

Re: Halt and safe Z move

Posted: Sat Oct 02, 2021 2:25 pm
by TomKerekes
Hi Laurence,

Thanks for posting back.

The files KMotionDef.h and PC-DSP.h list all available defines, variables, and functions for KFLOP. Note you can right click on an include file to open it in the next Thread.

HTH