Page 1 of 1
Cycle Counter
Posted: Tue Oct 22, 2019 11:49 pm
by DMSdesignco
Hello Everyone,
I would like to add a cycle counter to the KMotionCNC screen. Ideally it would have a zero reset button and a display to show cycles run since last reset.
Thanks for any and all suggestions,
David.
Re: Cycle Counter
Posted: Wed Oct 23, 2019 12:06 am
by TomKerekes
Hi David,
Are you using the
KMotionCNC Screen Editor?
Re: Cycle Counter
Posted: Mon Oct 28, 2019 4:29 pm
by DMSdesignco
Hi Tom,
Yes we are using the KMotion Screen Editor.
Thanks,
David.
Re: Cycle Counter
Posted: Mon Oct 28, 2019 5:44 pm
by TomKerekes
Hi David,
You might add a DROLabel to your screen such as shown here in red.
Configure it to monitor Var 162 for a string to display as shown here:
Now create a C Program to increment a persist Variable Counter and display it on the screen. We use Var 50 for the counter.
Code: Select all
#include "KMotionDef.h"
#define TMP 10 // which spare persist to use to transfer data
#include "KflopToKMotionCNCFunctions.c"
#define COUNT_VAR 50 // declare what Variable to use as a counter
void main()
{
char s[80];
persist.UserData[COUNT_VAR]++; // count
// Now Format as string
sprintf(s,"%d",persist.UserData[COUNT_VAR]);
// Put it onto the Screen
DROLabel(1000, 162, s);
}
Another C Program to Clear the count
Code: Select all
#include "KMotionDef.h"
#define TMP 10 // which spare persist to use to transfer data
#include "KflopToKMotionCNCFunctions.c"
#define COUNT_VAR 50 // declare what Variable to use as a counter
void main()
{
char s[80];
persist.UserData[COUNT_VAR]=0; // cleat count
// Now Format as string
sprintf(s,"%d",persist.UserData[COUNT_VAR]);
// Put it onto the Screen
DROLabel(1000, 162, s);
}
Then call the Count Program when you want it to increment. For example you might have M30 (end of Job do a count)
- M30Counts.png (2.94 KiB) Viewed 9037 times
You might also add a User Button that executes the ClearCount.c Program to Clear the counter
HTH
Re: Cycle Counter
Posted: Fri Nov 01, 2019 12:15 am
by DMSdesignco
Hi Tom,
Thanks very much for your guidance. I will build one tomorrow when I have access to one of our machines.
That was a BIG help!
Regards,
David.
Re: Cycle Counter
Posted: Mon Nov 18, 2019 3:39 pm
by DMSdesignco
Hello Tom,
Just a quick post to let you know the screen counter is awesome and our customers love it.
Thanks very much for your help with this!
Best regards,
David.
Re: Cycle Counter
Posted: Mon Nov 18, 2019 5:58 pm
by TomKerekes
Hi David,
Great! Thanks for taking the time to post back.