MPG for positioning and FRO control

Moderators: TomKerekes, dynomotion

gui_marchioro
Posts: 59
Joined: Sun Aug 21, 2022 11:22 pm

Re: MPG for positioning and FRO control

Post by gui_marchioro » Thu Aug 17, 2023 11:30 pm

Hello,

I've done the test using a default screen, but still without success :(



So, I'm still looking for a solution. Please let me know if there is anything else I could do.

Sincerely,
Guilherme

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

Re: MPG for positioning and FRO control

Post by TomKerekes » Fri Aug 18, 2023 12:52 am

Hi Guilherme,

Please post your Initialization C Program which calls ChangeFROAndRRO() etc.
Regards,

Tom Kerekes
Dynomotion, Inc.

gui_marchioro
Posts: 59
Joined: Sun Aug 21, 2022 11:22 pm

Re: MPG for positioning and FRO control

Post by gui_marchioro » Sat Aug 19, 2023 3:35 pm

Hello Tom,

Ok. Here is a simplified version from the code that is in my machine, having just MPG service attached to the initialization's infinite loop.

Sincerely,
Guilherme
Attachments
MPG_test.zip
(48.42 KiB) Downloaded 15 times

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

Re: MPG for positioning and FRO control

Post by TomKerekes » Sun Aug 20, 2023 9:13 pm

Hi Guilherme,

I think I see the issue.

Code: Select all

DoPCFloat(PC_COMM_SET_FRO,FRO);
is called before it has been defined and passes the FRO as a double where the function is expecting a float.

The includes are in this order:

Code: Select all

#include "KMotionDef.h"
#include "InitConfig.c"
#include "MPGWatch.c"
#ifndef TMP
#define TMP 10 // which spare persist to use to transfer data
#include "KflopToKMotionCNCFunctions.c"
#endif
MPGWatch.c calls DoPCFloat before KflopToKMotionCNCFunctions.c has been included.

The standard TCC67 compiler is very fast but not great at giving warnings. If you check the TI Compiler (right click) it will flag these errors. It reports:

"C:\KMotion435h\C Programs\MPG_test\MPGWatch.c", line 113: warning: missing return statement at end of non-void function "EvaluateSelectedAxis"
"C:\KMotion435h\C Programs\MPG_test\MPGWatch.c", line 143: warning: function declared implicitly
"C:\KMotion435h\C Programs\MPG_test\MPGWatch.c", line 120: warning: variable "LastUpdateEncoder" was declared but never referenced
"C:\KMotion435h\C Programs\MPG_test\MPGWatch.c", line 164: warning: function declared implicitly
"C:\KMotion435h\C Programs\MPG_test\MPGWatch.c", line 246: warning: last line of file ends without a newline
"C:\KMotion435h\C Programs\KflopToKMotionCNCFunctions.c", line 4: error: declaration is incompatible with previous "DoPCFloat" (declared at line 143 of "C:\KMotion435h\C Programs\MPG_test\MPGWatch.c")
"C:\KMotion435h\C Programs\MPG_test\InitConfigButtonAction.c", line 23: warning: last line of file ends without a newline
1 error detected in the compilation of "C:\KMotion435h\C Programs\MPG_test\InitConfigButtonAction.c".

>> Compilation failure


Please correct this and try again.
HTH
Regards,

Tom Kerekes
Dynomotion, Inc.

gui_marchioro
Posts: 59
Joined: Sun Aug 21, 2022 11:22 pm

Re: MPG for positioning and FRO control

Post by gui_marchioro » Thu Aug 24, 2023 11:48 pm

Hello,

Thanks a lot Tom, this finally solved my problem!!

Nice tip about the TI compiler.

Sincerely,
Guilherme

gui_marchioro
Posts: 59
Joined: Sun Aug 21, 2022 11:22 pm

Re: MPG for positioning and FRO control

Post by gui_marchioro » Sun Sep 03, 2023 4:16 pm

Hello,

Tom, I tried to use the incremental mode to set FRO and RRO intending to have some sync with the values commanded by the UI, but I got an issue when commanding the multiplier to a value less than 0.1.

I thought that KMotionCNC would block the value, but what happens is that it lets the value go less than the limit, and when I try to raise the number again it blocks stating that the value should be greater than 0.1.

To be able to command the values again via the MPG controller I needed to change the multiplier via the UI.

That being said, is it possible to keep track of the multipliers (FRO and RRO) written in the UI, so that I can block the command via code when reaching near that limit?

Or, do you see any other alternative to synchronize the values commanded via MPG and the values coming from the UI?

The current code that handles the MPG is attached. BasicServiceMPG() is called in the infinite loop from the init program. ChangeFROAndRRO() is the function to handle the incremental set of FRO and RRO. I am using version 4.35h from KMotionCNC.

Sincerely,
Guilherme
Attachments
MPGWatch.c
(6.53 KiB) Downloaded 16 times

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

Re: MPG for positioning and FRO control

Post by TomKerekes » Sun Sep 03, 2023 7:02 pm

Hi Guilherme,

Please post your include files.
Regards,

Tom Kerekes
Dynomotion, Inc.

gui_marchioro
Posts: 59
Joined: Sun Aug 21, 2022 11:22 pm

Re: MPG for positioning and FRO control

Post by gui_marchioro » Mon Sep 04, 2023 2:11 am

Hello,

Find attached my source files. InitConfigButtonAction.c contains the program that runs when the Init button is pressed, and MPGWatch.c contains MPG related code.

Sincerely,
Guilherme
Attachments
source_files.zip
(27.69 KiB) Downloaded 14 times

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

Re: MPG for positioning and FRO control

Post by TomKerekes » Tue Sep 05, 2023 2:06 am

Hi Guilherme,

CS0_LastFRO and CS0_LastRapidFRO can be used as the last commanded Hardware FROs. The code below seems to work for preventing below 0.1. But I don't have a proper solution for above 1.0. Do you wish to allow FRO or RRO above 1.0? If no you could also limit changes above 1.0. Do you wish to use Software FRO?

Code: Select all

    if ((Encoder > CHANGE_TOL || Encoder < -CHANGE_TOL) && T > LastTime+CHANGE_TIME)
    {
        incrementFactorFRO = (Encoder > 0) ? 1.1 : 0.9;
        if (CS0_LastFRO * incrementFactorFRO < 0.1)incrementFactorFRO = CS0_LastFRO/0.1;
        printf("FRO increment factor: %f. MPGWatch.c.\n", incrementFactorFRO);
        DoPCFloat(PC_COMM_SET_FRO_INC, incrementFactorFRO);
        
        incrementFactorRRO = (Encoder > 0) ? 1.1 : 0.9;
        if (CS0_LastRapidFRO * incrementFactorRRO < 0.1)incrementFactorRRO = CS0_LastRapidFRO/0.1;

        printf("RRO increment factor: %f. MPGWatch.c.\n", incrementFactorRRO);
        DoPCFloat(PC_COMM_SET_RRO_INC, incrementFactorRRO);    
        
        LastTime=T;
        Encoder = 0;
    }
Regards,

Tom Kerekes
Dynomotion, Inc.

gui_marchioro
Posts: 59
Joined: Sun Aug 21, 2022 11:22 pm

Re: MPG for positioning and FRO control

Post by gui_marchioro » Tue Sep 05, 2023 11:25 pm

Hello Tom,

Thanks for the response. I'll try it on my machine using these variables you mentioned to keep track of FRO and RRO, also adding a limit in the positive end at 1.0.

I'm not sure about the difference between software and hardware FRO. My intent is to have sync between UI, and MPG FRO and RRO commands.

Sincerely,
Guilherme

Post Reply