G32 sync spindle to Z axis lathe

Moderators: TomKerekes, dynomotion

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

Re: G32 sync spindle to Z axis lathe

Post by TomKerekes » Mon Aug 12, 2019 7:05 pm

Hi turbothis,
how do i zero ch2 in the AXIS tab in kmotion
You might click Zero on the Step Response Screen or Zero2 on the console.
i run the spindle as the rotary axis for 3600 degrees (100 spins)
Wouldn't that be 10 revs?
it shows about 6 degrees extra.
That's bad. What is your counts/degree setting in KMotionCNC | Tool Setup | Trajectory Planner | Axis Parameters | A axis?

What were the counts before and after the move?
of course i cant count the 100 spins to make sure that happened though
why not move slow so you can?
Regards,

Tom Kerekes
Dynomotion, Inc.

turbothis
Posts: 309
Joined: Fri Mar 15, 2019 4:07 pm
Location: southern oregon

Re: G32 sync spindle to Z axis lathe

Post by turbothis » Mon Aug 12, 2019 7:11 pm

ok
i "zero2" on the console
spin the spindle by hand 100 times (lame)
i get 1183285 on the pointer i have clamped on the lathe

A axis is 32.97907 counts/deg
should be 32.86911 right?
ok 10 and 100 spins shows right on the mark!

i still think having the G32 start on the servo and not the spindle might be the trouble
if the G32 would only start on the same servo and spindle sync position then it would be working.
very much like EFI in a car having a cam sensor for sequential fuel injection to indicate where the in the cycle the crank is

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

Re: G32 sync spindle to Z axis lathe

Post by TomKerekes » Mon Aug 12, 2019 7:50 pm

Hi turbothis,
ok
i "zero2" on the console
spin the spindle by hand 100 times (lame)
i get 1183285 on the pointer i have clamped on the lathe
seems our number is correct and encoder working correctly.

should be 32.86911 right?
actually should be 32.8691358

i still think having the G32 start on the servo and not the spindle might be the trouble
if the G32 would only start on the same servo and spindle sync position then it would be working.
very much like EFI in a car having a cam sensor for sequential fuel injection to indicate where the in the cycle the crank is
I don't understand why it would be necessary.

Please post a screen shot of all your Trajectory Planner settings so we can check them.

Also post the GCode you are using.

Do you see a slight pause before each Threading Pass?

You might also run the GCode while rotating the Spindle manually by hand and observe that the Z motion begins each pass when the Spindle is at the same angular position.
Regards,

Tom Kerekes
Dynomotion, Inc.

turbothis
Posts: 309
Joined: Fri Mar 15, 2019 4:07 pm
Location: southern oregon

Re: G32 sync spindle to Z axis lathe

Post by turbothis » Mon Aug 12, 2019 8:49 pm

it does look to get in position/ pause and then start threads

Image

Code: Select all

N158 G00 X0.3 Z0.02 

(thread )

N163 M04 S500  
     g04 p4
N164 X0.285 Z0.02 
N165 X0.235 Z0.02 
N166 G01 X0.228 Z0.02 F0.0492 
N167 G32 X0.228 Z-0.45 
N168 G00 X0.285 Z-0.45 G95 
N169 X0.285 Z0.02 
N170 X0.235 Z0.02 
N171 G01 X0.2252 Z0.02 F0.0492 
N172 G32 X0.2252 Z-0.45 
N173 G00 X0.285 Z-0.45 G95 
N174 X0.285 Z0.02 
N175 X0.235 Z0.02 
N176 G01 X0.223 Z0.02 F0.0492 
N177 G32 X0.223 Z-0.45 
N178 G00 X0.285 Z-0.45 G95 
N179 X0.285 Z0.02 
N180 X0.235 Z0.02 
N181 G01 X0.2211 Z0.02 F0.0492 
N182 G32 X0.2211 Z-0.45 
N183 G00 X0.285 Z-0.45 G95 
N184 X0.285 Z0.02 
N185 X0.235 Z0.02 
N186 G01 X0.2194 Z0.02 F0.0492 
N187 G32 X0.2194 Z-0.45 
N188 G00 X0.285 Z-0.45 G95 
N189 X0.285 Z0.02 
N190 X0.235 Z0.02 
N191 G01 X0.218 Z0.02 F0.0492 
N192 G32 X0.218 Z-0.45 
N193 G00 X0.285 Z-0.45 G95 
N194 X0.285 Z0.02 
N195 X0.235 Z0.02 
N196 G01 X0.2166 Z0.02 F0.0492 
N197 G32 X0.2166 Z-0.45 
N198 G00 X0.285 Z-0.45 G95 
N199 X0.285 Z0.02 
N200 X0.235 Z0.02 
N201 G01 X0.2153 Z0.02 F0.0492 
N202 G32 X0.2153 Z-0.45 
N203 G00 X0.285 Z-0.45 G95 
N204 X0.285 Z0.02 
N205 X0.235 Z0.02 
N206 G01 X0.2141 Z0.02 F0.0492 
N207 G32 X0.2141 Z-0.45 
N208 G00 X0.285 Z-0.45 G95 
N209 X0.285 Z0.02 
N210 X0.235 Z0.02 
N211 G01 X0.213 Z0.02 F0.0492 
N212 G32 X0.213 Z-0.45 
N213 G00 X0.285 Z-0.45 G95 
N214 X0.285 Z0.02 
N215 X0.235 Z0.02 
N216 G01 X0.213 Z0.02 F0.0492 
N217 G32 X0.213 Z-0.45 
N218 G00 X0.285 Z-0.45 G95 
N219 X0.285 Z0.02 
N220 X0.235 Z0.02 
N221 G01 X0.213 Z0.02 F0.0492 
N222 G32 X0.213 Z-0.45 
N223 G00 X0.285 Z-0.45 G95 
N224 X0.285 Z0.02 
N225 X0.235 Z0.02 
N226 G01 X0.213 Z0.02 F0.0492 
N227 G32 X0.213 Z-0.45 
N228 G00 X0.285 Z-0.45 G95 
N229 X0.285 Z0.02 
N230 X0.3 Z0.0 M05 M09
N233 M30 

