Macros

If you have a question about the software please ask it here.

Macros

Postby Phil1322 » Mon Mar 31, 2025 3:57 pm

Hello,

I'm very new, not just to Macros, but CNC generally. I want to start off with quite a "simple" Macro to test out my port 1 pin 1 and toggle it on/off 5 times, with a delay in between This is the code I've done

M101.txt
(188 Bytes) Downloaded 60 times



I'm using UCCNC (V1.2113) with UC300 5ltp ETh and a UCBB


Errorlog.txt
(935 Bytes) Downloaded 60 times


Eventually, I want to create a pretty complex (for me) Macro for my ATC Spindle, but I want to understand Macros better before I do anything. if I can't get my head around this "simple" Macro, what chance do I have! lol

Regards,


Phil
Phil1322
 
Posts: 20
Joined: Sun Jan 19, 2020 7:41 pm

Re: Macros

Postby ger21 » Mon Mar 31, 2025 4:14 pm

I think you want something like this. It's in C#

Code: Select all
; Macro to toggle Output 1 (Port 1) 5 times

int LOOP_COUNT = 0;

while (LOOP_COUNT < 5)
{
  exec.Setoutpin(1,1);
  exec.code "G4 P0.5";

  exec.Clroutpin(1,1);
  exec.code "G4 P0.5";

  LOOP_COUNT++;

}
Gerry
UCCNC 2022 Screenset - http://www.thecncwoodworker.com/2022.html
ger21
 
Posts: 2794
Joined: Sat Sep 03, 2016 2:17 am

Re: Macros

Postby ger21 » Mon Mar 31, 2025 4:16 pm

Take a look at the default M6 macro to see how a macro is written.
Gerry
UCCNC 2022 Screenset - http://www.thecncwoodworker.com/2022.html
ger21
 
Posts: 2794
Joined: Sat Sep 03, 2016 2:17 am

Re: Macros

Postby Phil1322 » Mon Mar 31, 2025 7:08 pm

Thank you Ger21, I will be able to test this tomorrow

Cheers,

Phil
Phil1322
 
Posts: 20
Joined: Sun Jan 19, 2020 7:41 pm

Re: Macros

Postby Phil1322 » Tue Apr 01, 2025 2:45 pm

I've just tried the Macro and I get the following Errorlog

Errorlog.txt
(699 Bytes) Downloaded 53 times


The Errorlog is just as confusing as the Macro :lol:

I just copied the text, pasted it into Notepad, saved it as M101, and then placed it inside the Macro Folder in the UCCNC Profile Folder (is this correct? Is there anything else I've missed or need to do?).
Phil1322
 
Posts: 20
Joined: Sun Jan 19, 2020 7:41 pm

Re: Macros

Postby ger21 » Tue Apr 01, 2025 4:32 pm

Change the first line to this:

Code: Select all
// Macro to toggle Output 1 (Port 1) 5 times
Gerry
UCCNC 2022 Screenset - http://www.thecncwoodworker.com/2022.html
ger21
 
Posts: 2794
Joined: Sat Sep 03, 2016 2:17 am

Re: Macros

Postby Phil1322 » Tue Apr 01, 2025 5:16 pm

I've just tried that and still no luck, here's the new error log

Errorlog.txt
(306 Bytes) Downloaded 58 times


There are fewer errors, so I guess we're narrowing it down...?
Phil1322
 
Posts: 20
Joined: Sun Jan 19, 2020 7:41 pm

Re: Macros

Postby ger21 » Tue Apr 01, 2025 5:35 pm

One more time. Sorry, I'm not a programmer, and was going by memory.

Code: Select all
// Macro to toggle Output 1 (Port 1) 5 times

int LOOP_COUNT = 0;

while (LOOP_COUNT < 5)
{
  exec.Setoutpin(1,1);
  exec.code ("G4 P0.5");

  exec.Clroutpin(1,1);
  exec.code ("G4 P0.5");

  LOOP_COUNT++;

}
Gerry
UCCNC 2022 Screenset - http://www.thecncwoodworker.com/2022.html
ger21
 
Posts: 2794
Joined: Sat Sep 03, 2016 2:17 am

Re: Macros

Postby Phil1322 » Tue Apr 01, 2025 5:42 pm

No need to apologise, I really appreciate you help and time.

I will have another go and let you know

Thanks again
Phil1322
 
Posts: 20
Joined: Sun Jan 19, 2020 7:41 pm

Re: Macros

Postby Phil1322 » Tue Apr 01, 2025 6:34 pm

Unfortunately still no luck

Here is the error log

Errorlog.txt
(720 Bytes) Downloaded 53 times
Phil1322
 
Posts: 20
Joined: Sun Jan 19, 2020 7:41 pm

Next

Return to Ask a question from support here

Who is online

Users browsing this forum: Bing [Bot] and 4 guests