Hello Guest it is March 29, 2024, 03:04:03 AM

Author Topic: How do I change Output signal Active status from within a G code program  (Read 5272 times)

0 Members and 1 Guest are viewing this topic.

Offline tony_m

*
  •  10 10
  • Woodwind instrument maker.
    • View Profile
Hi
I am trying to switch on and off the voltage on pin 14 on my parallel port from within the g code program run within Mach 3. I need to do this to control an auto tool changer.
I have set up output 14 in the Mach 3 Ports and Pins Output Signals tab to be Enabled on Port 1 (I only have one parallel port on my PC), set Pin No. 14 and set to say Active Low with a red cross.
I can go into the Ports and Pins output screen and set the Active Low from red cross to green tick and I can see the voltage chance on pin 14 on my controller board, but I just can figure out how to change the status from within a G code program.
I suspect I have missed something really easy in the manual but I cant find it. It must be possible as switching on suds pumps etc must be done this way I presume.
Any guidance gratefully received.
Thanks
Tony
Denford Orac lathe and Wabaco mill running with Mach 3 on XP.
I wish I had gone with CNC years ago!
Hi,
two ways I can think of.

First: Pound Variable method
All variables within Mach, and there are thousands of them, are accessible using pound variable notation, #nnnn
I don't offhand know what variable number is for instance associated with Machs Output1, lets say #5677
To cause Ouput1 to go high you would code
#5677=1
To cause it to go low
#5677=0

The only real difficulty with this method is trying to find a definitive list of assigned pound variables, my understanding
is that as Mach developed some of the variable numbers changed adding to the challenge.

Second: DRO/LED method
In VisualBasic or rather CypressEnable, the VB scripting language of Mach3, there are instructions of the type
setOEMDRO(nnn,<value>)
Where nnn is the DRO number of a variable of Mach3. For instance DRO800 is the x-axis DRO on Machs screen.
Similarly there are instructions of the type
setOEMLED(nnn,<true/false>)
which can be used to set/unset an LED.
Neither of these instructions could be used in a Gcode program as is, the Gcode interpreter has no idea what setOMDRO(...) means.
CE instructions have to be put in a macro that the Gcode interpreter can run.
Lets say for example you wish to turn an output on and you called the macro to do it M150. If you put a line M150
in your Gcode program Mach would execute the instructions contained in M150. M150 might look a bit like this:

setOEMLED(nnn,1)

Given that turning on an output is so simple it doesn't really give you a feel for what can be achieved with macros.
Have a look at Operator/VB Script Editor and open and have a look at some of them, M600 is a doozy!
Quote
Mach3 Version 3.x
Macro Programmers Reference Manual
is pretty much essential reading if you wish to write macros and there is some good videos
on the Artsoft site about macros.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'

Offline olf20

*
  •  325 325
    • View Profile
Have you seen Topic: OEM codes for buttons, DRO's and LED's from Hood??
Hope this helps.
olf20 / Bob
Mach3, Atlas Knee Mill, 4th Axis, VcarvePro, ESS, Super PID.
Been Heating with corn since 1998
Hi olf20,
its been a while since I had a look at that list, I see it has been updated and tidied up a bit since I last looked.
I have migrated to Mach4 so have no need for OEM numbers. In fact one of the main reasons I changed to Mach4
is so I could get away from the confusion of OEM numbers. Of course Mach4 has its own challenges but it is
consistent throughout.

As a matter of interest have you seen an up-to-date pound variable list for Mach3? It would be so simple for the
original poster if it were available.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'

Offline olf20

*
  •  325 325
    • View Profile
No I have not seen a updated list, but I have not really looked.
Yea I like stumbling thru M3. I guess I'm to set in my ways
at this point. I find starting over is something I tend to stay
away from.
I really don't use many bells and whistles. I upgraded to
ESS and that has improved my mill greatly.
Did you have to learn Luna to any degree with M??

Thanks
olf20 / Bob
Mach3, Atlas Knee Mill, 4th Axis, VcarvePro, ESS, Super PID.
Been Heating with corn since 1998
Hi olf20/Bob,
milling/routing is pretty complete in Mach4, just load your code and cut chips.

To customise Mach4 you do need to code with LUA. LUA itself is really easy, its all the instructions necessary to interface with
Mach4 and/or other hardware that take some getting used to. It is worth the effort, you can customise or add features to Mach4
that you just can't do with Mach3. Also while LUA is simple it has features like 'functions as first class values' which make sound
like gobble-de-gook but when you understand the implications you realise that LUA 'kicks anus bigtime'. Neither is that the only
really really powerful subtlety about LUA, light years ahead of VB.

Given that you have an ESS you can download M4 and the Warp9 M4 plugin and try it out. The Demo version runs on Simulate forever
or for about 6 minutes at a time with an active motion controller like the ESS.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Hi tony_m,
sorry I have rather hijacked your thread. I found this in the manual
Quote
OEM LED Input 1 Active 821
OEM LED Input 2 Active 822
OEM LED Input 3 Active 823
OEM LED Input 4 Active 824

and this
Quote
OEM LED Output 4 Active 77
OEM LED Output 5 Active 78
OEM LED Output 6 Active 79

So if you want to turn on an output assign pin 14 to Output#1 on the Config/Ports and Pins/Outputs page and in a macro code:

setOEMLED(822)....please note I can't find this instruction in the manual so I may not have quite correct.

Will try to find a list for pound variables, it would be easier to use for your purpose.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'

Offline Tweakie.CNC

*
  • *
  •  9,196 9,196
  • Super Kitty
    • View Profile
Hi Craig,

To my knowledge no list of the Mach3 pound variables was ever released.  :'(

Tweakie.
PEACE

Offline tony_m

*
  •  10 10
  • Woodwind instrument maker.
    • View Profile
Hi Craig and Bob
Thanks very much for your replies which look like a way forward for me. Sorry for the delay in my getting back to you but I have been away for a couple of weeks.

I had a feeling I would need to get into some form of coding/scripting and your link to Macro Programers Ref Manual looks like my bedtime reading for a while.

I will have a go at finding the pound variable list first I think as that looks easier to get to grips with. If I cant find the right # codes then then I will have two venture into VB.

Again, thanks for your time on this. If I do find a list of the pound variables I will post them here.

Cheers
Tony
Denford Orac lathe and Wabaco mill running with Mach 3 on XP.
I wish I had gone with CNC years ago!