Machsupport Forum

Third party software and hardware support forums. => Modbus => Topic started by: fishin_fl on August 25, 2013, 08:28:31 AM

Title: Problems with Modbus TCP
Post by: fishin_fl on August 25, 2013, 08:28:31 AM
I have been diligently trying to get my modbus tcp to talk between mach3 to my Emerson Sk commander drive.  I called and talked to a tech about this drive and he sent me a file and told me to use it, but he was not familiar with Mach3 but thought it most likely would work.  I set up the drives parameters and ip address and can communicate to the web url with the drive.  I can see al the parameters and know its working via IP.  I then went to Mach3 and tried setting up the Modbus tcp screen. I inputted te information the way I thought it needed to be.  I opened connection and it was successful.  When I go to test starting address I kinda get confused.

Heres the email the tech sent me.  A one liner

With Modbus TCP/IP one simply writes to Parameter #6.42 (as #40642) and #1.21 (as #40121) for control via an Ethernet link.

This is a paragraph out of application I found online using a sk commander.

These are the parameters that we will use for controlling the drive from the network.

The four parameters that we want to include in the configuration are:
Parameter Name
Data Direction         Register          Length               Modbus Command                     Communicator Internal Address
Control Word
Write                     40642             1 Word(s)          [16] Preset Multiple Registers     0x0200
Preset Speed #1
Write                     40121             1 Word(s)          [16] Preset Multiple Registers     0x0202
Status Word
Read                     41040             1 Word(s)          [03] Read Holding Registers        0x0000
Output Speed
Read                     40501             1 Word(s)          [03] Read Holding Registers        0x0002
Control Word Enable
Write                    40114             1 Word(s)          [16] Preset Multiple Registers      0x0204
Reference Selector
Write                    40643            1 Word(s)           [16] Preset Multiple Registers      0x0206

So i setup my TCP screen.  i attached that to.

I have watched the videos on brains, modbus etc.  But still need help  If anyone can shine light on this.  I would be greatly appreciated.

I am wanting to start and stop spindle, and adjust RPM's.
Title: Re: Problems with Modbus TCP
Post by: fishin_fl on August 26, 2013, 08:30:21 AM
I found something in the Advanced manual of the CT drive.  Pg. 16-23.

CT Parameter           MODBUS PLC Register          Register Address (Protocol Level)
X.Y                              40000+X*100+Y                 X*100+Y-1
Examples
Pr 1.02                        40102                                 101
Pr 1.00                        40100                                 99
pr 0.01                        40001                                 0
______________________________________________________________________________
Does this mean that I would put parameter 40642 or 641 which is my control word (Read/Write) as my starting address in the test dialog box?

Then I would be sending the control word there.  I would assume that since the bit to word is broken I would need to convert to Hex or decimal for the Brains?

Then in the brains I would need?
SPINDLE ON->No operation->Formula ( the control word converted to hex or decimal)->then terminated as MOD:O?

Im trying, wow this is something for me.  I think I getting closer but still seems as if the light bulb in my brain is not hooked up. LOL!

Thanks Brooks
Title: Re: Problems with Modbus TCP
Post by: TeaMan on February 03, 2014, 01:34:22 PM
I just happened across this post, and am doing almost the exact thing with a Schneider Electric Altivar 12 drive.  I'm doing mine modbus serial right now, but if anyone has insight as to how to write to the control word to start/stop the drive or the speed output, it would help me dramatically.  I have some things to try tonight, and will see if it's successful.  I'll post back if it is.  Any insight to this one would be helpful and appreciated.

I'm trying to do the inital writes via the modbus test screen.  Maybe that is the problem, but seemed to me like the place to prove concept before I wrote a brain.

TeaMan
Title: Re: Problems with Modbus TCP
Post by: poppabear on February 04, 2014, 05:57:45 PM
Look at your modbus addresses in the drive, make sure they are showing you the "Decimal" address, for the different functions.
If they show you other than decimal modbus address then you will need to convert them to from Octal or Hex to decimal.
In the manual you have, for the different functions, it gives you a base (starting) address, the parameters (and thier conversion), shows you the "offset" needed to get to that functions parameter address in modbus address format.

Often, on most VFD drives, if your going to control it completely over modbus, then in your drives parameters you have to change the "control" parameter, usually they are like some value in some parameter that represents": Keypad control, DI/DO control, or Modbus control (TCP or Serial depending on what your drive supports).

I highly, highly recommend you read the "Brians user guide", in the User docs thread, it goes into doing some modbus stuff, including writing to different groups of registers.

