Hello Guest it is December 14, 2019, 03:24:03 AM

Author Topic: writing modbus coils using LUA for Mach4? how?  (Read 2039 times)

0 Members and 1 Guest are viewing this topic.

Re: writing modbus coils using LUA for Mach4? how?
« Reply #10 on: October 13, 2017, 03:43:31 PM »
Hi Mark,
found this:
http://www.simplymodbus.ca/FC05.htm
which seems to suggest that the embedded data within the function determines whether the coil is set or unset.
At this stage Mach4 is not offering a register for us to apply that data. Simpsons36 post is maddening!

Craig
My wife left with my best friend...
     and I miss him!
Re: writing modbus coils using LUA for Mach4? how?
« Reply #11 on: October 13, 2017, 06:21:22 PM »
Hi Mark,
think I've tumbled to the solution.

What gave it away is: have a look on the Modbus function page where you have declared your registers, the type is listed as Mach Output Register
whereas on the read coil function page it is listed as Mach Output. You will note that I declared a name, fwdrevbit, as the name of the input
to the modbus function which is a Mach output. In Machs outputs page I elected to use Output#1 but could have in fact any valid Mach output...

A picture is worth a thousand words.

Craig
My wife left with my best friend...
     and I miss him!
Re: writing modbus coils using LUA for Mach4? how?
« Reply #12 on: October 13, 2017, 06:24:28 PM »
Nice catch. Makes perfect sense. I'm away from the machine right now but I'll try it over the weekend and I really appreciate the help

you rock :)

Mark
Re: writing modbus coils using LUA for Mach4? how?
« Reply #13 on: October 13, 2017, 06:29:23 PM »
Hi,
sorry I used Output#0 not 1 as in previous post.

Not sure at the moment when trying to set Output#0/fwdrevbit what should be used when trying to get the signal handle. I suspect Output#0, fwdrevbit
is an alias. I know the ESS plugin make good use of aliases but its the first time I've seen another plugin do the same.

The question in my mind is where the alias is valid? One question answered but another three new ones!

Craig
My wife left with my best friend...
     and I miss him!
Re: writing modbus coils using LUA for Mach4? how?
« Reply #14 on: October 14, 2017, 10:25:56 AM »
Craig:

I have not tried using the alias yet. That does indeed make the spindle spin. On the hitachi the frequency is from 0-40000 via modbus since the resolution is .01 hz. It works fine with the frequency <32767 but when I try to use something closer to 24,000 RPM of course then I need the 2nd register value to be updated. So far when I do that I get an error from the VFD I need to look at that a bit more. But it's working a LOT better. Thanks and I'll post something again when I get this all working since I'm sure there are other Hitachi VFD people who will want to do this.

Thanks again

Mark
Re: writing modbus coils using LUA for Mach4? how?
« Reply #15 on: October 14, 2017, 01:46:40 PM »
Hi,
and having frequency resolution to 0.01 Hz is useful why? Your spindle is asynchronous and the frequency displayed or
commanded is not the actual rpm anyway.

Craig
My wife left with my best friend...
     and I miss him!
Re: writing modbus coils using LUA for Mach4? how?
« Reply #16 on: October 14, 2017, 03:02:13 PM »
Don't ask me why ask Hitachi :)

Anyway as it turns out (verified all this with a tachometer) the Hitachi NE-S1 has two registers for the frequency but you have to set the high order one to zero and then populate the low order one with the desired frequency 0-400hz multiplied by 100. So for the full 24,000 RPM on my router you just stuff the 40000 into the low register and the VFD treats it like an unsigned integer and it works fine. I guess they allocated two registers just to be safe and allow for future products. None of this is documented in the Hitachi manual of course other than the fact that there are two registers and that the resolution is .01 HZ.

I still have to hook up the VFD trip stuff so that Mach knows when the VFD throws and error.

Getting closer, fun fun fun.

Mark
Re: writing modbus coils using LUA for Mach4? how?
« Reply #17 on: October 14, 2017, 03:21:03 PM »
Later this weekend I'm going to implement all the stuff you did with Zuxztah in this thread: http://www.machsupport.com/forum/index.php/topic,34023.0.html

After that I guess I'll have to revisit the E-Stop situation a bit.

Thanks!!!

Mark
Re: writing modbus coils using LUA for Mach4? how?
« Reply #18 on: October 14, 2017, 03:27:36 PM »
Hi Mark,
glad to help.

Craig
My wife left with my best friend...
     and I miss him!