Viewing console from KmotionCNC


Page 1 of 2 12 LastLast
Results 1 to 12 of 21

Thread: Viewing console from KmotionCNC

  1. #1
    Registered
    Join Date
    May 2012
    Location
    canada
    Posts
    356
    Downloads
    0
    Uploads
    0

    Default Viewing console from KmotionCNC

    Hi Tom,

    Wondering if theres a way to view the console directly from Kmotioncnc? Maybe add a small console to the main screen with screen editor? Or a button to open a new window without having to open kmotion? I sort of recall someone asking something similar before but cant find it now.

    I configured m30 to print true cycle time (including part change) and check this fairly often. Would be nice if i could display it on screen or have it one click away. Thanks.

    Mark

    Similar Threads:


  2. #2
    Gold Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    2987
    Downloads
    0
    Uploads
    0

    Default Re: Viewing console from KmotionCNC

    Hi Mark,

    Noted. You might use the Screen Editor to add a DROLabel on the Screen then have the M30 write the cycle time there.

    Regards



  3. #3
    Registered
    Join Date
    May 2012
    Location
    canada
    Posts
    356
    Downloads
    0
    Uploads
    0

    Default Re: Viewing console from KmotionCNC

    Hi Tom,

    Im going to try and add a DRO label as you suggest, and another to show feed per rev. But im having some trouble getting anything to display.

    I just added the "Screen Value to Jog speed" feature and this is working well. I added to the code of this program to try and print to another dro but cant get it to display anything. What am I doing wrong. See attached screenshot for DRO settings and code below:

    Code:
    #include "KMotionDef.h"
    
    #define TMP 10 // which spare persists to use to transfer data
    #include "KflopToKMotionCNCFunctions.c"
    
    #define MAX_JOG_SPEED_X 210.0 // ipm
    #define MAX_JOG_SPEED_Y 210.0 // ipm
    #define MAX_JOG_SPEED_Z 210.0 // ipm
    
    void UpdateJogSpeeds(void);
    void DoLimitJog(double rate, int cmd);
    
    
    main()
    {
    
    	double IPR;
    	char s[80];
    
    	for (;;)  // forever loop
    	{
    
    		// set jog rate
    		UpdateJogSpeeds();
    		Delay_sec(0.005);
    		// end set jog rate
    
    
    		//Display Feed Per Rev
    		IPR = 0.0123; // random feed to test display
    		sprintf(s,"Feed = %8.2f ipr\n",IPR);
    		DROLabel(1000, 151,s);
    	}
    }
    
    //set Rate within Limits
    void DoLimitJog(double rate, int cmd)
    {	
    	rate = rate * 2;
    	if (rate < 0.0) rate=0.0;
    	if (rate > 1.0) rate=1.0;
    	
    	DoPCFloat(cmd, rate);
    }
    
    void UpdateJogSpeeds(void)
    {
    	static LastChangeCount=-1;
    	int Units, TWORD, HWORD, DWORD;
    	double rate;
    	
    	// don't bother if nothing changed
    	if (EditChangeCount == LastChangeCount) return;
    
    	// remember count before updating
    	LastChangeCount = EditChangeCount;
    	
    	// Read double from a KMotionCNC Edit Control
    	// Persist Var identifies the Control and contents specifies 
    	// where the string data should be placed in the 
    	// Gather Buffer as an offset in words
    	if (GetEditControlDouble(&rate, 150, 1000)) return;  // exit if value is invalid
    	
    	GetMiscSettings(&Units, &TWORD, &HWORD, &DWORD); // check Units
    	if (Units == CANON_UNITS_MM) rate = rate/25.4; // convert screen value to ipm	
    	DoLimitJog(rate/MAX_JOG_SPEED_X, PC_COMM_SET_JOG_OVERRIDE_X);
    	DoLimitJog(rate/MAX_JOG_SPEED_Y, PC_COMM_SET_JOG_OVERRIDE_Y);
    	DoLimitJog(rate/MAX_JOG_SPEED_Z, PC_COMM_SET_JOG_OVERRIDE_Z);
    	
    }


    Attached Thumbnails Attached Thumbnails Viewing console from KmotionCNC-untitled-png  


  4. #4
    Gold Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    2987
    Downloads
    0
    Uploads
    0

    Default Re: Viewing console from KmotionCNC

    Hi Mark,

    I think you have the hide "hide" property set for the "IPR" DROLabel control. When a control is shown in yellow it indicates hidden, yet selected.

    To make a control visible:

    #1 select it (you may need to select "Show Hidden")
    #2 press "show"

    Otherwise your code seems to work for me.

    Viewing console from KmotionCNC-ipr-png

    On a minor note you shouldn't need the new line character \n in the label characters so you might remove it.

    If you still have an issue post the screen script (as a txt file) so we can check it.

    Regards



  5. #5
    Registered
    Join Date
    May 2012
    Location
    canada
    Posts
    356
    Downloads
    0
    Uploads
    0

    Default Re: Viewing console from KmotionCNC

    Ok yes that would certainly explain it. Sorry, not sure how i missed that lol.

    I have it sort of working now. Im using variable 151 to show feed per rev, and 152 to show cycle time on another DRO. But that program is printing feedrate to both dros?? And If i kill that thread m30 prints cycle time fine to the second dro with var 152 which is very strange. I did double check the numbers are right in the screen editor but i must be missing something, ill look it over again tomorrow.

    One more thing, i'm guessing that its better to leave this code in a separate thread with a slight delay in the loop instead of putting it in my init right?



  6. #6
    Registered
    Join Date
    Jun 2013
    Location
    USA
    Posts
    984
    Downloads
    0
    Uploads
    0

    Default Re: Viewing console from KmotionCNC

    I don't know if this is taking things off topic so I apologize ahead of time just in case. I am wondering if it would be possible to show the axis screen load graph as well as the analog I/O screen adc's, supply, and temperature values on the kmotion screen using similar methods. Note these values monitor snapamp in my system.

    Thank you
    Ben

    Sent from my E6810 using Tapatalk



  7. #7
    Gold Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    2987
    Downloads
    0
    Uploads
    0

    Default Re: Viewing console from KmotionCNC

    Hi Mark,

    I have it sort of working now. Im using variable 151 to show feed per rev, and 152 to show cycle time on another DRO. But that program is printing feedrate to both dros?? And If i kill that thread m30 prints cycle time fine to the second dro with var 152 which is very strange. I did double check the numbers are right in the screen editor but i must be missing something, ill look it over again tomorrow.
    Besides using the persist variable to trigger the string to be uploaded, the string must be placed in memory somewhere. That is what the 1000 is in this function call is for:

    DROLabel(1000, 151,s);

    1000 is an offset into the 8 megabyte gather buffer where the string is to be placed. If you send one string at a time to various DROLables you might be able to use the same memory for the strings. But if updating multiple DRO labels at the same time, separate memory areas must be used. Its probably simplest to always use separate memory spaces. So for example to leave space for strings 100 characters long you might do:

    DROLabel(1000, 151,string1);
    DROLabel(1100, 152,string2);

    One more thing, i'm guessing that its better to leave this code in a separate thread with a slight delay in the loop instead of putting it in my init right?
    Good question. I would expect you could use the same Init Thread for setting the DROLabels as long as you use a Timer in order to only do it periodically. The strings are fairly quickly placed in memory for KMotionCNC to upload later, so it shouldn't have a big impact on the loop timing. I measure ~60us to format the string with sprintf and the call to DROLabel takes ~25us.

    However when the Operator Types into the Jog Rate control and KFLOP is informed of a change multiple interactions with KMotionCNC is required to request and receive the Rate values and the Units. KMotionCNC only services this on ~100ms intervals so it can take ~500ms for all this to occur.

    Its like sending vs getting information to/from a friend via mail. To send you can just drop a note in the mail and you are immediately done (if/when he receives it isn't your issue). To get information you must first mail a request. Then wait days before possibly receiving a response.

    The call to GetEditControlDouble(&rate, 150, 1000) currently blocks waiting for the response. We could re-write it in a way where it doesn't block but rather returns whether the response was received or not.

    I'm not sure which is simpler: Using two Threads or a non-Blocking approach.



  8. #8
    Gold Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    2987
    Downloads
    0
    Uploads
    0

    Default Re: Viewing console from KmotionCNC

    Hi Ben,

    I am wondering if it would be possible to show the axis screen load graph as well as the analog I/O screen adc's, supply, and temperature values on the kmotion screen using similar methods. Note these values monitor snapamp in my system.
    Yes you should be able to display such status numerically or graphically using the Screen Editor. The Screen Editor has a Vertical Bar (VertBar) control type for simple graphics. Your C Program would set a persist variable as a floating point value fro 0.0 to 1.0 to update the graph. See the example ShowInstantVelocityDROBar.c and ShowInstantFeedRate3AxisBar.scr.

    Viewing console from KmotionCNC-vertbar-jpg

    Regards



  9. #9
    Registered
    Join Date
    May 2012
    Location
    canada
    Posts
    356
    Downloads
    0
    Uploads
    0

    Default Re: Viewing console from KmotionCNC

    Quote Originally Posted by TomKerekes View Post
    Hi Mark,

    Besides using the persist variable to trigger the string to be uploaded, the string must be placed in memory somewhere. That is what the 1000 is in this function call is for:

    DROLabel(1000, 151,s);

    1000 is an offset into the 8 megabyte gather buffer where the string is to be placed. If you send one string at a time to various DROLables you might be able to use the same memory for the strings. But if updating multiple DRO labels at the same time, separate memory areas must be used. Its probably simplest to always use separate memory spaces. So for example to leave space for strings 100 characters long you might do:

    DROLabel(1000, 151,string1);
    DROLabel(1100, 152,string2);

    Good question. I would expect you could use the same Init Thread for setting the DROLabels as long as you use a Timer in order to only do it periodically. The strings are fairly quickly placed in memory for KMotionCNC to upload later, so it shouldn't have a big impact on the loop timing. I measure ~60us to format the string with sprintf and the call to DROLabel takes ~25us.

    However when the Operator Types into the Jog Rate control and KFLOP is informed of a change multiple interactions with KMotionCNC is required to request and receive the Rate values and the Units. KMotionCNC only services this on ~100ms intervals so it can take ~500ms for all this to occur.

    Its like sending vs getting information to/from a friend via mail. To send you can just drop a note in the mail and you are immediately done (if/when he receives it isn't your issue). To get information you must first mail a request. Then wait days before possibly receiving a response.

    The call to GetEditControlDouble(&rate, 150, 1000) currently blocks waiting for the response. We could re-write it in a way where it doesn't block but rather returns whether the response was received or not.

    I'm not sure which is simpler: Using two Threads or a non-Blocking approach.
    Hi Tom,

    You were right, I was using 1000 for both, I changed to 1100 and its working fine now thanks. This is pretty cool to be able to send anything to the screen like that without too much trouble. I think im going to add another to print run time from the start of program, ill set it up with another M code to record start time. Would be nice to see both run time and cycle time.

    I guess there are pros and cons of each when it comes to the threads. It would be sort of convenient to have it all running in one thread but I don't think I mind having two in this case. Almost seems to me like its better to have the init running smoothly on its own doing the important stuff and not having anything to do with the PC. And having another thread handling the communication with the PC. I have it setup now with an M code to start this second thread, and thats done automatically anyway when i run init so really no big deal.

    Ben, I also considered adding load meters that would be based on DAC values. Would be a nice feature, You would need to average the values for a period of time to get any sense out of them, not sure how much trouble that would be. Im sure Tom would have a way of doing it. The meters would take up a fair bit of space on the screen too.

    Thanks again Tom.

    Mark



  10. #10
    Registered
    Join Date
    May 2012
    Location
    canada
    Posts
    356
    Downloads
    0
    Uploads
    0

    Default Re: Viewing console from KmotionCNC

    Hi Tom,

    I have all the DRO's working after, using three in total. Two to display run time and cycle time that gets updated by M30. And another that displays feed per rev that gets updated several times per second (I forget exact number but can check). Everything is working well with the DRO's, but it seems to be slowing down Kmotioncnc. Whenever I try and access the tool and fixture tables now there is a considerable delay before they open, sometimes 8-10 seconds or more. I think the boxes themselves may be grayed out a little longer at program end as well.

    Any suggestions on how to speed it up? Is there a way to make kmotioncnc read the variable less often or something? Have you ever noticed any slow down? Is there a chance I have something done wrong thats causing a conflict or something?



  11. #11
    Gold Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    2987
    Downloads
    0
    Uploads
    0

    Default Re: Viewing console from KmotionCNC

    Hi Mark,

    I wouldn't expect this. I just checked a single DRO updating 100 times/sec and I don't see any such issue.

    Can you post your Screen Script and C Program for us to look at?

    Regards



  12. #12
    Registered
    Join Date
    May 2012
    Location
    canada
    Posts
    356
    Downloads
    0
    Uploads
    0

    Default Re: Viewing console from KmotionCNC

    Hi Tom,

    Here are the files.

    The delay seems most noticeable after doing something else. Like right after finishing a program or starting and stopping the spindle or something. If its just sitting there idling it isnt as bad. Thanks.

    Mark

    Attached Files Attached Files


Page 1 of 2 12 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


About CNCzone.com

    We are the largest and most active discussion forum for manufacturing industry. The site is 100% free to join and use, so join today!

Follow us on


Our Brands

Viewing console from KmotionCNC

Viewing console from KmotionCNC