MPG for positioning and FRO control
Moderators: TomKerekes, dynomotion
-
- Posts: 59
- Joined: Sun Aug 21, 2022 11:22 pm
MPG for positioning and FRO control
Hello everyone,
I am configuring the interface of KFLOP and an MPG controller (wiring scheme attached) and I would like to know if there is any example of C program where:
- when the Control switch is pressed the encoder control axis position.
- when the Control switch is released the encoder control FRO.
Thanks,
Guilherme
I am configuring the interface of KFLOP and an MPG controller (wiring scheme attached) and I would like to know if there is any example of C program where:
- when the Control switch is pressed the encoder control axis position.
- when the Control switch is released the encoder control FRO.
Thanks,
Guilherme
- TomKerekes
- Posts: 2679
- Joined: Mon Dec 04, 2017 1:49 am
Re: MPG for positioning and FRO control
Hi Guilherme,
No I'm not aware of such a C program.
When the Control Switch is released you might accumulate the Position changes in a variable and then periodically use that to change the FRO. You might see the SetFROwithPot.c example for something similar.
It can be tricky how to handle when on-screen controls can change things as well as external things. So you need to decide how to handle two things setting the same thing. Do you want both to be active? Maybe use PC_COMM_SET_FRO_INC to just increment and decrement the On-Screen FRO instead of setting it.
HTH
No I'm not aware of such a C program.
When the Control Switch is released you might accumulate the Position changes in a variable and then periodically use that to change the FRO. You might see the SetFROwithPot.c example for something similar.
It can be tricky how to handle when on-screen controls can change things as well as external things. So you need to decide how to handle two things setting the same thing. Do you want both to be active? Maybe use PC_COMM_SET_FRO_INC to just increment and decrement the On-Screen FRO instead of setting it.
HTH
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
Re: MPG for positioning and FRO control
Hello Guilherme,
You can check the init file of my Mazak or Stama, they have similar function. (available on the forum in the machines presentation)
Cordially,
Francois
You can check the init file of my Mazak or Stama, they have similar function. (available on the forum in the machines presentation)
Cordially,
Francois
-
- Posts: 59
- Joined: Sun Aug 21, 2022 11:22 pm
Re: MPG for positioning and FRO control
Hello,
Thanks for the responses Francois and Tom.
Francois I've looked in your files and also in the example SetFROwithHWEncoderLog.c to base my MPG program.
The problem is that when I call DoPCFloat(PC_COMM_SET_FRO, FRO) or DoPCFloat(PC_COMM_SET_FRO_INC, FRO) nothing seems to happen.
There is another command required to make it work?
Here is a sample of my code to control both FRO and RRO at the same time:
Sincerely,
Guilherme
Thanks for the responses Francois and Tom.
Francois I've looked in your files and also in the example SetFROwithHWEncoderLog.c to base my MPG program.
The problem is that when I call DoPCFloat(PC_COMM_SET_FRO, FRO) or DoPCFloat(PC_COMM_SET_FRO_INC, FRO) nothing seems to happen.
There is another command required to make it work?
Here is a sample of my code to control both FRO and RRO at the same time:
Code: Select all
void ChangeFROAndRRO()
{
static double T;
static int FirstTime=TRUE;
static double LastFRO=1, LastTime=0, LastRRO=1, LastEncoder=0,
LastUpdateEncoder=1e30, Encoder=0, FRO=1, incrementFactorFRO=1, increment=0,
RRO=1, incrementFactorRRO=1;
// Initializes the position of the MPG encoder in the first execution.
if (FirstTime)
{
LastEncoder = chan[MPG_INPUT_AXIS].Position;
}
T = WaitNextTimeSlice();
Encoder += (chan[MPG_INPUT_AXIS].Position - LastEncoder); // accumulate changes
LastEncoder = chan[MPG_INPUT_AXIS].Position;
if ((Encoder > CHANGE_TOL || Encoder < -CHANGE_TOL) && T > LastTime+CHANGE_TIME)
{
increment = (Encoder > 0) ? 0.1 : -0.1;
FRO = LastFRO + increment;
if (FRO > FRO_MAX) FRO=FRO_MAX;
if (FRO < FRO_MIN) FRO=FRO_MIN;
incrementFactorFRO = 1 + ((FRO - LastFRO)/LastFRO);
LastFRO = FRO;
printf("FRO: %f, incrementFactor: %f, increment: %f. MPGWatch.c.\n", FRO, incrementFactorFRO, increment);
DoPCFloat(PC_COMM_SET_FRO, FRO);
RRO = LastRRO + increment;
if (RRO > RRO_MAX || FRO >= RRO_MAX) RRO=RRO_MAX;
if (RRO < RRO_MIN) RRO=RRO_MIN;
incrementFactorRRO = 1 + ((RRO - LastRRO)/LastRRO);
LastRRO = RRO;
printf("RRO: %f, incrementFactor: %f, increment: %f. MPGWatch.c.\n", RRO, incrementFactorRRO, increment);
DoPCFloat(PC_COMM_SET_RRO, RRO);
LastTime=T;
Encoder = 0;
}
}
Guilherme
- TomKerekes
- Posts: 2679
- Joined: Mon Dec 04, 2017 1:49 am
Re: MPG for positioning and FRO control
Hi Guilherme,
FirstTime is not being set FALSE so it reinitializes every time
FirstTime is not being set FALSE so it reinitializes every time
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
-
- Posts: 59
- Joined: Sun Aug 21, 2022 11:22 pm
Re: MPG for positioning and FRO control
Hi,
Sharp eyes Tom! Thanks for the review.
I added the variable's reset, but still FRO and RRO are not being changed.
Here is a video showing how it is working:
It is just a test program containing G0 and G1 statements to assess if speed changes. While I spin the MPG's encoder notice that FRO and RRO variables change as expected (the values are being printed in the console), but the speed in the machine didn't.
Is there something else that I could be missing?
Sincerely,
Guilherme
Sharp eyes Tom! Thanks for the review.
I added the variable's reset, but still FRO and RRO are not being changed.
Here is a video showing how it is working:
It is just a test program containing G0 and G1 statements to assess if speed changes. While I spin the MPG's encoder notice that FRO and RRO variables change as expected (the values are being printed in the console), but the speed in the machine didn't.
Is there something else that I could be missing?
Sincerely,
Guilherme
- TomKerekes
- Posts: 2679
- Joined: Mon Dec 04, 2017 1:49 am
Re: MPG for positioning and FRO control
Hi Guilherme,
Sorry I can't duplicate the problem.
Note the video shows a G0 move while the screen is displaying Feed Override. But the FRO slider should still move regardless.
Please post your entire program(s). Also post your Tool Setup - Trajectory Planner settings.
Maybe it has to do with your custom Screen. Temporarily switch to Resizable 3 Axis to check if the problem exists.
What Version are you running?
Sorry I can't duplicate the problem.
Note the video shows a G0 move while the screen is displaying Feed Override. But the FRO slider should still move regardless.
Please post your entire program(s). Also post your Tool Setup - Trajectory Planner settings.
Maybe it has to do with your custom Screen. Temporarily switch to Resizable 3 Axis to check if the problem exists.
What Version are you running?
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
-
- Posts: 59
- Joined: Sun Aug 21, 2022 11:22 pm
Re: MPG for positioning and FRO control
Hello Tom,
I am running on version 4.35h.
Here is the MPG program, my custom screen, and my configurations. I call BasicServiceMPG() method in the infinite loop from initialization program.
I will check if the problem persists when using the default screen you mentioned.
Sincerely,
Guilherme
I am running on version 4.35h.
Here is the MPG program, my custom screen, and my configurations. I call BasicServiceMPG() method in the infinite loop from initialization program.
I will check if the problem persists when using the default screen you mentioned.
Sincerely,
Guilherme
- Attachments
-
- 3AxisEdit_004_traduzido.scr
- (61.88 KiB) Downloaded 232 times
-
- MPGWatch.c
- (7.28 KiB) Downloaded 234 times
-
- GCodeConfigCNC.txt
- (23.14 KiB) Downloaded 232 times
- TomKerekes
- Posts: 2679
- Joined: Mon Dec 04, 2017 1:49 am
Re: MPG for positioning and FRO control
Still not setting FirstTime to FALSE.
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
-
- Posts: 59
- Joined: Sun Aug 21, 2022 11:22 pm
Re: MPG for positioning and FRO control
Hello,
You are right. I posted an out of date version of the file, sorry.
In the video I tested with the right one. File is attached.
Sincerely,
Guilherme
You are right. I posted an out of date version of the file, sorry.
In the video I tested with the right one. File is attached.
Sincerely,
Guilherme
- Attachments
-
- MPGWatch.c
- (7.3 KiB) Downloaded 234 times