Hello Guest it is April 26, 2024, 03:09:57 PM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - cd_edwards

Pages: « 1 2
11
Mach4 General Discussion / auto soft limits again
« on: August 08, 2016, 02:32:23 PM »
I don't pretend to be a programmer all that often anymore, but this was needed I believe. This will set Soft Limits off before a RefAllHome(). And after the RefAllHome() is done set it back on so you don't forget to do it.

create a mcSoftLimits.lua in your modules directory with the following

-- mcSoftLimits.lua
-- local CDFuncs = {}

function autoSoftLimitsToggle (togglevalue)
    local mInst = 0
    local rc = 0
    local inst = mc.mcGetInstance (mInst)
--    mc.mcCntlSetLastError(inst, string.format('In Auto Soft Limits Toggle = ' .. togglevalue));
    for i=0, 11 do
        if mc.mcAxisIsEnabled (inst,i) == 1
        then
              mc.mcSoftLimitSetState (inst,i,togglevalue)
        end
    end
end -- of mcSoftLimits.lua

Now in your screenset load script. This script is only run once, and we need an initial value for the variable.

machSoftLimits = -1 -- add this near the top of the script


Now find RefAllHome() and add the two lines to it.

function RefAllHome()
    autoSoftLimitsToggle(0) -- ****** ADD we want to make sure and turn this off at this point.
    mc.mcAxisDerefAll(inst)  --Just to turn off all ref leds
    mc.mcAxisHomeAll(inst)
    coroutine.yield() --yield coroutine so we can do the following after motion stops
    ----See ref all home button and plc script for coroutine.create and coroutine.resume
    wx.wxMessageBox('Referencing is complete')
    machSoftLimits = 1 -- ******* ADD this line to your RefAllHome() function
end

Add this in the section that loads required modules.

package.loaded.SoftLimits = nil
sl = require "mcSoftLimits"

Finally at the bottom of your PLC script add the following

if ((machSoftLimits == 1) and (machState == mc.MC_STATE_IDLE)) then -- after we finish the toggle, set machSoftLimits to 0 so we don't come back here until needed.
    autoSoftLimitsToggle(1);
    machSoftLimits = 0; -- RefAllHome() set's this for us when we need it
end

if (machSoftLimits == -1) then -- Don't care what the state of Mach4 is here. We just are disabling them for first run.
   autoSoftLimitsToggle(0);
   machSoftLimits = 0;
end

12
Mach4 General Discussion / machine.ini
« on: July 01, 2016, 06:14:10 PM »
Is the machine.ini connected to the screenset in anyway other than defining what screenset to load? What I attempted todo in order to save myself some effort once again
was to copy the working .ini file from a profile into a newly created profile which uses wxrouter.. When I do this, I notice there are some color changes?? where there should not be. As well
upon exit I can an error msg as shown here

http://prntscr.com/bnmzda

This is due to wxrouter storing values in the machine.ini. I eventually found these values and copied them over. This is not very unhandy.. wxrouter should have it's own ini to store values in and not store them in the machine definitions. doing this causes it to be highly unportable and makes updating a frustrating process as you need to copy machine settings down on paper and then re-write your machine.ini.

13
Mach4 Toolbox / Soft Limits toggle
« on: June 07, 2015, 02:49:58 PM »
Add this to the beginning of the Screen loading script. Shamelessly stolen from someone here :)


--////////////////  This is the REQUIRED Header code, Begin  //////////////////////
package.path = "./?.lua;c:/Mach4Hobby/Modules/?.mcc;" --where the module file is.   
ff = require "FuncModule";--load the module file, call it ff
--///////////////  This is the REQUIRED Header code, End   ///////////////////////

create this script in the Modules directory.

function autoSoftLimitsToggle (togglevalue)
    local mInst = 0
    local rc = 0
    local inst = mc.mcGetInstance (mInst)
   -- mc.mcCntlSetLastError(inst, 'In Auto Soft Limits Toggle = ');
    for i=0, 11 do
        if mc.mcAxisIsEnabled (inst,i) == 1 then mc.mcSoftLimitSetState (inst,i,togglevalue) end
    end
end

-- End of funcModule.mcs Don't forget to compile this script Doh!

In your PLC script add the following.

package.path = "./?.lua;c:/Mach4Hobby/Modules/?.mcc;" --where the module file is.   
ce = require "funcModule";--load the module file, call it ce

Near the end of the PLC add the following