Scott
Title: Re: Problems with Modbus TCP
Post by: TeaMan on February 05, 2014, 02:09:43 PM
Thanks Scott.  I hope I'm not hijacking this thread, but hope your answer may help us both.

I'm trying to write to the control word of the drive, it actually has two addresses, and I'm working with the distributor to understand which to use. It has a line such as this in the manual.

Submenu   On the local HMI, it is parameter Description                          Factory setting parameter                Modbus Address
ICS-           NMA1(nNA1) Source drive address of the 1st input word       Address of ETA=3201 16#OC81     NMA1 address 16#319D = 12701

Which Address would we use, the factory setting parameter address or modbus address?

Also in the manual it shows an example value to do certain functions.  One is for Enable Operation and the example is 16#000F which is obviously hex.  From your previous answer, you mentioned converting to decimal.  I was using the modbus test screen in Mach 3 to send a test message to the drive.  I had chosen hex and put this number in as hex.  Are you saying I should change that number to decimal and send it out to the drive in decimal instead?

Thanks
TeaMan
Title: Re: Problems with Modbus TCP
Post by: poppabear on February 05, 2014, 04:17:05 PM
TeaMan,

Modbus Address: NMA1 address 16#319D = 12701     if I am understanding what your posting then the 12701 would be your modbus address for the control word or the start address of the control word(s).

The Mach3 Modbus function as far as addressing is concerned in the config setup page, is addressing in Decimal. So "Assuming" (Ass out of U and Me), that the 12701 is the modbus address of your control word in Hex, its equivelant value would be: 75521 in decimal. 

Break out the MS windows calculator and under view, pick scientific or programmer depending on your view, enter the value in Hex (with the Hex radio button checked), then click the Decimal radio button, it will convert it for you to decimal).

Your best bet, may be to see if the manufacture has a section in the manual for talking across modbus to a PLC, or can point you to examples or docs about that. That is usually where you can find more useful info on what your trying to do.

Again, IN GENERAL for most manufactures VFD's....  You will need to break out the programming manual or software for your drive, and set up the parameters that are required for you to control the drive over modbus first (to include the baud rate, parity, modbus address, or ether addy, or both).

Most drives will have a place where you can setup "Block" parameter addressing, this simplifies addressing if you have functions that are in vastly diffferent modbus addresses.

Usually the addresses you will need to look for at the most BASIC level is:

1). Control word(s) this is where you talking to the drive for: Status, Monitoring, enables.
2). You may have more control words, or Function control params for:  On/Off, Enable, Run, stop, CW/CCW etc. That may also include blocks for Error messaging/alarms, etc.

again, read the Brains user guide in the member docs,

Scott







Title: Re: Problems with Modbus TCP
Post by: TeaMan on February 05, 2014, 08:24:36 PM
Thanks again Scott.  I learned a couple things tonight messing with my drives. I was able to set some parameters to force a manual mode using a switch.  I then noticed a slider on the Modbus test screen in Mach 3.  I slid it to the right to see what it does, and noticed that I couldn't enter a number to write to the drive anymore, and assumed it was persistently reading from the drive.  I could slide it to the left and put a number in to write, click write and slide it right.  The number I wrote, then remained.  I put the drive in manual, started it forward, and when I pressed stop, the number in Mach 3 changed to 260, I pressed reverse, then stop and it changed to 2308, forward then stop repeated the same number as did reverse.  Made me think those were the codes it needed.  I then shut my switch off and returned to Auto or Modbus and it reported 2311.  I converted all three to binary, but haven't compared them to the bits in the control word to see what bits they turned on, but when I tried to write them to the drive in auto, I didn't get any response from the drive.

I also noticed that after I write a value of any kind to the drive, I get a Modbus communications fault after about 10 seconds which is what the Modbus timeout is set for.  I can't figure out why I'm getting this fault.  When in fault, I can not go to manual and manually start the drive in forward or reverse, but can write a value to the address for the control word and read that value back out.  When I slid the slider to the right, it seemed it didn't fault as fast, but eventually does even then.  It seems for some reason the drive is expecting traffic on the Modbus link, or it faults, which again doesn't make sense to me.

As for the address for the control word, I typed 12701 into the Modbus test screen and read from the address, the number it reported was the other address or "3201".  It appears that address 12701 is some kind of pointer to 3201.  I don't have my head wrapped around that yet either.  I need to get that answered from the drives distributer also.

