Hello Guest it is April 28, 2024, 02:28:59 AM

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.


Messages - barneskite28

Pages: « 1 2 3 4 5 6 7 8 »
21
Mach4 General Discussion / Re: Modbus control huanyang GT vfd
« on: November 06, 2021, 06:44:36 AM »
Hi,
I gave you the outline of what is required in post #8. Did you try it?

Craig
I pasted that code into the lua file for the spindle control, but I had no success with that unfortunately

22
Mach4 General Discussion / Re: Modbus control huanyang GT vfd
« on: November 06, 2021, 05:06:46 AM »
I have used the pmc editor a couple of times, but i am not sure how the structure should look to acheive the desired result

23
Mach4 General Discussion / Re: Modbus control huanyang GT vfd
« on: November 06, 2021, 04:50:50 AM »
Hi,
have you thought about putting some code in the PLC script instead?

Craig
Yes definitely thought about it, but i am unsure as to how to write the code!  This is the main problem and why i'm here asking for help! if i was a scripting guru i would have written the solution by now lol

24
Mach4 General Discussion / Re: Modbus control huanyang GT vfd
« on: November 05, 2021, 06:12:56 AM »
i STILL CANT GET A RESOLUTION TO THE REQUIRED SCRIPT TO MAKE THIS OPERATE PROPERLY!

25
Mach4 General Discussion / Re: Modbus control huanyang GT vfd
« on: November 04, 2021, 01:55:40 PM »
replaced that line of code to no avail....

one thing i have noticed is that when i have the lua script enabled, i cannot write to the speed register using regfile anymore...
As soon as i uncheck the script in screen editor, i can control it again

26
Mach4 General Discussion / Re: Modbus control huanyang GT vfd
« on: November 04, 2021, 08:31:50 AM »
the modbus resister addresses are present below, so i figured this path was supposed to be there

27
Mach4 General Discussion / Re: Modbus control huanyang GT vfd
« on: November 04, 2021, 08:30:55 AM »
Maybe, i'm not sure too.... i did see that but i dont have the knowledge of Lua to say so

28
Mach4 General Discussion / Re: Modbus control huanyang GT vfd
« on: November 04, 2021, 05:53:11 AM »
This is the lua file i'm using here

Code: [Select]
-----------------------------------------------------------------------------
--   Name: PMC Module
--Created: 03/27/2015
-----------------------------------------------------------------------------
-- This is auto-generated code from PmcEditor. Do not edit this file! Go
-- back to the ladder diagram source for changes in the logic

-- U_********* symbols correspond to user-defined names. There is such a symbol
-- for every internal relay, variable, timer, and so on in the ladder
-- program. I_********* symbols are internally generated.

local VFD_Spindle_controller = {}

local hReg, hSig, rc
local mInst = 0

-- Generated function for MachAPI.
local function Read_Register(path)
    hReg, rc = mc.mcRegGetHandle(mInst, path)
    if (rc == mc.MERROR_NOERROR) then
        local value, rc = mc.mcRegGetValue(hReg)
        if (rc == mc.MERROR_NOERROR) then
            return value
        end
    end
    return 0
end

-- Generated function for MachAPI.
local function Write_Register(path, value)
    hReg, rc = mc.mcRegGetHandle(mInst, path)
    if (rc == mc.MERROR_NOERROR) then
        rc = mc.mcRegSetValue(hReg, value)
        if (rc == mc.MERROR_NOERROR) then
            return
        end
    end
    return
end

-- Generated function for MachAPI.
local function Read_Signal(path)
    hSig = 0
    rc = mc.MERROR_NOERROR
    hSig, rc = mc.mcSignalGetHandle(mInst, path)
    if (rc == mc.MERROR_NOERROR) then
        local state = 0;
        state, rc = mc.mcSignalGetState(hSig)
        if (rc == mc.MERROR_NOERROR) then
            return state
        end
    end
    return 0
end

-- Generated function for MachAPI.
local function Write_Signal(path, v)
    hSig = 0
    rc = mc.MERROR_NOERROR
    hSig, rc = mc.mcSignalGetHandle(mInst, path)
    if (rc == mc.MERROR_NOERROR) then
        mc.mcSignalSetState(hSig, v)
    end
end

-- Generated function for signal read.
local function Read_U_b_FSpindle_CW()
    return Read_Signal(1142)
end

-- Generated function for signal read.
local function Read_U_b_FSpindle_CCW()
    return Read_Signal(1143)
end

-- Generated function for signal read.
local function Read_U_b_FSpindle_ON()
    return Read_Signal(1141)
end

-- Call this function to retrieve the PMC cycle time interval
-- that you specified in the PmcEditor.
function VFD_Spindle_controller.GetCycleInterval()
    return 10
end


-- Call this function once per PLC cycle. You are responsible for calling
-- it at the interval that you specified in the MCU configuration when you
-- generated this code. */
function VFD_Spindle_controller.PlcCycle()
    mInst = mc.mcGetInstance()

    if     (Read_U_b_FSpindle_CCW() == 0 and Read_U_b_FSpindle_CW() == 1 and Read_U_b_FSpindle_ON() == 1) then
       Write_Register("modbus0/wrtvfdcmd0", 1)
    elseif (Read_U_b_FSpindle_CCW() == 1 and Read_U_b_FSpindle_CW() == 0 and Read_U_b_FSpindle_ON() == 1) then
       Write_Register("modbus0/wrtvfdcmd0", 2)
    else --if Read_U_b_FSpindle_ON() == 0) then
       Write_Register("modbus0/wrtvfdcmd0", 5)
    end

    local spindle_rpm = scr.DroRead(mInst, 27)
    Write_Register("modbus0/wrtvfdspeed0", spindle_rpm/12000*10000)
end

return VFD_Spindle_controller

29
Mach4 General Discussion / Re: Modbus control huanyang GT vfd
« on: November 04, 2021, 05:51:17 AM »
Hi,
Writing your own m3 would result in the speed register being updated only at each occasion m3 is called. Quasi continuous updates ocurr with the code in the plc script and is therefore preferred.
Craig

Yes thats what i thought.. i would like this to function as it was - i.e. not need an m3 cmd to update the speed
 

30
Mach4 General Discussion / Re: Modbus control huanyang GT vfd
« on: November 04, 2021, 05:48:07 AM »
A couple of things to check:
Did you add the .lua file to the PMC and enable it through the screen editor?
Are your register names for the modbus exactly the same as it shows in the instruction? The PMC is writing to these specific register paths so it needs to match.

Yes i have checked the functions are exact as in the script file.  i added the Lua file to the pmc scripts in screen editor.  I feel like its partly working as it is 'activating' the vfd, it just wont spin!


Pages: « 1 2 3 4 5 6 7 8 »