M6 TXXXX QYY

Moderators: TomKerekes, dynomotion

Post Reply
cemoa9
Posts: 82
Joined: Mon Jun 01, 2020 11:01 am

M6 TXXXX QYY

Post by cemoa9 » Fri May 27, 2022 11:10 am

Hello Tom,

For cycle time improvement I would like to change my M6 code to have not only the tool changed but also the A axis moved (rotary table), does M6 support a second parameter?

Cordially,

Francois

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

Re: M6 TXXXX QYY

Post by TomKerekes » Fri May 27, 2022 4:19 pm

Hi Francois,

No it doesn't. You could use a dummy M Code to first pass some parameters. ie

M100 Pxxx Qyyy Rzzz
M6 Txxx
Regards,

Tom Kerekes
Dynomotion, Inc.

cemoa9
Posts: 82
Joined: Mon Jun 01, 2020 11:01 am

Re: M6 TXXXX QYY

Post by cemoa9 » Tue May 31, 2022 12:45 pm

Hello Tom,

Thanks it works, but I kinda got an issue while reading DROs, sometimes GetDROs(...) is not getting updated and the value of the previous movement is shown in the console. I use the latest version of KMotionCNC.

here is the code :

double DROx, DROy, DROz, DROa, DROb, DROc, OffsetZ;
GetDROs(&DROx, &DROy, &DROz, &DROa, &DROb, &DROc);
printf("DROa = %f\n", DROa);

It happened twice, DRO was 0 on KMotionCNC, but appeared as 90 in the console, causing a wrong rotary table movement (no crash :) )

Cordially,

Francois

cemoa9
Posts: 82
Joined: Mon Jun 01, 2020 11:01 am

Re: M6 TXXXX QYY

Post by cemoa9 » Tue May 31, 2022 2:11 pm

Hello Tom,

I just tried using MDI(s) command, there also I have a problem, the command will only work randomly :

WaitNextTimeSlice();
char s[80];
float Angle = *(float *)&persist.UserData[TMP];
Angle = 10; // just for trial to have a fix value
sprintf(s,"G0 A%f", Angle);
MDI(s);

I may need to run it 20 times to have it moving.

I am using a very slow computer (cheap win10 tablet), may that be the issue?

Edit : I added a delay of 0.01s in the init program in the forever loop, it seems to have solved the MDI issue, but it does not feel safe...

Cordially,

Francois

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

Re: M6 TXXXX QYY

Post by TomKerekes » Tue May 31, 2022 5:17 pm

The communication to KMotionCNC is not Thread safe. That is if two Threads send a command at the same time then commands can be dropped or results mixed up.

If your forever loop is issuing commands then one solution is to have the other Thread tell the forever loop to issue the command rather than doing the command itself.

HTH
Regards,

Tom Kerekes
Dynomotion, Inc.

Post Reply