Hello Guest it is April 25, 2024, 08:02:34 AM

Author Topic: Problems with Modbus TCP  (Read 22141 times)

0 Members and 1 Guest are viewing this topic.

Problems with Modbus TCP
« 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.
« Last Edit: August 25, 2013, 08:34:48 AM by fishin_fl »
Re: Problems with Modbus TCP
« Reply #1 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
Re: Problems with Modbus TCP
« Reply #2 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

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: Problems with Modbus TCP
« Reply #3 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
fun times
Re: Problems with Modbus TCP
« Reply #4 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

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: Problems with Modbus TCP
« Reply #5 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







fun times
Re: Problems with Modbus TCP
« Reply #6 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
Re: Problems with Modbus TCP
« Reply #7 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

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: Problems with Modbus TCP
« Reply #8 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
fun times
Re: Problems with Modbus TCP
« Reply #9 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