Spindle load, display analog readings on screen

Moderators: TomKerekes, dynomotion

Post Reply
TFrenken
Posts: 5
Joined: Mon Dec 25, 2023 10:36 am

Spindle load, display analog readings on screen

Post by TFrenken » Thu Feb 13, 2025 9:13 pm

Hi Tom,
is it possible to display an ADC value on the KMotionCNC screen?
If possible as some kind of bar or percentage, in my case to show spindle load.

Regards
Thomas

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

Re: Spindle load, display analog readings on screen

Post by TomKerekes » Thu Feb 13, 2025 10:47 pm

Hi Thomas,

Yes. You might see the Screen example ShowInstantFeedRate3AxisBar.scr that shows the feed rate as a value and as a Bar Graphic.

The C Program example ShowInstantVelocityDROBar.c updates the Value and the Bar Graphic periodically.

You can read the current value of a Kanalog ADC with ADC(n).

You can use KOGNA_CONVERT_ADC_TO_VOLTS(v) to convert the ADV counts to Volts if needed.

Code: Select all

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

#define CNTS_PER_INCH_X 20000.0
#define CNTS_PER_INCH_Y 20000.0
#define CNTS_PER_INCH_Z 15000.0

#define FULL_BAR_SCALE 50.0


main()
{
	double Rate,d,x0,dx,y0,dy,z0,dz,t0,t1;
	char s[80];
	
	for(;;)
	{
		t0=WaitNextTimeSlice();
		x0 = ch0->Dest / CNTS_PER_INCH_X;
		y0 = ch1->Dest / CNTS_PER_INCH_Y;
		z0 = ch2->Dest / CNTS_PER_INCH_Z;
		t1=WaitNextTimeSlice();
		dx = ch0->Dest / CNTS_PER_INCH_X - x0;
		dy = ch1->Dest / CNTS_PER_INCH_Y - y0;
		dz = ch2->Dest / CNTS_PER_INCH_Z - z0;
		
		d = sqrt(dx*dx + dy*dy + dz*dz);

		Rate = d/(t1-t0)*60.0;
		sprintf(s,"Rate %8.2f ipm\n",Rate);
		// Put it onto the Screen
		DROLabel(1000, 162, s);
		WriteVarFloat(163, Rate/FULL_BAR_SCALE);
		Delay_sec(0.5);
	}
}

Bar.png



HTH


SSBar.png
Regards,

Tom Kerekes
Dynomotion, Inc.

TFrenken
Posts: 5
Joined: Mon Dec 25, 2023 10:36 am

Re: Spindle load, display analog readings on screen

Post by TFrenken » Fri Feb 14, 2025 12:40 pm

Hi Tom,

thank you for the quick reply and this great solution.

Regards,
Thomas

Post Reply