Hello Guest it is April 23, 2024, 07:30:36 AM

Author Topic: Mach modbus inteface info?  (Read 29554 times)

0 Members and 1 Guest are viewing this topic.

Mach modbus inteface info?
« on: January 20, 2009, 02:46:10 PM »
Hi Guys,
I'm looking for some mach 3 modbus info.

I have a new mill I've interfaced to mach. The spindle has the usual 0-10v input on the VFD to control spindle speed, I currently have that hooked up to the PC via an SD to 0-10v board. This results in a Digital (mach) to analog (SD to 0-10) to digital (VFD 0-10 to speed) chain – which is rather nonlinear and hard to calibrate.

The manual for the VFD I'm using says it also has an rs-485 input and accepts what appears like it may be modus as a command structure. So I thought that a better way might be: mach mobus serial out (digital) to rs-232-rs-485 level conversion to the vfd rs-485 input. This would eliminate the analog conversions from the path.

I'm not real familiar with the modbus protocol so have been reading stuff off the web.

I think the vfd looks like a modbus slave and I think mach acts a mod bus master?

What I'd like is a pointer to detailed info (messages, sequences, formats etc)  on what mach puts on the serial port when modbus serial support is enabled. I'm particularly interested in messages resulting from M3, M4, M5 and S codes. (Note that I'm not looking for the Holman mod-io info, which I have - right now I'm trying to figure out if I could do a PC serial port direct (other than sio level translation) to vfd hook up approach).

Is there a doc that details how one would interface a modbus device to mach via the serial port?

Dave
Re: Mach modbus inteface info?
« Reply #1 on: April 24, 2009, 03:45:45 PM »
http://www.modbus.org/ is where MODBUS protocol is described, you can download the documents.
Re: Mach modbus inteface info?
« Reply #2 on: April 24, 2009, 03:51:02 PM »
I have a question from my side:

If I want to build a ModBUS device, what MODBUS data types are to be supported?
e.g. there is a simple source code that I could use, but it supports 3 and 16 (read registers, write multiple registers)

In fact I would not like to use "coils" for discrete inputs, but rather use a register for multiple inputs / outputs.
With this I could save lots of MODBUS bandwidth, but of course the MODBUS plugin has to be able to support this...

Any hints regarding this?
Re: Mach modbus inteface info?
« Reply #3 on: May 10, 2009, 06:10:05 PM »
Hi Guys,
I have a new mill I've interfaced to mach. The spindle has the usual 0-10v input on the VFD to control spindle speed, I currently have that hooked up to the PC via an SD to 0-10v board. This results in a Digital (mach) to analog (SD to 0-10) to digital (VFD 0-10 to speed) chain – which is rather nonlinear and hard to calibrate.

I'm with you - with even cheap VFD's supporting RS485, direct control over the VFD is the way to go.  You get less complexity (on the hardware end), more accurate control and the ability to do things like monitor load and error codes.  I'm suprised more people don't seem to do it this way... that was until I ventured down the path to figure out how to get Mach3 working with my Modbus VFD.  Long story short - it took about 20 hours of research, testing and learning about Mach3 "oddities".  In the end I did get it working and it works pretty good.  Not perfect but it works for me.

Let me know if you have a specific question and I can see what I can do for you.  I've got a Teco CV-2003-H1 from FactoryMation I'm using.
 
Re: Mach modbus inteface info?
« Reply #4 on: June 02, 2009, 06:33:32 PM »
I'm waiting on my spindle and VFD but see things the same as you guys. Why have mach pulse and put a freqency to voltage board in the mix when direct comms are possible? My VFD is a Huanyang HY02D223B with limited docs on the rs485 interface. Can you post how you set yours up so i can avoid probably 400hours of research :)

Cheers

Mark
Re: Mach modbus inteface info?
« Reply #5 on: June 06, 2009, 06:12:58 PM »
Mark -

Here you go.  Be aware that this may not be the best method but it seems to be working for me.

The code below works with the following VFD:
http://www.factorymation.com/s.nl/it.A/id.5578/.f
TECO 7300CV AC Drive, 3 HP, 230V 1 PH Input, 230V 3 PH Output, 10.5FLA, IP20, Frame 2 (JNTHBCBA0003AC-U)

Contents of Macropump.ms1:

Dim TspinRPM As Integer
If TSpindRPM = 0 Then 
   SetParam("RPMOverRide",1) 'allows us to over-write the TRUE RPM DRO
   RunOnce = 1 'set the flag so this code doesn't run more than once in a session
End If

'Spindle Speed Routine
CurrentSpindleOverRideSpeed = GetOEMDRO(202)
FinalOutputInHz = CurrentSpindleOverRideSpeed * 1.6695 'this is used to correct for actual speed
SetUserDRO(1001,FinalOutputInHz)

