Sharing some of my macros for my ATC router

I've been on and off working on my router that I've outfitted with a pneumatically actuated linear tool rack and an ATC spindle. I see that some people have shared my videos here but I'll leave a link to my channel since I try to share valuable things that I've learned putting my system together.
https://www.youtube.com/channel/UC7hzAI5mgGt3yWGC4U4N4Ng/
Right now I'm working on incorporating NPN sensor inputs to my M6 macro as a safety feature, it's a lot better than running the machine blind with exec.Wait() and instead waiting on an input from a sensor in order for the macro to move forward or error if something goes wrong.
Anyways in this thread I'll be dumping my macros that I've put together to share. This means that I won't share my M6 until I rewrite it for readability and with the sensor inputs added.
Right now the macro that I have to share is something that measures sensor input delay, but really it was an opportunity to test a while() loop which I think is how I'm going to integrate the sensor inputs into the M6. I think it's a good example of code to share for others in a similar situation as me where I haven't written a line of code until picking up UCCNC. As a bonus it does make for a fun macro to run when playing around with the cylinders and different pressures/speed valves/etc.
So the macro starts off by asking you to enter the port, pin, and what LED will turn on. In my case I used this macro to test my tool rack cyclinder and ATC spindle's drawbar cylinder. It times out after 1000ms if the LED doesn't turn on (true).
I'll be using the while() loop moving forward and incorporate it into my M6. Open to any suggestions/criticism about my code as I share it. No ETA on the M6, could be tomorrow or a month from now all depends on how much free time/motivation I have to put into this.
I'll also be making this post on CNCzone's UCCNC section so there might be some good info in there too if other people comment but I'll be posting the same info in both threads.
https://www.youtube.com/channel/UC7hzAI5mgGt3yWGC4U4N4Ng/
Right now I'm working on incorporating NPN sensor inputs to my M6 macro as a safety feature, it's a lot better than running the machine blind with exec.Wait() and instead waiting on an input from a sensor in order for the macro to move forward or error if something goes wrong.
Anyways in this thread I'll be dumping my macros that I've put together to share. This means that I won't share my M6 until I rewrite it for readability and with the sensor inputs added.
Right now the macro that I have to share is something that measures sensor input delay, but really it was an opportunity to test a while() loop which I think is how I'm going to integrate the sensor inputs into the M6. I think it's a good example of code to share for others in a similar situation as me where I haven't written a line of code until picking up UCCNC. As a bonus it does make for a fun macro to run when playing around with the cylinders and different pressures/speed valves/etc.
So the macro starts off by asking you to enter the port, pin, and what LED will turn on. In my case I used this macro to test my tool rack cyclinder and ATC spindle's drawbar cylinder. It times out after 1000ms if the LED doesn't turn on (true).
- Code: Select all
/*
This macro is used to measure delay (as seen by the macroloop) between output and LED input triggering turning true (on, high?)
This measures the input of a single sensor, does not accommodate 2 sensors or a sensor turning off (although just delete ! in the while loop and it should work)
My machine's tool rack cylinder is port 3, pin 1, and input LED is 15
My machine's spindle drawbar cylinder is port 1, pin 1, and input LED is 12
*/
double port = exec.Question("What is the port?");
double pin = exec.Question("What is the pin?");
double led = exec.Question("What is the LED?");
int timer = 0;
exec.Setoutpin((int)port,(int)pin);
while (!AS3.GetLED((int)led)) // While the input is false, timer will count up (1000ms timeout)
{
timer++;
exec.Wait(1);
if (timer == 1000)
{
MessageBox.Show("took longer than 1000ms");
break;
}
}
if (timer < 1000)
{
MessageBox.Show(timer.ToString() + " ms delay");
}
exec.Wait(1000);
exec.Clroutpin((int)port,(int)pin);
I'll be using the while() loop moving forward and incorporate it into my M6. Open to any suggestions/criticism about my code as I share it. No ETA on the M6, could be tomorrow or a month from now all depends on how much free time/motivation I have to put into this.
I'll also be making this post on CNCzone's UCCNC section so there might be some good info in there too if other people comment but I'll be posting the same info in both threads.