For printing runtime other then caption bar of KmotionCNC

Moderators: TomKerekes, dynomotion

Post Reply
AmitKumar171
Posts: 134
Joined: Tue Feb 20, 2018 7:35 am
Location: India

For printing runtime other then caption bar of KmotionCNC

Post by AmitKumar171 » Thu Sep 27, 2018 12:05 pm

Hi all

I am using kflop board.

In Kmotion CNC there is a Run time option in Caption bar of Kmotion cnc here it is shown.
Screenshot (109).png
Screenshot (109).png (1.52 KiB) Viewed 2885 times
This run time i wan to print somewhere else using DRO Label on my KmotionCNC screen.

I want to know that how to use a DRO Label for printing Run Time.

Waiting for your kind reply.
Thank You

AMIT KUMAR

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

Re: For printing runtime other then caption bar of KmotionCNC

Post by TomKerekes » Thu Sep 27, 2018 5:42 pm

Hi Amit,

Here is C Program that monitors whether a Job is Active, Time stamps when a Job Starts, detects when a Job Ends, Formats a Job Time message, and writes it to a DROLabel.

Code: Select all

#include "KMotionDef.h"

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

void ServiceJobTimer(void);

#define JOBTIMEPERSIST 162

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

// Monitor and time Jobs starting and ending
void ServiceJobTimer(void)
{
    static BOOL WasActive = FALSE;
    static double StartTime;
    double dt, Seconds;
    int Hours, Minutes;
    char s[80];

    if (JOB_ACTIVE && !WasActive)    // Started ??
    {
        StartTime = Time_sec();
        WasActive = TRUE;
    }
    if (!JOB_ACTIVE && WasActive)    // Ended ??
    {
        WasActive = FALSE;

        dt = Time_sec() - StartTime;
        Hours = (int)(dt / 3600.0);
        Minutes = (int)((dt - Hours * 3600.0) / 60.0);
        Seconds = dt - Hours * 3600.0 - Minutes * 60.0;

        if (Hours > 0)
            sprintf(s, "Last Run Time %d hours %d min %5.1f sec", Hours, Minutes, Seconds);
        else if (Minutes > 0)
            sprintf(s, "Last Run Time %d min %5.1f sec", Minutes, Seconds);
        else
            sprintf(s, "Last Run Time %5.1f sec", Seconds);

        // Put it onto the Screen using Persist
        DROLabel(1000, JOBTIMEPERSIST, s);
    }
}
Attached is a Screen Script example (also Attached)with the DROLabel that looks like this:
JobTimeScreen.png
HTH
Attachments
RawCustomWithJobTimeDRO.scr
(45.72 KiB) Downloaded 173 times
ServiceJobTimer.c
(1.3 KiB) Downloaded 172 times
Regards,

Tom Kerekes
Dynomotion, Inc.

AmitKumar171
Posts: 134
Joined: Tue Feb 20, 2018 7:35 am
Location: India

Re: For printing runtime other then caption bar of KmotionCNC

Post by AmitKumar171 » Mon Oct 01, 2018 6:26 am

Hi Tom,

Thanks for the reply.

The timer for printing runtime other then caption bar is working fine as expected by the program that you sent.

Will let you know about further updates.
Thank You

AMIT KUMAR

Post Reply