Hello Guest it is March 28, 2024, 11:20:02 AM

Author Topic: Mach 4 Machtric 2.2kw VFD Modbus  (Read 22052 times)

0 Members and 1 Guest are viewing this topic.

Re: Mach 4 Machtric 2.2kw VFD Modbus
« Reply #10 on: January 21, 2017, 05:27:12 PM »
Hi Zuxztah,
have a look at Diagnostics/Regfile. You will see a number of registers. Most of them are defined and/or created by various plugins
but you can define your own as well.

Try this: Configure/Plugins/Regfile- you should see a page with two tabs 'Instance Registers' and 'Global Registers'. Try creating an instance
register (page icon with green cross) and a new register will be formed which you can name, provide a default value and make persistent.
Make one called RegMyTrial with a default of 100 and make it persistent. Click Apply and exit.

Now inspect that new register by Diagnostic/Regfile and expand iRegs0 and you should see the register you created RegMyTrial and its value.
You can edit its value by double clicking. This register could now be accessed or written to by any script in Mach4. For instance you might
store a value of the X co-ordinate when running one of your macros say m100 but later you could recall that number in another macro say m101.
Of course this is just an example, read chapter 4 of the Mach4 Scripting Manual that is in the 'Help Docs' button of the File Ops tab when Mach4
is enabled. It explains the usage of registers. Note also that you could store either a number or a string. I make use of the string store to
record a path and filename in one of my macros which can later be used to open that file in another macro.

For your spindle control problem you are going to allow the MODBUS plugin to define two new registers. They will be seen at Diagnostics/Regfile
and expand modbus0. You could manually edit them there or you could programmatically edit them when you hit a button or execute a script.
You would also be able to see the registers by Diagnostics/Modbus and expanding but note that the only registers displayed there are those which
have been created or owned by the Modbus Plugin, it is not the right place to edit them however.

Once you've got your 485 comm link working and the two new registers defined in the Regfile then you can go on to work out how to manipulate
them.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Mach 4 Machtric 2.2kw VFD Modbus
« Reply #11 on: January 22, 2017, 12:12:11 PM »
Finally it works!  I've been changing the ballscrews on the machine so haven't been able to check the modbus settings until now, and it worked first try? That's just pure luck!

I've posted a new album on postimg.org: https://postimg.org/gallery/prwl03vi/

I guess the Reg file thing you told me to do "RegMyTrial" was for explaining purposes? For me to find the registry editor?

I can now control the Spindle via Register diagnostics by changing the value modbus0/spinCntrl and modbus0/freq with my old decimal commands I talked about earlier:)
Modbus0/Cntrl
8192:
10 Start CW
01 Stop
06 Start CCW
12 change direction

Modbus0/freq
8193:
1000-4000




Re: Mach 4 Machtric 2.2kw VFD Modbus
« Reply #12 on: January 22, 2017, 01:29:25 PM »
Hi Zuxztah,
kool!

Code: [Select]
I guess the Reg file thing you told me to do "RegMyTrial" was for explaining purposes? For me to find the registry editor?
Yes.

Couple of things I see that could do with refinement or experimentation:
Both your Modbus functions have slave address 0 and Modbus address 8192 or 8193. Try the other way around.
The VFD is the slave device and the address of the registers internal to the VFD are 8192 and 8193. Try it and tell
me if it works, I can't test it without a 485 link.
Second item: the two registers are continuous so you could have just one function

Modbus function: Multiple write
Slave address: 8192
Modbus address:0
Nmbr reg:2

ie each time the Modbus function runs it sends both the control word AND the frequency word. It means that the CRC check which must
happen within the Modbus plugin only has to run once.

Another idea that you may wish to experiment with is reading the actual spindle speed from the VFD, in this instance you are not
writing data to the VFD but reading from it. Don't have your VFD manual on screen at the moment but there is a register that has
the current speed, I'm going to guess 8150:

Modbus function: Read single holding reg
Slave address: 8150
Modbus address:0

So you would end up with another register in the Regfile called something like ActSpeed which could be read and then displayed on the screen.

