Hello Guest it is April 27, 2024, 09:30:05 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.


Messages - barneskite28

Pages: « 1 2 3 4 5 6 7 8 »
11
Mach4 General Discussion / Re: Modbus control huanyang GT vfd
« on: November 08, 2021, 02:04:47 PM »
Hi Joe,
  unfortunately the path does not include the 'function0', but i tried it anyways and still the same :(

12
Mach4 General Discussion / LUA set modbus register
« on: November 07, 2021, 10:16:18 AM »
Hi Guys, this is a follow on and a broader question to scripting gurus....

I have a modbus connection, and i am trying to update the register from the cmd rpm but i am having no luck.  Joeaverage has been helping me but i am still not successful, would much appreciate dazthegaz or anyone else taking a look at this for me please?
The spindle specs
12000rpm
register values 100% = 10000 etc

Code: [Select]
local registerHandle=mc.mcRegGetHandle(mInst,"modbus0/wrtvfdspeed")
local commandedSpeed=mc.mcSpindleGetCommandRPM(mInst)
local registerValue=(commandedSpeed/12000)*10000
mc.mcRegSetValue(registerHandle,registerValue)   

this does not seem to be writing the register as expected, any help appreciated!

13
Mach4 General Discussion / Re: Modbus control huanyang GT vfd
« on: November 07, 2021, 09:49:05 AM »
I can confirm it is still the speed register not working/updating

14
Mach4 General Discussion / Re: Modbus control huanyang GT vfd
« on: November 07, 2021, 07:23:02 AM »
Hi,
I have just got back from work, been shifting stuff all day and I'm buggered again! I'm beginning to think that going to Church on a Sunday
may not be such a bad idea after all.

Craig
wow must be bad lol

15
Mach4 General Discussion / Re: Modbus control huanyang GT vfd
« on: November 07, 2021, 07:22:27 AM »
Hi,
I would guess at least a part of the code that you have installed is working, ie the VFD turns on and off and you can select FWD or REV,
so to bin it would be to 'throw the baby out with the bath water'.

What I would suggest is to put the proposed code in a macro so that you can run it in the editor.  Once you have established that it works
to your satisfaction and you understand it thoroughly then and only then install it in the PLC script.

The reason I suggest this is because a macro executes just once, if there is a problem with it you can stop it, and/or single step through the code
until you understand what's going on. If you put it directly in the PLC script it will run every few milliseconds, and if it does something strange you may have
to crash Mach to get it to stop, not ideal.

For no particular reason lets call the macro m666:

Code: [Select]
function m666()
     local mInst=mc.mcGetInstance()
     local registerHandle=mc.mcRegGetHandle(mInst,"modbus0/wrtvfdspeed")
     local commandedSpeed=mc.mcSpindleGetCommandRPM(mInst)
     local registerValue=(commandedSpeed/12000)*10000
     mc.mcRegSetValue(registerHandle,registerValue)
end
if(mc.mcInEditor()==1)then
     m666()
end

Try installing that in the macros folder of your current profile. You need to single step through it using the debug functions of the editor.
Using single step is the sure-fire best way to understand how your code works, and even more importantly when it does  not work!

Craig

So i have done as you suggested, i have saved the macro into the macro folder as m666 an if i go to the mdi, enter m3 s2000, i have the same result - power but no rotation.
then i enter m666 to call the macro (screen dro displays 2000 rpm) nothing happens so no better  :(

16
Mach4 General Discussion / Re: Modbus control huanyang GT vfd
« on: November 06, 2021, 05:32:45 PM »
should i bin the rest of the code or append this into it?


17
Mach4 General Discussion / Re: Mach 4 Wont save Configuration
« on: November 06, 2021, 11:04:21 AM »
I had a similar behaviour with the machine units settings.....

What helped for me was to open mach, locate the config file in the mach folder, delete the file and close mach.  This forces mach to re write the config file and the setting stuck.

Maybe it will help!

18
Mach4 General Discussion / Re: Modbus control huanyang GT vfd
« on: November 06, 2021, 10:15:27 AM »
Hi,
first please post a screen shot of the Regfile diagnostic, I need to see the register path.
Second, what number do you have to set in the register to cause a given speed?

Craig

19
Mach4 General Discussion / Re: Modbus control huanyang GT vfd
« on: November 06, 2021, 10:12:08 AM »
Hi,

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

But it doesn't go in the spindle control file, wherever it is and whatever it is, it goes in the PLC script. The code is not completed,
you have to add some details, you'll not just be able to paste it in as is.

Craig

ok, so i pasted this  code into the Lua file that i posted earlier in this thread, which is called as a PLC script (selected in screen editor). This LUA file is called spindle control - hope this clarifies!

Unfortunately i am not so familiar with coding, scripting and writing macros so forgive my ignorance!
I have attached a screen grab of the regfile and modbus window, and below the code as is at the moment

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

20
Mach4 General Discussion / Re: Modbus control huanyang GT vfd
« on: November 06, 2021, 06:46:22 AM »
Hi,
I gave you the outline of what is required in post #8. Did you try it?

Craig
I noticed you have posted about this kind of thing a while ago - Do you use modbus spindle control yourself?  If so do you mind sharing the script?

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