Page 1 of 1

For printing runtime other then caption bar of KmotionCNC

Posted: Thu Sep 27, 2018 12:05 pm
by AmitKumar171
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 2536 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.

Re: For printing runtime other then caption bar of KmotionCNC

Posted: Thu Sep 27, 2018 5:42 pm
by TomKerekes
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

Re: For printing runtime other then caption bar of KmotionCNC

Posted: Mon Oct 01, 2018 6:26 am
by AmitKumar171
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.