Sign in to follow this  
Followers 0
machinebuilder

Modbus Help

16 posts in this topic

Having trouble reading to registers in a servo drive.

I have a micrologix 1400 ser B. I enabled modbus and re-cycled the plc. It shows it is enabled. The register I am trying to write to is 6000. It is a double integer. See attached picture. I do not see any

errors. I type numbers into N7:0 and I do not see the number in the servo drive. Can anyone see what I might be doing wrong or missing?

 

sending.jpg

Share this post


Link to post
Share on other sites

We most often have to add 1 to the address supplied by unit manufacturers for use in these Modbus instructions (RTU or Modbus TCP). Ill have to assume that the instruction is actually running (since it's in the Main Ladder and the status indicates Remote Run that is probably a safe bet)

 

Is it possible the unit documentation expressed the address in hex? If so you will have to convert that to decimal.

Edited by b_carlton

Share this post


Link to post
Share on other sites

Thanks for the info. Yes, that rung is running continuously. The modbus address supplied are in decimal. Just for kicks, I converted them anyhow and it still does not work.

I connected an Automation Direct PLC and within 5 minutes I had it working. So I would say the servo drive is configured correctly and capable of modbus tcp/ip. I hate to pull the AB plc out and have to re-wire for a different plc.

Any other thoughts to as why the AB 1400 does not work over the modbus tcp/ip?

 

Oh tried the add 1 to the address. still did not work. Will give it a couple more trys tomorrow, then out it comes!

Share this post


Link to post
Share on other sites

The mapping is only needed if the Micrologix will be a Modbus server.

Share this post


Link to post
Share on other sites

If it were me, I would change the rung so that I could execute the MSG instruction just once, instead of re-triggering it automatically.   That will let you see if there are error codes being generated by a failed MSG instruction.

The other common diagnostic technique is to set up a Modbus/TCP Server on your computer and see if the PLC can read and write to that.

I've had some trouble with Modbus/TCP devices handling the Unit Identifier;  some needed it to be 255, some needed it to be 1.    In one case, it needed different Unit Identifiers when sending different Modbus function codes to the same device (don't get me started...).

Share this post


Link to post
Share on other sites

First, I do not need to do the mapping. That is only required if I was doing Allen Bradley Ethernet/Ip. Since I am doing Modbus, that is not needed. I checked with the manufacture of the servo drive, and i would have needed to specify I wanted to do Ethernet/Ip. that is an add on. But the drive will do Modbus Ehernet/IP.

 

Second, I will check the Unit Identifier. I tried 0 and 1 but was thinking of trying the 255. I will try that tomorrow.

Third. I had someone check the label on the PLC for me to see if it was a version A or B. I was told it was B. Funny thing when i hooked up for 1st time and sucked out the plc info. it came up as A. It was hard to see in the cabinet, being the label is on the side of the PLC. I will personally check tomorrow, and if it is A, I am going to be pissed.

For those who work a lot more with AB then I do, when you hook up to the plc and auto config, is it by default it says series A? Maybe that is a default thing. Well anyhow I created a new project and selected 1400 Ser B. When I downloaded for the first time. it warmed me the versions did not match. Is the software smart enough to compare? How  accurate is the software reading the PLC info?

 

Share this post


Link to post
Share on other sites

Up date. I have it working. Ken, I took your advice and actually eliminated the reset on error. An error did show up. It said bad address. After converting numbers and finally trying them all. It turned out I have to add 1. I was looking to write to address 6000. I had to use 6001. Funny thing, I tried that at first signs of trouble and it did not work. Not sure if I changed something other then adding the 1 before this. Also it was a series B PLC. I left the unit number at "0".

The biggest help was not resetting on an error bit.

Sometimes it just helps to hear others give their suggestions no matter how small it may sound. It get you thinking.

This forum is awesome.

Share this post


Link to post
Share on other sites

Sorry, seems I have another issue. I am trying to read from the Drive, 32 bit, to the Allen Bradley. I tried N7, F8 and no luck. Says the processor can not process the info. If I set it to N7:20 and select 16 bit for data, I see the info coming in but only can display part of the number, around 32000, then it goes negative. I need to import the data into a 32 bit word. I do not see how I can do that. The N7's are 16 bit. I tried telling the data is 32 bit, then I get a large number in n7:0 and then a -1 in N7:1. Any ideas?

Share this post


Link to post
Share on other sites

Read into two adjacent N registers. Then do

 

CPW  (first N register)  F register  2

 

Example from one of my programs    CPW #N40:2 #F42:1 2

 

This copied the 32 bit pattern from N40:2 and N40:3 into F42:1

Edited by b_carlton

Share this post


Link to post
Share on other sites

You should read the data into an N-register array;  the A-B implementation of Modbus is built around 16-bit integers, which is very common.

Whether you CPW those into an F (floating point) or L (long integer) depends on if your data is encoded as an integer or as a IEEE 754 single-precision floating point value.

Try both.   

An important note about the Length argument:  in the ordinary Copy (COP) command, the source and destination must be the same datatype (N-N, F-F, L-L, etc).   The Length of the COP instruction is the number of Elements.

In the Copy Word (CPW) instruction, the datatypes can be different.   The Length argument should be the number of 16-bit Words.

 

That's why Bernie's example of copying N40:2 and N40:3 (both 16 bit) to a single F42:1 (32-bit floating point) element used a length value of 2, for 2 Words.     

This is slightly different than with ControlLogix, but that's another topic for another day.

Edited by Ken Roach

Share this post


Link to post
Share on other sites

The CPW did not seem to work. I got a 4.12445e3-xx after executing.

What I see from N7:0 and N7:1 is N7:0 is good up to 32767 the it goes neg. In N7:1 I get a 1,2,3 depending how far the number in N7:0 goes. Not sure I need to do a high/low word swap.

I do not see how to do that with the 500 software. Also concerning seeing numbers like 1,2,3 in N7:1.

I just can not believe it is difficult to read a 32 bit number into a AB plc. Ref, the number I am trying to read from the drive is on Modbus address 8002 & 8003. So it looks like it is coming to the plc on 2 16 bit addresses.

Share this post


Link to post
Share on other sites

Hi Ken,

I created a Long Data Type and it works perfectly. How do you guys find out this info.

I have not tried it yet, but it should work in reverse also. I should be able to take the Long and use CPW to2 16bit modbus addresses back to the Drive? So

CPW #L9:0   #N7:0 2

Share this post


Link to post
Share on other sites

I'm sorry that I misinterpreted your first post on reading this 32 bit value as it was to be interpreted as a float (possibly because you mentioned F8).

Share this post


Link to post
Share on other sites

Hi b_Carlton, that is quite alright. It got things rolling. I haven't had a chance to try the reverse yet. I will tomorrow. I am a little surprised there is no double words in the micrologix. You have to build it. I was a little confused on the LONG. the way it is listed in the list, I thought maybe it was a LONG String. I was expecting under integer, to be a selection for 16 bit or 32 bit.

Share this post


Link to post
Share on other sites

Concerning double words (Long) in the Micrologix. Yes it's not a default but it is available. One problems is - the lack of instructions which support them. I don't have the reference here but I believe none for Multiply or Divide. I think they can be used in Add and Subtract. You can use Float (Real) but then you have to be aware of significant digits limitation.

In then end sometimes you have to view the PLC as a pure computer, check what it has available as far as registers and instructions, then use that to achieve your purpose. In other words you have to think 'below the instruction'. By this I mean imagine what is happening in the actual CPU. For this it helps to have a background programming microprocessors using their lowest level instructions.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0