Hello Guest it is April 26, 2024, 09:08:28 PM

Author Topic: Modbus control huanyang GT vfd  (Read 3914 times)

0 Members and 1 Guest are viewing this topic.

Modbus control huanyang GT vfd
« on: October 31, 2021, 12:49:00 PM »
Hi guys,
  Just upgraded my VFD to huanyang GT, got modbus connected and talking thanks to the little tutorial
https://caldwellfam.net/bill/wp-content/uploads/2019/04/Connecting-a-VFD-to-Mach4-through-the-Modbus-v5.pdf

I have copied the script as instructed and i have the VFD turning on with the spindle on button, but the spindle is not turning - cant seem to set the RPM.  I dont quite get what i should be looking at!

I can control via regfile initially but now when i enter new values the actual value does not change
Re: Modbus control huanyang GT vfd
« Reply #1 on: November 01, 2021, 04:43:34 PM »
So using the REGFILE i can start, stop and set rpm of the spindle.  But the GUI does not have this effect?  If entered m3 s2000 in mdi, the VFD comes on but no forward signal and 0 rpm........  PLEASE HELP
MB3 ESS
Huanyang GT
Re: Modbus control huanyang GT vfd
« Reply #2 on: November 01, 2021, 05:25:25 PM »
Hi,
in the m3 macro you need to edit it to put a valid number into the register.

Modbus exchanges data with Mach exclusively through the registers. If you want Mach to provide good Modbus data then you must program
Mach to do so.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Modbus control huanyang GT vfd
« Reply #3 on: November 01, 2021, 07:35:48 PM »
Hi,
  Thanks but I am not using an m3 macro, I have added the lua script as above.  When i add the lua code I cannot set the speed using regfile.

If i need an m3 macro would that not only start the spindle after the m3 cmd?  if the on screen button is pressed would that still work??

I'm guessing that lua is the right way to go but I'm no programmer, just a dumb mech engineer!
Re: Modbus control huanyang GT vfd
« Reply #4 on: November 01, 2021, 07:36:28 PM »
Do you know of any good examples that i can find or documentation?
Re: Modbus control huanyang GT vfd
« Reply #5 on: November 01, 2021, 11:37:58 PM »
Hi,
all very well but that script does not seem to work, all in all it seems a complicated way to go about a simple task.

If you enter a valid number into the register 'wrtvfdspeed0' what happens?. It should be communicated to the VFD and if the VFD is turned on by the
other control registers then it will rotate at the speed nominated by the value you just entered.

If you had two-three-four lines of code in the PLC script updating  the register wrtvfdspeed0 from the current S value which is #2132.
Every time you enter a block Snnnn either MDI or Gcode job, and hence #2132 is updated the PLC script will update wrtvfdspeed0 every few milliseconds and
Bob's your Auntie!!!

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Modbus control huanyang GT vfd
« Reply #6 on: November 01, 2021, 11:52:03 PM »
Hi,

Quote
If i need an m3 macro would that not only start the spindle after the m3 cmd?  if the on screen button is pressed would that still work??

You always had to use m3, OR the on-screen button press.....which IS an m3, so no change. The only change is that you require the commanded
speed be placed in the appropriate register....and the MODBUS plugin will look after transmitting that to the VFD.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Modbus control huanyang GT vfd
« Reply #7 on: November 02, 2021, 03:14:16 AM »
So if I use regfile and update the register manually, the spindle turns on, changes speed etc.
When I say I'm not using M3, what I mean is I'm not using a separate M3 macro.
What script to have in the plc script is my problem, as I mentioned I'm no coder. I have tried to figure it out using PMC but no luck.
Re: Modbus control huanyang GT vfd
« Reply #8 on: November 02, 2021, 06:56:23 AM »
Hi,

Quote
So if I use regfile and update the register manually, the spindle turns on, changes speed etc.

Exactly, that proves if the register is updated then everything works.

Quote
When I say I'm not using M3, what I mean is I'm not using a separate M3 macro.

You ARE using m3, and note it is m3 NOT M3. m3 is a Mach4 built-in macro, it's there whether you like it or not. You may also write your own m3.
When Mach encounters an m3 call it will in the first instance looks in the macros directory of your profile, if it finds an m3 there it uses it, if not it searches further
up the directory tree until it finds an m3 to use, usually the built-in m3. This is a time when you MUST use proper notation, ie m3 not M3. Get used
to using lowercase, without leading zeros and without whitespace, this is how the Gcode interpreter parses the Gcode. When the interpreter is looking for
m3 for example its likely to miss M3, it's looking look a lowercase m.

So you have two choices:
1) Write your own m3. It will live in the macros folder of your profile. It will need to include everything that the built-in m3 includes PLUS whatever
else you want, which in your case would include updating the three registers that control the VFD.
2) Use the provided script, but which for whatever reason fails to update the speed register by adding a little code in the PLC script.

The script will be something like this:

local registerHandle=mc.mcRegGetHandle(inst,.....Path)  -- Substitute Path with the full path to register wrtvfdspeed0
local speed=mc.mcGetPoundVar(inst, 2132)
speed = speed*...........    -- You may need to do some arithmetic on the pound variable to bring into into line with the number the VFD expects.
mc.mcRegSetValue(registerHandle,speed)

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Modbus control huanyang GT vfd
« Reply #9 on: November 02, 2021, 03:57:45 PM »
Ok, i know i AM using M3, what i meant was i am using the built in M3 as opposed to a separate macro file.
If i put this script in an M3 macro would the command to write the register function if the gcode gave an change of rpm? if i enter separate commands in the MDI i can make this change with simply s5000, so in this case would not call the M3?