Hello Guest it is April 19, 2024, 02:26:23 AM

Author Topic: Looking for help enabling and disabling output with M code  (Read 4563 times)

0 Members and 1 Guest are viewing this topic.

Re: Looking for help enabling and disabling output with M code
« Reply #10 on: September 04, 2015, 09:54:54 AM »
you are missing an "end" at the end of the file.
A good way to check this stuff is before you save the file, in the Debug menu, click Compile. If there are any major errors with the file, it will display them at the bottom of the window.
Re: Looking for help enabling and disabling output with M code
« Reply #11 on: September 04, 2015, 10:15:04 AM »
Good morning,

I added another end to the end and am no longer getting an error. Thanks for the tip on checking the code. Unfortunately when I run it in either MDI or in a program it  makes the buttons on the screen blank for a second like you are normally running a program but it does not trigger an output. This is what I have now.

function m121() --Save the name of the Signal (as stored inside of Mach4)
local inst = mc.mcGetInstance() --Get the instance of Mach4
ActivateSignalTime = 10000 --Time in milliseconds that we want the signal to be active.
local hReg = mc.OSIG_OUTPUT5 --The handle to the signal
-----------------------------

hReg = mc.mcIoGetHandle(inst, IOName)
if hReg == 0 then
   wx.wxMessageBox("Could not locate signal!")
else
   local rc = mc.mcIoGetState(hReg)
   if rc == 1 then --If rc equals 1, then the signal is active.
      wx.wxMessageBox("Signal is already active!")
   else --If rc does not equal 1, then the signal is not active.
      mc.mcIoSetState(hReg, true) --Activate a signal.
      wx.wxMilliSleep(ActivateSignalTime) --Sleep for the commanded time (so that the output stays on as long as we want).
      mc.mcIoSetState(hReg, false) --Set the state of the signal back to false.
   end
end
end

dan
Re: Looking for help enabling and disabling output with M code
« Reply #12 on: September 04, 2015, 10:24:56 AM »
Is the Output mapped within your Mach Configuration? Are you using an ESS or USS? Is the Output mapped in the ESS config? are all of your wires grounded properly?
Also, check the Diagnostics page to see if the proper Output LED is being lit up.
« Last Edit: September 04, 2015, 10:26:35 AM by KingKerf »
Re: Looking for help enabling and disabling output with M code
« Reply #13 on: September 04, 2015, 11:31:30 AM »
I am working on this code on a development machine which is just running the simulator. I am only referencing the diagnostic screen regarding outputs when I say that I'm not seeing anything.

The actual machine is running a CSMIO/IP-M from CS labs..

dan