Hello Guest it is May 21, 2019, 01:16:07 PM

Author Topic: Creating custom M codes... how???  (Read 18103 times)

0 Members and 1 Guest are viewing this topic.

Creating custom M codes... how???
« on: June 22, 2010, 11:54:04 PM »
Hi everyone,

I am building a machine to automate an assembly process. I involves actuating solenoid valves and relays (along with controlling stepper motors). I want to use M codes to do this.

I have Mach3 installed and working (the motors work fine). I made a custom BreakOut Board that has the required driver circutry for the solenoids and relays. It also works properly.

For testing purposes, I am using M3, M4, M7, and M8 as they are easy to configure. I need more than four M codes and M3/M4 cannot be "On" at the same time.

How do I go about creating my own M codes?

Thanks!
"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." Antoine de Saint-Exupery (1900 - 1944)
Re: Creating custom M codes... how??? - SOLVED!
« Reply #1 on: June 23, 2010, 12:35:46 AM »
I found a post in another forum that showed how to use VB Scripting to do it.

To activate an output, I wrote the following script:

ActivateSignal(OUTPUT1)

Then I saved it as m111.m1s   (I chose the M code as M1xx as my custom code and Mx1x to signify output 1 and Mxx1 to signify the output active.

To deactivate an output, I wrote the following script:

DeactivateSignal(OUTPUT1)

Then I saved it as m110.m1s   (I chose the M code as M1xx as my custom code and Mx1x to signify output 1 and Mxx0 to signify the output inactive.

I then did the for all the outputs I need, of course I changed the M code and outputs to correlate with each other.

I can then test it by using the MDI screen and entering the appropriate M code and hit enter.

It works like a charm!
"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." Antoine de Saint-Exupery (1900 - 1944)

Offline Tweakie.CNC

*
  • *
  •  7,764 7,764
  • Super Kitty
    • View Profile
    • Tweakie.CNC
Re: Creating custom M codes... how???
« Reply #2 on: July 06, 2010, 06:41:06 AM »
Brilliant my friend - Everything is here on the forum and you took the trouble to look for the solution.  :)

If only I could solve the E1P1 /E1P0 problem that way  :'(

Tweakie.
Success consists of going from failure to failure without loss of enthusiasm.  Winston Churchill.
Re: Creating custom M codes... how???
« Reply #3 on: July 25, 2010, 12:28:36 AM »
Many thanks 2000MPH, very helpful post.

I would also add chapter 10.9 in the manual states that new macros can be written using and external editor like notepad.
Re: Creating custom M codes... how???
« Reply #4 on: July 25, 2010, 06:11:18 AM »
If anyone needs a little more help with this see http://www.machsupport.com/forum/index.php/topic,15425.0.html