Cycle Counter

Moderators: TomKerekes, dynomotion

Post Reply
DMSdesignco
Posts: 3
Joined: Sat Jul 28, 2018 1:09 am

Cycle Counter

Post by DMSdesignco » Tue Oct 22, 2019 11:49 pm

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.

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

Re: Cycle Counter

Post by TomKerekes » Wed Oct 23, 2019 12:06 am

Hi David,

Are you using the KMotionCNC Screen Editor?
Regards,

Tom Kerekes
Dynomotion, Inc.

DMSdesignco
Posts: 3
Joined: Sat Jul 28, 2018 1:09 am

Re: Cycle Counter

Post by DMSdesignco » Mon Oct 28, 2019 4:29 pm

Hi Tom,

Yes we are using the KMotion Screen Editor.

Thanks,
David.

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

Re: Cycle Counter

Post by TomKerekes » Mon Oct 28, 2019 5:44 pm

Hi David,

You might add a DROLabel to your screen such as shown here in red.
ScreenWithCounter.png


Configure it to monitor Var 162 for a string to display as shown here:
ScreenEditorWithCounter.png


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
M30Counts.png (2.94 KiB) Viewed 429 times

You might also add a User Button that executes the ClearCount.c Program to Clear the counter

HTH
Attachments
ClearCount.c
(447 Bytes) Downloaded 2 times
Count.c
(441 Bytes) Downloaded 2 times
Regards,

Tom Kerekes
Dynomotion, Inc.

DMSdesignco
Posts: 3
Joined: Sat Jul 28, 2018 1:09 am

Re: Cycle Counter

Post by DMSdesignco » Fri Nov 01, 2019 12:15 am

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.

Post Reply