Page 1 of 1

user button for taper feed on lathe / cnc compound rest

Posted: Sun Apr 12, 2020 7:56 pm
by turbothis
hey, i would like to have a user button that runs a prescribed taper that has X and Z feed variables. not position
i am not sure if this exist already or what to even call it for a search
an electronic compound rest if you will.
i can do this now by setting the jog speeds and hitting both X and Z jogs at the same time but it is not to easy to achieve the angle and kinda wonky smacking 2 buttons at once
can an executive program run this from a user button jogging?
like have a text file on the desktop with a code for a X and Z feed command?

first thing is to have input variables to set the angle. example like 12" run and 2.5" rise. (carpentry lingo)
have a master Z jog feed and then a calculator thingy/part would need to output the correct feed speeds on the X to achieve this.
this is while holding the button like jogging.

example lol

Code: Select all

#include "KMotionDef.h"

#1=[12.000]                // Z run
#2=[0.100]                 // X rise
#3=[5.0]                    // main cut feed

Taper = [#2/#1]               // how much rise to do while running, "Taper" is variable?

 main ()
{
            jog( -X F #3, +Z F(Taper) );         // use variable to set X feed speed?
}

Re: user button for taper feed on lathe / cnc compound rest

Posted: Sun Apr 12, 2020 11:01 pm
by TomKerekes
Hi turbothis,

You could Jog along an angle from a KFLOP C Program by simply commanding the X axis to Jog at one speed and the Z axis to Jog at another speed at the same time. ie:

Jog(XAXIS, xspeed);
Jog(ZAXIS, zspeed);

then to stop

Jog(XAXIS, 0.0);
Jog(ZAXIS, 0.0);

Note the motion would not be perfectly linear while accelerating or decelerating but that would be the same as your current method.

You would also need to factor in the X and Z axis resolutions as KFLOP Jog commands work in steps and steps/second.

Another issue might be that the standard User Buttons are not momentary like Jog buttons. You could have a User Button start the taper motion and then a 2nd press could stop it. If you absolutely need momentary behavior you might add a momentary button with the KMotionCNC Screen Editor to control a Virtual Bit, then have a running KFLOP C Program monitor the bit and start/stop the jogging. Of course you could also add edit controls that could be read by KFLOP to control the angle and speed.

Re: user button for taper feed on lathe / cnc compound rest

Posted: Thu Apr 06, 2023 7:54 pm
by turbothis
hey, i have been playing with chatgpt and wanted to revisit this thought.
i am not sure if the macro can be run as a G code or what would happen
i wanted to just have a keyboard button jog this so i told it "K" button

Code: Select all

; Macro for CNC lathe controller to cut at a specified angle in the X and Z-axis
; User inputs: spindle speed in RPM, angle of feed, feed speed (in inches per minute), feed Z-axis direction, feed X-axis direction

(Start of the macro)
O1000

; User input parameters
#1 = [SPINDLE_SPEED_RPM] (Spindle speed in RPM)
#2 = [ANGLE] (Angle of feed in degrees)
#3 = [FEED_SPEED_IPM] (Feed speed in inches per minute)
#4 = [Z_AXIS_DIRECTION] (Feed Z-axis direction: 1 for positive, -1 for negative)
#5 = [X_AXIS_DIRECTION] (Feed X-axis direction: 1 for positive, -1 for negative)

; Calculate incremental X and Z-axis movements
#6 = [#2 * 0.0174533] (Convert angle to radians)
#7 = [cos[#6]] (Cosine of the angle)
#8 = [sin[#6]] (Sine of the angle)
#9 = [#3 * #7 * #5] (Incremental X-axis movement)
#10 = [#3 * #8 * #4] (Incremental Z-axis movement)

; Check for valid input values
IF [ABS[#4] NE 1] GOTO 999
IF [ABS[#5] NE 1] GOTO 999

; Start spindle and set feed rate
M03 S#1 (Spindle on, clockwise, set spindle speed in RPM)
F#3 (Set feed rate in inches per minute)

; Begin cutting
(Button_Hold)
G91 G01 X#9 Z#10 (Feed at specified angle in X and Z-axis directions)
(Button_Check) (Check for "K" button release)
M00 (Hold for button release)
GOTO Button_Hold

(Button_Release)
G90 (Reset to absolute positioning)
M05 (Spindle off)
G28 (Return to home position)

M30 (End of the macro)
GOTO 1000

; Error handling
(Invalid_Input)
N999 (Invalid input values)
(End of the macro)
O1000 M99

Re: user button for taper feed on lathe / cnc compound rest

Posted: Sat Apr 08, 2023 2:11 am
by TomKerekes
Not sure what you’re asking, but the Interpreter doesn’t have ‘if’ or ‘goto’ statements. You might look at the GCode examples such as SubroutineWithConditionals.ngc.

Re: user button for taper feed on lathe / cnc compound rest

Posted: Thu Apr 13, 2023 7:04 pm
by turbothis
great, i will
thanks