if ((machSoftLimits == 1) and (machState == mc.MC_STATE_IDLE)) then
    autoSoftLimitsToggle(1);
    machSoftLimits = 0;
end

if (machSoftLimits == -1) then -- Don't care what the state of Mach4 is here. We just are disabling them.
    autoSoftLimitsToggle(0);
   machSoftLimits = 1;
end


And finally in your Ref All Home button script add the following
machSoftLimits = -1;


This will cause Soft Limits to be turned off while you  are Referencing ALL Home. Once homed, Soft Limits will be re-enabled.

I attempted to run the autoSoftLimitsToggle() directly from the button. This would get rid of the machSoftLimits = -1 crap. no  matter what I tried this failed.


14
Mach SDK plugin questions and answers. / programming questions
« on: December 02, 2011, 09:12:57 PM »
Something ODD I noticed while playing with my LCD DRo plugin. I was attempting to use the runtime variable in the CMach4View structure and noticed that it seems to fluctate between 8 and 5 characters long. I'm curious if this is by design or a bug. Also, the esttime variable doesn't seem to ever get filled.

[108116] comport = 6 Show4th axis = 0
[108116] 0 ?y0?x00X: +000.000
[108116] 1 ?y1?x00Y: +000.000
[108116] 2 ?y2?x00Z: +000.000
[108116] runtime 00:00:00
[108116] runtime 00:00
[108116] runtime 00:00:00

One other question I have is how do I get the velocity value that most screen set's display? is that a calculated value or is it the velocity of the current moving axis.


15
Finished Plugins for Download / LCD DRo plugin Gravitech board
« on: November 30, 2011, 10:21:44 PM »
Here's a LCD DRo plugin which works with the Gravitech LCD board. There is NO setup, you will need to edit the XML file using the XML reader in the General Mach3 forum. Please READ the LCDDRO.txt file before doing anything though, as it explains what you need todo.

Updates to the display are almost realtime and are MUCH faster than using the chargepump.m1s file and mach3's builtin serial routine. The currect exec line from the running program is displayed along with 3 axis's. An option is availble to display the 4th A Axis. Display will show the value of ESTOP when estop is enabled.  I might change the display output slightly so that DRO's are displayed at all times by moving ESTOP into another place and not clearing the screen.



EDIT: Added updated version of the LCD Plugin and removed old version.

16
General Mach Discussion / Data structure change
« on: November 27, 2011, 11:44:59 AM »
I've been working on a plugin for a LCD display and had the device working quite well except there was no config dialog. I ended up crashing mach3 so I installed the most recent non-release beta version. Now I have a problem in that the display is not picking up the mach3 machine data structure correctly. Has there been a change in the structure between the release and the current beta version?  Also, I've been able to create a problem with mach3 in that I am able to trigger a 9991 art code consistantly. Closing the dialog, causes mach3 to crash. this is extremely repeatable. I'm not modifiying the structures at all, just set up a dialog box and obviuosly incorrectly.

17
General Mach Discussion / LCD display
« on: October 28, 2011, 09:09:26 AM »
I purchased a LCD Smartie recently which I hope to use for DRO display as well as other information. Here is the code I'm having trouble with
It seems that I need to send raw characters to the device in order to drive it. The example I found in one of the other boards here, does not work for me. The block that I've been working on is in the "If init-=0 .... endif" section.
I'm working from the driver software for the matrix DLL which works using LCD Smartie


procedure TLCD_MO.setPosition(x, y: Integer);
begin
  writeDevice(Chr($0FE)+'G'+Chr(x)+Chr(y));
  inherited;
end;

Chr(254) is 0xFE


cnt=getVar(1000)
init=getVar(1001)

If init=0 Then

   SendSerial _
      Chr(254)"G"Chr(0)Chr(0)" X:" & _
      Chr(254)"G"Chr(0)Chr(1)" Y:" & _
      Chr(254)"G"Chr(0)Chr(2)" Z:" & _
      Chr(254)"G"Chr(0)Chr(3)" A:" & _
      setVar(1001, init+1)
      setVar(1000, 0)
end if

if cnt=10 then
     setVar(1000, 0)
    SendSerial _
    "¦30" & Format (Getdro(0) , "+000.0000;-000.0000") & _
    "¦31" & Format (Getdro(1) , "+000.0000;-000.0000") & _
    "¦32" & Format (Getdro(2) , "+000.0000;-000.0000") & _
    "¦33" & Format (Getdro(3) , "+000.0000;-000.0000")
else
    setVar(1000, cnt+1)
End If   

Pages: « 1 2