Welcome, Guest. Please login or register.
Did you miss your activation email?
May 27, 2012, 09:27:46 AM

Login with username, password and session length
Search:     Advanced search
* Home Help Search Calendar Links Login Register
+  Machsupport Forum
|-+  Mach Discussion
| |-+  VB and the development of wizards
| | |-+  speed of execution of macro
Pages: 1 2 »   Go Down
Print
Author Topic: speed of execution of macro  (Read 845 times)
0 Members and 1 Guest are viewing this topic.
moorea21
Active Member

Offline Offline

Posts: 88


View Profile
« on: December 24, 2010, 11:40:31 AM »

Hi,

As part of what I'm doing, it looks like I need to write a macro that I will call from Gcode quite often. maybe 40 times a second... ie one call on each line.

My question is, how long (in microseconds I guess) does it take to call, execute and exit from a macro? The macro will only be about 5 lines long.

Any ideas?

Thanks, Richard B
Logged
moorea21
Active Member

Offline Offline

Posts: 88


View Profile
« Reply #1 on: December 24, 2010, 11:50:21 AM »

The macro will move an axis to 3 different positions in sequence, at full speed.
Logged
BR549
Active Member

Offline Offline

Posts: 2,555


View Profile
« Reply #2 on: December 24, 2010, 12:48:29 PM »

It all depends on how busy the CPU is as each macro is called. Also NOTE using a macro there is NO garranty that all the calls will stay in synced.  The basic VB loop only cycles at 10 cycles per sec IF it has time to get it all done in one loop then maybe ,maybe not.

Rememeber Mach is a GCODE machine motion controller it processes basic machine GCODE very well. Using it ouside of those parameters and you are pretty much in unknown territory.

From what I see you have pretty extreme paramaters to follow machine wise.  MOve an axis to 3 sequential positions up to 40 times per sec at full speed AND process the macro up to 40 times per sec when the basic macro loop is 10 cycles per sec.

HECK give it a whirl and let us know if it works, (;-) TP
« Last Edit: December 24, 2010, 12:51:33 PM by BR549 » Logged
moorea21
Active Member

Offline Offline

Posts: 88


View Profile
« Reply #3 on: December 24, 2010, 03:48:22 PM »

At the moment, the gcode runs at about that speed, with one command for the axis in question on each line. But there are god reasons to use a macro, related to file size... it's a bit more involved than that. The other alternative would be to use a supplementary output pin on my controller to trigger a picaxe microcontroller to perform the 3 positions thing.

I didn't know that macros might not be executed in the order they are written in.

Does anyone know a way around that?
Logged
moorea21
Active Member

Offline Offline

Posts: 88


View Profile
« Reply #4 on: December 24, 2010, 03:57:30 PM »

Re my last post : - I'm assuming when you say 'NOTE using a macro there is NO garranty that all the calls will stay in synced" you mean that they could be executed in the wrong order? Could the problem be solved by adding

While IsMoving()
  Sleep 10
Wend

into the macro, so that the cpu is likely to be free, and no other axes would move at the same time, so no sych problems?
Logged
moorea21
Active Member

Offline Offline

Posts: 88


View Profile
« Reply #5 on: December 24, 2010, 04:03:27 PM »

Re "The basic VB loop only cycles at 10 cycles per sec"... does that mean you only have 1/10th of a second to execute the whole macro?
Logged
rrc1962
Active Member

Offline Offline

Posts: 434


View Profile
« Reply #6 on: December 24, 2010, 04:04:28 PM »

You don't need "Sleep 10" inside the loop.  an empty IsMoving() while loop will just loop until IsMoving() = false.  
Logged
rrc1962
Active Member

Offline Offline

Posts: 434


View Profile
« Reply #7 on: December 24, 2010, 04:08:00 PM »

Re "The basic VB loop only cycles at 10 cycles per sec"... does that mean you only have 1/10th of a second to execute the whole macro?

Basically, yes.  The number of cycles depends on the macro.  A slow running macro may only be able to execute 5 times per second.  As long as the macro can finish in less than 1/10 of a second, the best you can hope for if 10 cycles per second.  Brains are much faster, but I don't think you can do what you want to do in brains.
Logged
moorea21
Active Member

Offline Offline

Posts: 88


View Profile
« Reply #8 on: December 24, 2010, 04:16:34 PM »

Not familiar with brains... I like the idea of something much faster than a macro, though.
The macro would be basically:-

While IsMoving()
   Wend
      Code G01 A2.5
      Code G01 A0
      Code G01 A1.7

That's all...
Logged
BR549
Active Member

Offline Offline

Posts: 2,555


View Profile
« Reply #9 on: December 24, 2010, 04:20:11 PM »

each time a macro is called it is opened in its own thread. It is also known that mach can skip over open threads that take too long and the results fall out of exact sync. I have also seen where a data loop was skipped over but showed up several cycles later.

Mach VB macro system is not perfect BUT works ok inside of what it was designed for.

CAN you design the system to RUN from straight Gcode?  Mach does that part very well and fast.

Brains last I heard scanned at 10hz as well. the internals are much faster but IF you have to gather/scan data it will be at 10 cycles per sec as well.


OK looking at you last message IF you are just doing basic Gcode WHY wash it through a macro???  Could  Gcode SubProgram work in place of the macro call?

Just a thought, (;-) TP
« Last Edit: December 24, 2010, 04:22:50 PM by BR549 » Logged
Pages: 1 2 »   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!