load % readouts. actual and maximum

This is where you talk about Macros, show examples of your macro scripting and SHARE handy segments of script code as examples.

load % readouts. actual and maximum

Postby Battwell » Sat Mar 04, 2023 11:05 am



https://youtu.be/WBUkqUUSI3s

if you are lucky enough to have uc300eth with 2 analog inputs you can use this.
edit the screen to show the correct field numbers. ( i edited the actual boxes as these are not used on routers) then added the max and actual labels.

code is below. save as m501 and run as a macroloop.

// M501 analog to power percentage readout in actual fields. re numbered to 20701,20702
// run as macroloop.
// settings,io settings 1, analog2 = var# set to 151

// set vfd to output current or torque from its analog output. use this as your signal into analog 2.
// 2 analogs in on uc300eth. other controllers may not have them!

int anavar=151;
int max=502;
double analogzero=0; // adjust to give correct percentage.// value is any reading with spindle off.

double reading=exec.Getvar(anavar);
double maximum=exec.Getvar(max);
double power=(((reading-analogzero)/65536)*100);//

if(AS3.GetLED(50)) // spindle on?
{
//exec.AddStatusmessage("analog 2 = " +reading);

// SET READING %
AS3.Setfield ((int)power,20701);

if (power >90)
{AS3.SetLED(true, 501);}
else
{AS3.SetLED(false, 501); }

// SET MAXIMUM %
//exec.AddStatusmessage("maximum = " +maximum);
if (reading > maximum)
{
exec.Setvar(reading,max);
AS3.Setfield ((int)power,20702);
}
}
else
{
// SET TO ZERO IF SPINDLE IS OFF.
//AS3.Setfield (0,20702); // this can clear maximum with spindle off.
AS3.Setfield (0,20701);
exec.Setvar(0,max);
}
Thread.Sleep(250); // update 4 times per second.
Uc300eth on router and mill.
UK uccnc powered machine sales. https://cncrouter.uk/atc-cnc-routers.htm
Automateanything/duzzit cnc/mercury cnc
Battwell
 
Posts: 832
Joined: Sun Sep 25, 2016 7:39 pm
Location: South Wales. Uk

Return to Macros

Who is online

Users browsing this forum: No registered users and 1 guest

cron