'Spindle Power-up/Power-down Routine
If GetOEMLED(164) Then 'check to see if the spindle is moving CW
   If Not GetOEMLED(800) Then 'check to see if we are in reset
      If GetUserDRO(1001) = 0 Then  'the spindle is at zero rpm,
         SetUserDRO(1001,10000) 'Set the spindle to 100hz
         Code "S12000" 'set the spindle speed DRO to default off zero
         Sleep 1000
      Else
         SetUserDRO(1000,1) 'start spindle
         SetOEMDRO(39,CurrentSpindleOverRideSpeed)
      End If
   Else
      SetUserDRO(1000,0)
   End If
Else
   SetUserDRO(1000,0)
End If

'Spindle Error Control
CurrentVFDErrorCode = GetUserDRO(1002)
Select Case CurrentVFDErrorCode
   Case 0
      'nothing is wrong
   Case 44
      'Modbus communications error
   Case 11
      'Over Current during accelerating
      DoOEMButton(1021) 'hit the reset button
      Message("SPINDLE: Over current during accerlation")
      SetUserDRO(1000,8) 'reset spindle   
   Case 11
      'Over Current during decceleration
      DoOEMButton(1021) 'hit the reset button
      Message("SPINDLE: Over current during deccerlation")
      SetUserDRO(1000,8) 'reset spindle            
   Case 30
      'Can not start spindle at 0 RPM
      DoOEMButton(1021) 'hit the reset button
      Message("SPINDLE: Cannot start spindle at zero RPM")
      SetUserDRO(1000,8) 'reset spindle      
   Case Else
      'trap
      DoOEMButton(1021) 'hit the reset button
      Message("SPINDLE: Other error #" & CurrentVFDErrorCode)
      SetUserDRO(1000,8) 'reset spindle
End Select
   
'Spindle Load Update Routine
CurrentSpindleLoad = GetUserDRO(1004)/10
SetUserDRO(1100,CurrentSpindleLoad)

See the attached "MacroPumpInterface.brn" Brain file.

You will also notice that I used UserDRO(1004) to store the current spindle load.  I then use that on a modified screen to display the load.

Hope that helps.
david
Re: Mach modbus inteface info?
« Reply #6 on: June 07, 2009, 01:22:10 AM »
Thanks David.
It's always easier to get a start once you can see how others have proceeded.

Cheers

Mark
Re: Mach modbus inteface info?
« Reply #7 on: June 26, 2009, 07:28:54 AM »
What do you do if you want to output serial to a non-standard modbus?

The structure of how Mach makes up a modbus string is unfortunately not how I need to communicate with my Huanyang VFD which has a structure of a single byte address, a single byte function (which don't adhere to modbus standard), a single byte date length indicator, 1,2 or 3 byte data depending on the Length specified and then a two byte CRC.

I can fully control the VFD via the usb port (usb to rs485 adapter) using some VB scripting..... how should I best proceed to replicate this control within Mach?


BTW My programmer friend has posted over on the zone the test app (search Water cooled spindle step by step) if anyone wants to experiment and has one of these VFD's

Cheers

Mark
Re: Mach modbus inteface info?
« Reply #8 on: June 27, 2009, 05:38:30 AM »
Ok I take some of my lasty statement back.

The Huanyang VFD does (for the most part) fit the ModBus standard.. as I've read it from www.modbus.org . However Mach seems to force you to enter a StartC or Modbus address of 2 bytes as part of its framing rather than leave this as part of the Data field.

RTU framing as per Modbus is:
1 byte slave address
1 byte function (which is workable with the Huanyang except 02 and 03 are seen as writes in it rather than reads)
N x bytes data
2 bytes CRC

Can you configure Mach to act this way or are you forced to enter the fields as it desires?

Ie. if the Modbus Var(start reg)  and # of registers was just left as part of the data field n bytes long

It seems as if Mach has predefined the string based on what one board may need rather than a generic Modbus standard.

What am I missing? Or am I setting it up incorrectly. Is there another way to serially communicate out of Mach rather than using the inbuilt Modbus (ie do I need to write VB scripts for everything including the CRC calc)

Help!

Thanks

Mark
Re: Mach modbus inteface info?
« Reply #9 on: June 28, 2009, 08:07:57 PM »
Hi Mark,

If the message format is as below, then it does not meet the modbus spec. Mach3 uses a Modbus compliant library. There is no way to make it non standard.


1 byte slave address
1 byte function (which is workable with the Huanyang except 02 and 03 are seen as writes in it rather than reads)
N x bytes data
2 bytes CRC

I'm thinking of making a small converter board that takes in Modbus on one side and outputs the Huanyang  protocol on the other.

Cheers,

Peter.
« Last Edit: June 28, 2009, 09:14:46 PM by Peter Homann »
----------------------------------------------------
Homann Designs
http://www.homanndesigns.com
email: peter at homanndesigns.com