Sharing some of my macros for my ATC router

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

Sharing some of my macros for my ATC router

Postby belarusian » Tue Aug 25, 2020 9:16 pm

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).

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.
belarusian
 
Posts: 3
Joined: Wed Jun 12, 2019 4:36 am

Re: Sharing some of my macros for my ATC router

Postby cncdrive » Wed Aug 26, 2020 3:19 pm

Nice, thanks for sharing. :)
cncdrive
Site Admin
 
Posts: 4685
Joined: Tue Aug 12, 2014 11:17 pm

Re: Sharing some of my macros for my ATC router

Postby belarusian » Fri Oct 02, 2020 7:32 am

Alright, so the macro handling the M6 you see in the following linked video is working.
I've added all the safety features I could think of with the inputs I have available (2 tool rack piston sensors, spindle drawbar piston sensor, and tool holder detecting sensor) which almost doubled the line count of my M6 macro. I'll spend the next week tweaking and re-writing it for readability then share it here.
I don't expect this M6 to be reusable with minimal editing for anyone else because of the sensor inputs that I added, just sharing it because like myself I'm sure it'll prove very valuable borrowing code from for your own machine.

https://youtu.be/8qCiiF_Fyik
belarusian
 
Posts: 3
Joined: Wed Jun 12, 2019 4:36 am

Re: Sharing some of my macros for my ATC router

Postby trendsetter » Sat Oct 03, 2020 9:30 am

Hi Belarusion,

thanks a lot for sharing the first part. Basically I planned exactly the same Setup as you including the tool length sensor. So I would highly appreciate, if you can share you macros.
I plan also to use all 4 Sensors you described, maybe a little bit more for cover of the tools, once it the tool changer is in the park position. Maybe one thing in addition, which might be differnt as well: I think about moving the tool length sensor with the tool changer, to have the full space of the working are. But these are minor details.
Really looking forward to your macro(s).

BR
Michael
trendsetter
 
Posts: 38
Joined: Fri Nov 03, 2017 5:20 am

Re: Sharing some of my macros for my ATC router

Postby lloxley016 » Mon Oct 12, 2020 11:02 am

Nikita S.

thanks for your reply.. Yes. (it's in the UB1's manua) i got that.. the sensor has 4 wire's. i no about PNP/NPN setup.. my question how to wire it. my sensor has a yellow/green for probe single and other two wire red/black for overtravel protection single. can you show how wiring is setup. my old probe was simple wiring two wire, which i hive it set to X103 / 0V. now this new probe sensor is 4 wire's. like a drawing of the wiring Pin to Pin. hear that black/red wire gets connect to E-Stop/ . this probe sensor that i got are NPN close, when press down is open. when i tested with a matter both wire close,. So i don't burn anything out on UB1. can email me a drawing of your wiring setup. Thanks


this is the sensor i got:
Attachments
IMG_0810.jpg
User avatar
lloxley016
 
Posts: 6
Joined: Wed Apr 29, 2020 9:12 pm
Location: orlando

Re: Sharing some of my macros for my ATC router

Postby belarusian » Mon Oct 26, 2020 11:50 pm

lloxley016 wrote:Nikita S.

thanks for your reply.. Yes. (it's in the UB1's manua) i got that.. the sensor has 4 wire's. i no about PNP/NPN setup.. my question how to wire it. my sensor has a yellow/green for probe single and other two wire red/black for overtravel protection single. can you show how wiring is setup. my old probe was simple wiring two wire, which i hive it set to X103 / 0V. now this new probe sensor is 4 wire's. like a drawing of the wiring Pin to Pin. hear that black/red wire gets connect to E-Stop/ . this probe sensor that i got are NPN close, when press down is open. when i tested with a matter both wire close,. So i don't burn anything out on UB1. can email me a drawing of your wiring setup. Thanks


this is the sensor i got:


On mine green went to 0V and yellow is X211.
belarusian
 
Posts: 3
Joined: Wed Jun 12, 2019 4:36 am

Re: Sharing some of my macros for my ATC router

Postby lestui » Mon Nov 22, 2021 7:19 am

Hello, Thought I would revive this thread. just thought I would see if you are still sharing your m6 macro? I’ve seen your YouTube videos. I plan on making a similar setup I pneumatic tool rack but on a 4x8 Chinese CNC router which I have converted to UCCNC.
lestui
 
Posts: 1
Joined: Fri Oct 01, 2021 12:47 am


Return to Macros

Who is online

Users browsing this forum: No registered users and 3 guests