Button name

Moderators: TomKerekes, dynomotion

Tarasevih
Posts: 101
Joined: Fri Jul 09, 2021 11:26 am

Re: Button name

Post by Tarasevih » Fri Jul 23, 2021 11:42 am

Hi Tom. Are you resting now?

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

Re: Button name

Post by TomKerekes » Fri Jul 23, 2021 3:10 pm

Hi Taras,

Sorry for the delay we made some changes to facilitate doing this and to make other things easier. Unfortunately it involved quite a few changes.


Here is the result:
RTCP ON.png
RTCP ON.png (1.73 KiB) Viewed 1051 times
RTCP OFF.png
RTCP OFF.png (1.79 KiB) Viewed 1051 times


A new command was added to read the Tool Number and ID from the currently selected tool table entry.

KflopToKMotionCNCFunctions.c added GetToolSlotAndID(int *Slot, int *ID)
PC_DSP.h PC_COMM_GET_TOOL_SLOT_ID added

Host Status updated in KFLOP now has a new status whether RTCP is currently active HOST_RTCP_ACTIVE_BIT. RTCP_ACTIVE defined in KMotionDef.h to access that bit.
KMotionDef.h
KMotionCNCDlg.cpp

Screen Scripts now allow Control definitions to be incomplete (missing parameters) and allows parameters in any order to make it simpler to change Text or Colors of controls. Unspecified parameters will be left unchanged. Controls will now be redrawn whenever their text changes.
KMotionCNC.exe
Unibutton.h
Screen.cpp

For example ChangeRTCPon.scr contains

Code: Select all

SubScript
ID:IDC_But11,Bold:1,Colors:0;00FF00;;,Text:RTCP ON
and ChangeRTCPoff.scr contains

Code: Select all

SubScript
ID:IDC_But11,Bold:1,Colors:0;FF8000;;,Text:RTCP OFF
An example Screen RTCP.scr has a button IDC_But11 for displaying RTCP Status and with an Action when pushed to change RTCP State by setting Virtual Bit 1200.
RTCP.scr



KFLOP C Program example to continuously update Button status and to change RTCP state when requested by Virtual Bit 1200

UpdateRTCP_State.c

Code: Select all

#include "KMotionDef.h"
#define TMP 10 // which spare persist to use to transfer data
#include "KflopToKMotionCNCFunctions.c"

// Displays RTCP mode status as a button text and color
//
// Monitors RTCP mode as part of HostStatus and executes 
// Screen SubScript to change text and color of a button
//
// Also looks for a command (Virtual bit 1200) as a request
// to toggle the mode. If command is detected we request the
// current Tool Number and MDI a G43.4Hn for that tool number
// to turn RTCP on for that tool.
 
void UpdateRTCP(void);

main()
{
	for (;;)
	{
		WaitNextTimeSlice();
		UpdateRTCP();
	}
}

#define ToggleRTCP_BIT 1200 // Set by Button to toggle mode
#define RTCP_UPDATE_TIME 2 // update every 2 sec in case out of sync

void UpdateRTCP(void)
{
	static double LastT=0;
	static int PrevRTCP=-1;
	
	int Slot, ID, HWORD;
	char s[80];


	if (ReadBit(ToggleRTCP_BIT))  // Toggle request
	{
		ClearBit(ToggleRTCP_BIT);  // clear command
		
		if (RTCP_ACTIVE)
		{
			printf("G49\n");
			MDI("G49");  // turn it off
		}
		else
		{
			GetToolSlotAndID(&Slot, &ID); // Get currently selected tool
			printf("Slot = %d ID = %d\n",Slot, ID);
			if (Slot == 0) HWORD=ID; else HWORD=Slot;
			sprintf(s,"G43.4 H%d",HWORD);
			printf("%s\n",s);
			MDI(s);  // turn it on
		}
	}
	
	// if mode changed or has been a while update button
	if (RTCP_ACTIVE != PrevRTCP || Time_sec() > LastT)
	{
		LastT = Time_sec() + RTCP_UPDATE_TIME;
		PrevRTCP = RTCP_ACTIVE;
		if (PrevRTCP)
		{
			printf("ON\n");
			ScreenScript("SScript:ChangeRTCPon.scr");
		}
		else
		{
			printf("OFF\n");
			ScreenScript("SScript:ChangeRTCPoff.scr");
		}
	}
}
Patched files for Version 4,35f are located here.

Please download and copy over existing files. Let us know if you have questions or any issues.


HTH
Regards,

Tom Kerekes
Dynomotion, Inc.

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

Re: Button name

Post by TomKerekes » Fri Jul 23, 2021 3:16 pm

Hi Taras,
I also noticed this problem. If RTCP is turned off and I turn it on G43.4H1, the position of the Z axis becomes - the length of the tool. If this happens during the execution of the G code, then the zero of the workpiece will move lower by the length of the cutter and machining will continue above the workpiece. Is this normal behavior Tom? I think that when the RTCP is turned on, the length of the tool should be recorded in offset without affecting the height of the Z axis.KMotionCNC Version 4.35F.
I don't fully understand what you are doing or what happens. Can You give a specific example? What is the Tool 1 Tool Table length? What are the ABC angles? What Kinematic are you using? What are the Machine and GCode DROs before turning on RTCP? and after?
Regards,

Tom Kerekes
Dynomotion, Inc.

Tarasevih
Posts: 101
Joined: Fri Jul 09, 2021 11:26 am

Re: Button name

Post by Tarasevih » Sat Jul 24, 2021 5:09 am

Hi Tom.Endless gratitude for your work.I will be able to check the additions after August 6, since the machine was taken to another city.

Regards, Taras.
Last edited by Tarasevih on Sat Jul 24, 2021 5:27 am, edited 1 time in total.

Tarasevih
Posts: 101
Joined: Fri Jul 09, 2021 11:26 am

Re: Button name

Post by Tarasevih » Sat Jul 24, 2021 5:26 am

Regarding the problem with the inclusion of the RTCP.
1 tool length, for example 50mm, is measured automatically and entered in the table under the first number.
2 Angles of axes B and C are equal to zero
3 Using the kinematics Kinematics5AxisGimbalCB
4 Without G code just entered the command MDI G43.4H1
After executing the command, if, for example, the Z axis was equal to zero,
it becomes equal to the length of the tool with a negative value (-50).
This happens all the time if you exit the RTCP mode and enter it again.


Regards, Taras.

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

Re: Button name

Post by TomKerekes » Sat Jul 24, 2021 5:54 pm

That sounds correct to me. If you compensate for a tool 50mm long the tip will move down by 50mm. For a tool 100mm long it would move down 100mm.
Regards,

Tom Kerekes
Dynomotion, Inc.

Tarasevih
Posts: 101
Joined: Fri Jul 09, 2021 11:26 am

Re: Button name

Post by Tarasevih » Sun Jul 25, 2021 12:07 pm

Yes, Tom, you're right, I just didn’t figure out that the workpiece must be zeroed on the spindle flange and not on the tool tip.
Thank you so much!
I've got one more question .
Do the tool radius compensation G41 or G42 also need to be activated in the G code?

Regards, Taras.

Tarasevih
Posts: 101
Joined: Fri Jul 09, 2021 11:26 am

Re: Button name

Post by Tarasevih » Thu Jul 29, 2021 6:45 am

Hi Tom. You have not answered the question.

Regards, Taras.

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

Re: Button name

Post by TomKerekes » Thu Jul 29, 2021 3:25 pm

Do the tool radius compensation G41 or G42 also need to be activated in the G code?
yes if you want it enabled.
Regards,

Tom Kerekes
Dynomotion, Inc.

Post Reply