I have read through the documentation on Brains, as well as the Modbus and advanced Modbus videos that talk about brains and macro's, but wanted to prove I could make the drive operate using the Modbus test screen before I got into working with brains or macros.  It seemed like less to go wrong, and fewer variables to worry about.  I'm either writing to the wrong words, or writing the wrong data to them, or worse, there is something wrong in the drives configuration, not letting the drive take Modbus commands from the computer.

A programming manual is a good idea.  I have not run across one, but it's something to ask the distributer.  I do have a user manual and a Modbus Communications manual.  Neither have been helpful.

Thanks again.
TeaMan
Title: Re: Problems with Modbus TCP
Post by: TeaMan on February 17, 2014, 01:01:49 PM
finally got it to work.  Turned out that the values were going to the right parameters, just in the wrong order.  The speed on the drive since it was just turned on and the memory cleared was zero, asking it to start at zero didn't work too well.  The other issue is the drive needs to see one bit high, bit zero on the command word to enable the drive.  In manual this is done with a normally closed switch coming into input 1.  Break this and the drive stops.  Sort of an estop.  Well same with modbus, you first have to send a 1 to this which can be programmed into the code you send for the stop, then with these two things set properly, you can finally send the command to either run in fwd or reverse.  Then the speed can be manipulated as you wish.

I need to make sure I put something in my macro pump or brain that takes care of the enable before the drive will be allowed to run.  It also will need an initial speed reference.  Probably should set the initial speed for the operation first, then let the drive soft start to that reference when it gets the direction start command.

I'm going to start digging into macro pumps and brains tonight to see what I can learn.  I'm pretty green with anything within Mach3 so I've got lots to absorb.  Kind of pumped though.  Been fighting it for a couple weeks, now I feel like a weight was lifted off my shoulders.

I did have two issues with the modbus test when I was working with it.  One was I occasionally got a CRC error, and occasionally got a lost connection error, or slave not found, I'm not sure what the exact error was.  I'm running serial 232 to serial 485 to the drives that are modbus 485.  It's a short distance, less than 15 feet.  I'm running 38.2 Kbaud.  Maybe I need to reduce that to 19.2 or something.  Might be losing the comm at that speed.

Definitely getting closer.

TeaMan
Title: Re: Problems with Modbus TCP
Post by: poppabear on February 17, 2014, 03:18:05 PM
If your going through a USB to Serial converter your hitting the conversion speed limit.

try lower baud rates, i.e. 19,200    also, look at your drive side, for timeout settins on your coms, it could be faulting out there as well.

Scott
Title: Re: Problems with Modbus TCP
Post by: TeaMan on February 17, 2014, 06:05:14 PM
Thanks Scott.  I was suspecting that I was bumping up against the converter speed.  I will try 19.2k to see how that works.  The drive timeout on the Modbus is 10s, so that should be way large.

much appreciated
TeaMan
Title: Re: Problems with Modbus TCP
Post by: Peter Homann on February 17, 2014, 07:45:56 PM
Hi,

The other problem you may be experiencing is that some USB to RS232 converters will fill their buffer, then transmit the data in a burst.

This can result in the Modbus inter- message gap being destroyed, resulting in CRC errors.

Cheers,

Peter
Title: Re: Problems with Modbus TCP
Post by: TeaMan on February 17, 2014, 10:24:25 PM
I guess I missed the USB to Serial converter reference in Scott's post. I don't have USB, my converter is Serial 232 to Serial 485.  On the 485 side, I have screw connectors that take me to the Modbus 485 to the drives and touch screen.  The problem would either have to be in the serial 232 card in the PC or the 232 to 485 converter.  My next step is to reduce the baud rate and see if that solves it.  The other thing could be Modbus 485 is normally terminated on both ends.  I don't have any terminations because it's a very short run and all three slaves spur from the same connection point.  Nothing is more than 10 feet.

Thanks
TeaMan
Title: Re: Problems with Modbus TCP
Post by: fishin_fl on April 15, 2014, 01:12:11 PM
No worries TeaMan, your not robbing thread.  So were you able to get anywhere with your Drive?  I forgot about the thread and now that my table is back up and running I am now talking the drive setup again.  If you have any insight that might help me, it would be greatly appreciated.
Title: Re: Problems with Modbus TCP
Post by: TeaMan on April 15, 2014, 07:25:41 PM
Yes I did.  I got help from various members, mostly Scott, Poppabear.  He was great to work with and really knows brains and Modbus.  I had various issues from addresses to converters to brains but got it all worked out.  Let me know where you are in your project and what issues you are having and I'll see if anything I learned will help you.  Others may be able to help also.

