Page 1 of 1
Activate outputs manually
Posted:
Tue Dec 22, 2020 8:14 pm
by Jotape
Hi folks!
I'm doing an old Bridgeport 520 interact retrofit with full cncdrive hardware and software.
My question is, is there anyway to activate the outputs manually? Not running a macro.
I'm doing some test with the pneumatic ATC sistem and I need to activate the solenoids one by one to test and check all of them.
Thanks a lot guys!
Re: Activate outputs manually
Posted:
Wed Dec 23, 2020 9:52 am
by dezsoe
You can use the following macro. Save it to Mxxx.txt into your macro folder, where xxx is a number that already does not exist. (You can safely use 1000..)
- Code: Select all
if ((Evar == null) || (Hvar == null) || (Qvar == null))
{
exec.AddStatusmessage("Parameters: E<port> H<pin> Q<0|1>");
return;
}
int Eint = Convert.ToInt32(Evar);
int Hint = Convert.ToInt32(Hvar);
int Qint = Convert.ToInt32(Qvar);
if (Qint == 0)
exec.Clroutpin(Eint, Hint);
else
exec.Setoutpin(Eint, Hint);
E.g.: M1000 E1 H17 P1 will turn on port 1 pin 17.
Re: Activate outputs manually
Posted:
Wed Dec 23, 2020 1:34 pm
by Jotape
Thanks a lot Csaba!
For a real noob in Macros and programming, can someone explain more or less what each command will do?
I need to start to understand this things, I have an ATC project in front to program
Re: Activate outputs manually
Posted:
Wed Dec 23, 2020 1:51 pm
by dezsoe
- Code: Select all
if ((Evar == null) || (Hvar == null) || (Qvar == null))
{
// if any of the parameters is missing then give error message
exec.AddStatusmessage("Parameters: E<port> H<pin> Q<0|1>");
return;
}
// convert the double type values to integer, because the pin switching functions
// work with integer parameters
int Eint = Convert.ToInt32(Evar);
int Hint = Convert.ToInt32(Hvar);
int Qint = Convert.ToInt32(Qvar);
// if Qint = 0 then turn off with Clroutpin(port, pin) else turn on with Setoutpin(port, pin)
if (Qint == 0)
exec.Clroutpin(Eint, Hint);
else
exec.Setoutpin(Eint, Hint);
The double? type is a special type of floating point: it can be null if no value is assigned to it, so you can check if the macro was called with the required parameters. See the manual 4.1.2 M-codes.
Re: Activate outputs manually
Posted:
Wed Dec 23, 2020 3:31 pm
by sebba
Hello again,
I checked for "if (myEvar == null)" before and after #Events
Before #Events myEvar have desired value but after #Events it is null ^%$#@@%$$#@@&****
Thank you,
Seb
Re: Activate outputs manually
Posted:
Wed Dec 23, 2020 3:51 pm
by dezsoe
I replied in your topic.
Re: Activate outputs manually
Posted:
Wed Dec 23, 2020 4:12 pm
by sebba
ops, sorry for posting here... my fault... back to my topic