turbothis
Posts: 309
Joined: Fri Mar 15, 2019 4:07 pm
Location: southern oregon

Re: G32 sync spindle to Z axis lathe

Post by turbothis » Mon Aug 12, 2019 9:33 pm

a lot of times when i push cycle start, one line of code will pass and then it sits there doing nothing but counting time and thinking it is running.
when i pause and cycle stop then hit start again, off it goes....... :?

turbothis
Posts: 309
Joined: Fri Mar 15, 2019 4:07 pm
Location: southern oregon

Re: G32 sync spindle to Z axis lathe

Post by turbothis » Mon Aug 12, 2019 10:16 pm

what thread/var should i have for spindle jog?

Image

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

Re: G32 sync spindle to Z axis lathe

Post by TomKerekes » Mon Aug 12, 2019 11:37 pm

Hi turbothis,

I think I see the issue. In the GCode the G95 causes the Spindle Synchronization to occur before the X plunge instead of after. Because the X plunge distance varies the Z threading pass is then shifted. I don't see why the X plunge should be synchronized or at a feed per rev mode. Please try the GCode below.

Code: Select all

N158 G00 X0.3 Z0.02 

(thread )

N163 M04 S500  
     g04 p4
N164 X0.285 Z0.02 
N165 X0.235 Z0.02 
N166 G01 F10 X0.228 Z0.02 
N167 G32 F0.0492 X0.228 Z-0.45 
N168 G00 X0.285 Z-0.45 
N169 X0.285 Z0.02 
N170 X0.235 Z0.02 
N171 G01 F10 X0.2252 Z0.02 
N172 G32 F0.0492 X0.2252 Z-0.45 
N173 G00 X0.285 Z-0.45 
N174 X0.285 Z0.02 
N175 X0.235 Z0.02 
N176 G01 F10 X0.223 Z0.02 
N177 G32 F0.0492 X0.223 Z-0.45 
N178 G00 X0.285 Z-0.45 
N179 X0.285 Z0.02 
N180 X0.235 Z0.02 
N181 G01 F10 X0.2211 Z0.02 
N182 G32 F0.0492 X0.2211 Z-0.45 
N183 G00 X0.285 Z-0.45 
N184 X0.285 Z0.02 
N185 X0.235 Z0.02 
N186 G01 F10 X0.2194 Z0.02 
N187 G32 F0.0492 X0.2194 Z-0.45 
N188 G00 X0.285 Z-0.45 
N189 X0.285 Z0.02 
N190 X0.235 Z0.02 
N191 G01 F10 X0.218 Z0.02 
N192 G32 F0.0492 X0.218 Z-0.45 
N193 G00 X0.285 Z-0.45 
N194 X0.285 Z0.02 
N195 X0.235 Z0.02 
N196 G01 F10 X0.2166 Z0.02 
N197 G32 F0.0492 X0.2166 Z-0.45 
N198 G00 X0.285 Z-0.45 
N199 X0.285 Z0.02 
N200 X0.235 Z0.02 
N201 G01 F10 X0.2153 Z0.02 
N202 G32 F0.0492 X0.2153 Z-0.45 
N203 G00 X0.285 Z-0.45 
N204 X0.285 Z0.02 
N205 X0.235 Z0.02 
N206 G01 F10 X0.2141 Z0.02 
N207 G32 F0.0492 X0.2141 Z-0.45 
N208 G00 X0.285 Z-0.45 
N209 X0.285 Z0.02 
N210 X0.235 Z0.02 
N211 G01 F10 X0.213 Z0.02 
N212 G32 F0.0492 X0.213 Z-0.45 
N213 G00 X0.285 Z-0.45 
N214 X0.285 Z0.02 
N215 X0.235 Z0.02 
N216 G01 F10 X0.213 Z0.02 
N217 G32 F0.0492 X0.213 Z-0.45 
N218 G00 X0.285 Z-0.45 
N219 X0.285 Z0.02 
N220 X0.235 Z0.02 
N221 G01 F10 X0.213 Z0.02 
N222 G32 F0.0492 X0.213 Z-0.45 
N223 G00 X0.285 Z-0.45 
N224 X0.285 Z0.02 
N225 X0.235 Z0.02 
N226 G01 F10 X0.213 Z0.02 
N227 G32 F0.0492 X0.213 Z-0.45 
N228 G00 X0.285 Z-0.45 
N229 X0.285 Z0.02 
N230 X0.3 Z0.0 M05 M09
N233 M30 
what thread/var should i have for spindle jog?
You should be able to set the M3, M4, M5, S actions to Exec/wait and use the same Thread for them all (ie 2). Not sure why you are putting 3 on your desktop and the other in a different folder. Better to put them all the same place to share the same MySpindleDefs.h header.
Regards,