Ed
Title: Re: Problems with Modbus TCP
Post by: fishin_fl on April 16, 2014, 07:57:34 AM
Well I have just started back at this project.  I am running a Emerson Sk Commander drive with a sm-ethernet module.  This module allows me to communicate over Modbus /tcp or ip.  I did talk to a programming buddy at work with me and said he can help get the control words and parameters setup.  But he can't help with the mach3 brains or macros.  I think I have a mental block when it comes to the brains or macros.  Do you have a layout of the brains that I can look at and decipher.  rive is different but may help me in the right direction.  My programming friend one problem I had was that I never dropped the indicators into the Sm module so that the drive new what the master was sending.

My ultimate goal is to start, stop spindle and control speed.  Hoping later to control vacuum table  dust collector, and various other things.  But first thing is first communication.  I appreciate any help you have.  I did attach sm -module manual of my drive if you want to look at it.
Title: Re: Problems with Modbus TCP
Post by: TeaMan on April 18, 2014, 09:44:28 PM
On the Mach3 side, you basically have to do two things.  First, you have to go into Function Configs and go into the setup Modbus tcp.  What I did was set one config for each address.  If you have more than one address that are next to each other, you can combine them, but I didn't, it made it easier to remember what I was using in my brain.  I then set up a brain to do just what you are trying to do.  It was to start and stop the motors, change direction, and set the speed. Here is the code in my brain.  Hope this helps.
Title: Re: Problems with Modbus TCP
Post by: fishin_fl on April 19, 2014, 10:41:29 PM
Thank you.  I have gotten further. I was able to test commands through the modbus test.  That was exciting.  I did see your attachment though.
Title: Re: Problems with Modbus TCP
Post by: fishin_fl on April 21, 2014, 05:01:54 PM
Just wanted to give everyone an update.  I have gotten further with the SK emerson drive.  It was a bit confusing but I have some good news.  Mach3 will communicate via modbus TCP, you just have to do some moving of parameters within the drive.  If anyone needs the these Parameters just let me know.  I have tested the stop and start via command designated by Emerson controls.  Like forward, stop, and reference select.  Now I am off to try and put this in a brain.  It has deffinitely been a bumped road but I think tha tlight is starting to flicker at the end of the road.  Does anyone know if Modbus TCP and be ran within VB script or Macros?  Or am I only able to use Brains?  Thanks everyone that has helped thus far.
Title: Re: Problems with Modbus TCP
Post by: TeaMan on April 22, 2014, 09:20:57 PM
Sorry the brain didn't attach.  here is one more try.  I went with the brain mainly for speed.
Title: Re: Problems with Modbus TCP
Post by: fishin_fl on May 02, 2014, 12:12:28 PM
Ok I was able to communicate via mach3 over TCP Modbus.  I got one line in brain and it works.  Yaay.  Now I have to figure out how to command the drive to turn cw when spindle on when it's instructed and then send another command to stop spindle for tool change or do program.  I guess that's where Invert comes in? 

So far this is what I have.

Spindle CW On ->  No-OP  ->  Formula A* 131  ->  Mod: 0-T:0
Title: Re: Problems with Modbus TCP
Post by: TeaMan on May 02, 2014, 12:48:15 PM
Take a look at the Brain I posted.  I am starting and stopping the spindle and changing directions.  I do however have to stop the spindle between CW and CCW commands, but thats OK for now.  I also have to send one command to stop the drive and another to reset it so I can start it again, it puts it into ready state.

My brain essentially does three things.  It starts and stops in either CCW or CW directions.  It resets the drive to Ready and it sends the commanded speed to the drive.  It should almost work as is for you by entering the codes into the formulas in the brain to send the proper codes to your drive.

TeaMan.
Title: Re: Problems with Modbus TCP
Post by: fishin_fl on May 02, 2014, 02:16:29 PM
When I get home I will try entering my control words into your full brain.  .  The CMD Spindle RPM is getting a pass signal... Is this getting its input from Spindle setup in settings of Mach3?  I will let you what I come up with.  Thank you for all the help.

Brooks
Title: Re: Problems with Modbus TCP
Post by: TeaMan on May 02, 2014, 03:05:32 PM
you will probably have to do some diting, but you will have a place to start.  The speed uses the G code, S command word.  Example is S800 M3, Which sets the speed to 800 rpm and starts the spindle clockwise.  My drive had two siputs for speed per se.  The one I used was for RPM, the other is for frequency.  Hope this helps.
Title: Re: Problems with Modbus TCP
Post by: fishin_fl on May 05, 2014, 08:30:12 AM
I wanted to update everyone and say thanks for all that have helped.  I have successfully gotten my Emerson Sk Drive to communicate and run with Mach3.  Little confusing but start, stop, and input speed work.  Yaay!  Still need to tweak some stuff but, getting closer.  Next I have to figure out how to pull actual speed off drive to mach3 screen so it know how fast its going.  I was looking around the general setup screen in Mach3 but could not find delay g-code till Spindle reached speed.  Am I looking in the right place?

