Halt and safe Z move

Moderators: TomKerekes, dynomotion

Post Reply
axeman
Posts: 15
Joined: Thu Jan 25, 2018 2:40 am

Halt and safe Z move

Post by axeman » Wed Sep 29, 2021 11:15 pm

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
Attachments
SafeZ_SpindleOff_Thermal_Protect.c
(610 Bytes) Downloaded 57 times

User avatar
TomKerekes
Posts: 2529
Joined: Mon Dec 04, 2017 1:49 am

Re: Halt and safe Z move

Post by TomKerekes » Thu Sep 30, 2021 4:50 pm

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
Regards,

Tom Kerekes
Dynomotion, Inc.

axeman
Posts: 15
Joined: Thu Jan 25, 2018 2:40 am

Re: Halt and safe Z move

Post by axeman » Fri Oct 01, 2021 2:42 am

Thank you Tom,
Putting in the code:

while (JOB_ACTIVE) ;

did the trick.

Cheers,
Laurence

axeman
Posts: 15
Joined: Thu Jan 25, 2018 2:40 am

Re: Halt and safe Z move

Post by axeman » Fri Oct 01, 2021 8:35 pm

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
Attachments
SafeZ_SpindleOff_Thermal_Protect.c
(803 Bytes) Downloaded 61 times

User avatar
TomKerekes
Posts: 2529
Joined: Mon Dec 04, 2017 1:49 am

Re: Halt and safe Z move

Post by TomKerekes » Sat Oct 02, 2021 2:25 pm

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
Regards,

Tom Kerekes
Dynomotion, Inc.

Post Reply