Hi Tom,
Im going to try and add a DRO label as you suggest, and another to show feed per rev. But im having some trouble getting anything to display.
I just added the "Screen Value to Jog speed" feature and this is working well. I added to the code of this program to try and print to another dro but cant get it to display anything. What am I doing wrong. See attached screenshot for DRO settings and code below:
Code:
#include "KMotionDef.h"
#define TMP 10 // which spare persists to use to transfer data
#include "KflopToKMotionCNCFunctions.c"
#define MAX_JOG_SPEED_X 210.0 // ipm
#define MAX_JOG_SPEED_Y 210.0 // ipm
#define MAX_JOG_SPEED_Z 210.0 // ipm
void UpdateJogSpeeds(void);
void DoLimitJog(double rate, int cmd);
main()
{
double IPR;
char s[80];
for (;;) // forever loop
{
// set jog rate
UpdateJogSpeeds();
Delay_sec(0.005);
// end set jog rate
//Display Feed Per Rev
IPR = 0.0123; // random feed to test display
sprintf(s,"Feed = %8.2f ipr\n",IPR);
DROLabel(1000, 151,s);
}
}
//set Rate within Limits
void DoLimitJog(double rate, int cmd)
{
rate = rate * 2;
if (rate < 0.0) rate=0.0;
if (rate > 1.0) rate=1.0;
DoPCFloat(cmd, rate);
}
void UpdateJogSpeeds(void)
{
static LastChangeCount=-1;
int Units, TWORD, HWORD, DWORD;
double rate;
// don't bother if nothing changed
if (EditChangeCount == LastChangeCount) return;
// remember count before updating
LastChangeCount = EditChangeCount;
// Read double from a KMotionCNC Edit Control
// Persist Var identifies the Control and contents specifies
// where the string data should be placed in the
// Gather Buffer as an offset in words
if (GetEditControlDouble(&rate, 150, 1000)) return; // exit if value is invalid
GetMiscSettings(&Units, &TWORD, &HWORD, &DWORD); // check Units
if (Units == CANON_UNITS_MM) rate = rate/25.4; // convert screen value to ipm
DoLimitJog(rate/MAX_JOG_SPEED_X, PC_COMM_SET_JOG_OVERRIDE_X);
DoLimitJog(rate/MAX_JOG_SPEED_Y, PC_COMM_SET_JOG_OVERRIDE_Y);
DoLimitJog(rate/MAX_JOG_SPEED_Z, PC_COMM_SET_JOG_OVERRIDE_Z);
}