On another note I installed my new NPN Proximity switches on the X and Z axis that replaced my mechanical limit switchs.  One more axis to do and maybe my intermittent limit trigger will finally be fixed.

Again thanks for all the help everyone.

Brooks
Title: Re: Problems with Modbus TCP
Post by: TeaMan on May 05, 2014, 10:26:21 AM
Brooks, Id be interested in the make and model of your prox switches if you dont mind.
Title: Re: Problems with Modbus TCP
Post by: fishin_fl on May 05, 2014, 05:33:50 PM
I am using2 different types of Prox..  They are made by Omron.

Z-axis using (TL-W3MC1) NO NPN  10 to 30VDC.  These are small and flat.  Approximately a 3 to 4 mm sensing distance.

X-axis using (E2B-M12KN04-WP-C1 2M) Short body, 12mm housing, unshielded, sensing distance 4mm, Pre-wired end, NPN, NO, 2M cable length, 10 to 30VDC

I will be getting another set of the E2B shortly for Y-axis.

Note: When installing I hooked a set of two together per axis for only one input.  Also in your setting you will have click active low for each one.  Other than that all is well.
Hope this helps.

Brooks
Title: Re: Problems with Modbus TCP
Post by: TeaMan on May 05, 2014, 09:58:12 PM
Neat little devices.  Do you find them accurate enough to use for home switches?  How repeatable do you find them to be?

Ed
Title: Re: Problems with Modbus TCP
Post by: fishin_fl on May 05, 2014, 10:06:14 PM
Very repeatable. I am using them as limits and homing. My company uses them on our machines for positioning. We use a range of these devices. I recommend them. 3 wire setup and very easy to hook up. 

Brooks
Title: Re: Problems with Modbus TCP
Post by: poppabear on May 06, 2014, 07:46:59 AM
Quote
Next I have to figure out how to pull actual speed off drive to mach3 screen so it know how fast its going.  I was looking around the general setup screen in Mach3 but could not find delay g-code till Spindle reached speed.  Am I looking in the right place?

Under Ports and Pins > goto the Spindle tab >  look at "General Config" middle column that is spindle spin up and spin down delays in seconds that will not let your G code run until that time period is done.

For the speed coming IN from your VFD, you need to ADD the "True Spindle Speed" DRO on to your screen set, (or a user dro), then put that DRO on your screen set.

Further, you will need to put this into a Macro, and then put that Macros number in the General setup page, under "Init" macros.

SetParam( "RPMOverRide" , 1 ) 'allows external override of dro 39 Then you can use a brain to terminate to DRO #39..

Last thing is, unless your spindle motor is direct drive, you will need to put the pulley ratio under "Pulley Ratio(s)" one ratio for each head gear you have.

Scott



Title: Re: Problems with Modbus TCP
Post by: TeaMan on May 09, 2014, 01:51:06 PM
Thanks for the instructions Poppabear.  I'll give that a try too.

Brooks, where did you get your prox sensors?  I only could find one of them in the online electronic houses.

Thanks
Ed
Title: Re: Problems with Modbus TCP
Post by: fishin_fl on May 09, 2014, 03:29:22 PM
I got the proxs thru allied electric which is a distributor my company uses. I will get po# from him with cross referenced numbers for you. Let me email him tonight. I have order a couple more anyways.

Brooks
Title: Re: Problems with Modbus TCP
Post by: fishin_fl on May 12, 2014, 11:05:28 AM
Teaman,

Alright this is what I got on the prox.  The one I use for z-axis are as follows:  TL-W W3MC1 @ $83.36 each.  Link number one.http://www.alliedelec.com/search/productdetail.aspx?SKU=70178122 (http://www.alliedelec.com/search/productdetail.aspx?SKU=70178122)


X axis I used E2B-S08KNW04-WP-C1-2M  @ $19.00 each.  Link number 2 http://www.alliedelec.com/search/productdetail.aspx?SKU=70331051#tab=overview (http://www.alliedelec.com/search/productdetail.aspx?SKU=70331051#tab=overview)

So far they have worked great for me.  Although the Z-axis prox were expensive I would say worth it though.  I think I would go with a  large OD prox on x and y axis but I am fine with these for now.  Hope this helps.

Brooks