The next item on the agenda is being able to manipulate your control words from a button on screen or an M code. I suggest you have
a look thru some of DTGs videos to get some ideas how to use the 'Edit Screen' function.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Mach 4 Machtric 2.2kw VFD Modbus
« Reply #13 on: January 22, 2017, 01:39:06 PM »
Hi! I tired the other way around this morning I understand that the vfd is the slave unit, in my vfd settings I can choose to set vfd slave adress, which is set to 1 (if I had another vfd it would be slave adress 2)

If you want and have your computer available at the moment then you could could download teamviewer (remote access) and try the settings yourself, super simple and no installation is needed, just download teamviewer 12 and choose run only, and then I send you my I'd and pass,

It is one way operation, I'll need to have your I'd and password to be able to do anything with your computer, it's safe :) no worries :)

The current setup works great, if I go into Regfile diagnostics and change the value on modbus0/spinCntrl to 10 the Spindle revs up, and 01 stops it,

And readout would also be awesome :) I'll try it as you mentioned (8150)
« Last Edit: January 22, 2017, 01:43:17 PM by Zuxztah »
Re: Mach 4 Machtric 2.2kw VFD Modbus
« Reply #14 on: January 22, 2017, 02:14:28 PM »
hi Zuxztah,
8150 was just my guess, read thru your manual to find the actual register number.

For instance my Delta VFD:

Quote
210CH Motor speed (rpm)
- would need to convert 210C to decimal...

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Mach 4 Machtric 2.2kw VFD Modbus
« Reply #15 on: January 22, 2017, 02:25:32 PM »
Hi Zuxztah,
just re-reading your last post and I think you are correct, ie the Slave address is the VFD device number. I wish I could
experiment but I don't have a 485 link. Further my machine is out in the garage and I've pretty much be told, doctors orders' to
stay the hell out of there!

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Mach 4 Machtric 2.2kw VFD Modbus
« Reply #16 on: January 22, 2017, 03:35:02 PM »
I must be really really stupid... my brain doesn't work as it should.. not  what it used to be, due to the disease..

I came up with 0004H = 4 Deci
Or 001B = 27 Deci,
 Tested and confirmed to not work with read holding registers either 16bit or 32bit

The manual is a mess.., at least for me, I find the other data addresses for the previous functions Start and freq:

2000H = 8192
2001H = 8193

And the content Bit1~Bit0 (10B Start) (01B stop) and so on..  but to read the motor speed seems different.

Some pictures of the manual: https://postimg.org/gallery/1g8bophy6/

Re: Mach 4 Machtric 2.2kw VFD Modbus
« Reply #17 on: January 22, 2017, 04:30:08 PM »
Hi Zuxztah,
maybe try 'Read Input Register', looks to me like you have the right address.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Mach 4 Machtric 2.2kw VFD Modbus
« Reply #18 on: January 22, 2017, 04:34:25 PM »
It's just reading the current motor speed state? No further action is needed? Just setup up the modbus configuration and then look for a value in the regfile diagnostics tab?
Re: Mach 4 Machtric 2.2kw VFD Modbus
« Reply #19 on: January 22, 2017, 05:44:54 PM »
Hi,
not quite. The Modbus functions run every 25ms or so, this means that the Regfile register is near enuf to a live value of the
actual motor speed. That register will have to be read and displayed on a regular basis so the display becomes 'live'.

The PLC script is the ideal way to achieve this. The PLC script runs about every 40ms. In that script you will insert some code
that reads the register, probably with some sort of calculation and formatting and display it on the screen. Lets say the register
you have created is called modbus0/ActSpeed

Append to PLC script:
hreg=mc.mcGetRegHandle(inst,"modbus0/ActSpeed")
local speed=mc.mcRegGetValueString(hreg)   --  have read it as a string just to be on safe side
local RPM =tonumber(speed)/10*60   --   convert speed to a number, divide by ten to get frequency and multiply by sixty to get rpm
scr.scrSetProp(droTrueSpindle,RPM)   -- not sure about this statement just yet will have to do some more reading/experimenting

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'