Tom Kerekes
Dynomotion, Inc.

turbothis
Posts: 309
Joined: Fri Mar 15, 2019 4:07 pm
Location: southern oregon

Re: G32 sync spindle to Z axis lathe

Post by turbothis » Tue Aug 13, 2019 12:29 am

yes!!!!
much better
that is just what my half ass post processor prints out for me to deal with
honestly i dont have enough experience to tell it was bad from the start
i think from here out i will just hand code the G32 as this seems simpler and more accurate
so this is the basic G32 block then

Code: Select all

N168 G00 X0.285 Z-0.45          (clear plane)
N169 X0.285 Z0.02               (IN POSITION)
N170 X0.235 Z0.02               (in)
N171 G01 F10 X0.225 Z0.02       (feed in)
N172 G32 F0.0492 X0.225 Z-0.45  (cut)

any reason to not simplify like this....

Code: Select all

N168 G00 X0.285 Z-0.45          (clear plane)
N169  Z0.02                  (IN POSITION)
N170 X0.235                      (in)
N171 G01 F10 X0.225             (feed in)
N172 G32 F0.0492   Z-0.45  (cut)

turbothis
Posts: 309
Joined: Fri Mar 15, 2019 4:07 pm
Location: southern oregon

Re: G32 sync spindle to Z axis lathe

Post by turbothis » Tue Aug 13, 2019 4:48 pm

with the more accurate counts/degree and counts/rev on the traj planner is this still good?

#define FACTOR (118724.6/60.0)

Code: Select all

#include "KMotionDef.h"

#define SPINDLEAXIS 2
#define FACTOR (118724.6/60.0) //1000 counts/sec / 1000 counts/rev = 1 RPS = 60 RPM
#define SPINDLECW_BIT 154
#define SPINDLECCW_BIT 155
#define SPEEDVAR 99
#define STATEVAR 98
#define KMVAR 1


// desired speed is passed from KMotionCNC in variable KMVAR
// save in user variable STATEVAR whether it was off, CW, or CCW (0,1,-1)
// save in user variable SPEEDVAR the last desired speed

main()
{
	// spin down
	
	ClearBit(SPINDLECW_BIT);
	ClearBit(SPINDLECCW_BIT);
	Jog(SPINDLEAXIS,0);
	printf("Jogging Spindle Stop\n");
	persist.UserData[STATEVAR] = 0;  // remember we are Off
	while (!CheckDone(SPINDLEAXIS)) ;
	DisableAxis(SPINDLEAXIS);
}


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

Re: G32 sync spindle to Z axis lathe

Post by TomKerekes » Tue Aug 13, 2019 5:40 pm

Hi turbothis,
yes!!!!
much better
Great!

any reason to not simplify like this....
Not that I can see. Except sloppy with spaces :)

You might use variables and a subroutine to create all the passes easily using parameters. See the Polygon.ngc for an example.

with the more accurate counts/degree and counts/rev on the traj planner is this still good?

#define FACTOR (118724.6/60.0)
That value should be corrected also. Although a slight error in commanded speed is not likely to be noticable.
Regards,

Tom Kerekes
Dynomotion, Inc.

Post Reply