Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations MintJulep on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

XG5000 and Mod bus Command 1

Status
Not open for further replies.

chemipoo

Computer
Apr 5, 2004
10
Hi,

I hope you are well.

I would like to solve the following problem:

There is a LSIS PLC which needs to talk to an Omgega PID controller over RS 485 and with modbus (PLC master - PID slave)

Now, LSIS provides a software to interact with PLC. The S/W is XG5000. From the manuals I have read, so far I am able to set up both the cnet interface of the PLC and the PID controller to have the same settings (baud rate, parity, etc).

But the problem I have is that I do not know where in the PLC I can put the ASCII commands to send to the PID.

The only other thing I can think of right now is that the modbus settings in the PLC software (XG5000 provides a bit and word address range: like word read is p06, word write is p070, etc....



Side note:
In ModBus ASCII, I need to put:

address unit 1 | address unit 2 | Command 1 | Command 0 | ....|End1|End2

Here the string to read the process value of the PID. It starts with ASCII character ':' (3A) and ends with 'CR LF' (0D 0A). Everything in the middle is the protocol definition like address of who receives this, what to do (read/write) and etc.

3A 31 30 33 31 30 30 30 30 30 30 31 45 42 43 0D 0A

Note that code has the beginning 3A which is ':' character indicating beginning of ASCII frame. CR and LF (0D 0A) mark the end.

Thanks for your consideration.
 
Replies continue below

Recommended for you

> address unit 1 | address unit 2 | Command 1 | Command 0 | ....|End1|End2

That is NOT a Modbus ASCII message format, (only one address, one function per message) but that said, your message is close to reasonable.

Your message 3A 31 30 33 31 30 30 30 30 30 30 31 45 42 43 0D 0A decodes as:

Start = 3A :))
Address = 3130 (10h) slave 16 (decimal)
Function = 3331 (31h) (what function is this? did you mean 03h, read holding registers? 3033 ASCII?)
start register = 3030 3030 (00 00h)
end register data = 3030 3145 (00 1Eh)
LRC = 42 43 (BCh)
End = 0D 0A

Is the decoding what you intended?


 
My bad:
start register = 3030 3030 (00 00h)
end register data = 3030 3145 (00 1Eh)

should be:
start register = 3030 3030 (00 00h)
requested register count = 3030 3145 (00 1Eh) (30 decimal)

 
Let's talk generalities, rather than specifics.

If you need to talk either Modbus RTU or Modbus ASCII, you typically have go back to the PLC manufacturer and ask, "what hardware/firmware/software do you have to talk Modbus RTU or Modbus ASCII?" and procure whatever that is i order to implement Modbus on a PLC.

If your PLC doesn't talk Modbus in any form, but talks some other serial protocol, there are commercially avaiable gateway boxes that can be programmed to talk serial on one side and Modbus on the other to do protocol conversions.

Frankly, I'd be surprised if your Omega controller actually talks Modbus ASCII. Does the spec/manual say "Modbus ASCII"?

I suspect it talks the Modbus RTU protocol. Very few commercial PID controllers nowadays talk Modbus ASCII.

Modbus ASCII is a derivative of Modbus RTU without some of Modbus RTU's critical timing requirements, the trade off being a halving of the effective data transfer rate, since RTU transmits binary values, whereas ASCII transmits the two hex values of an 8 bit byte literally as ASCII characters, doubling the amount of bytes for the same information/data.

You mention a 'cnet interface', which is a total unknown to me.
 
Hi Dawn2,

Thanks so much for your invaluable input.

Please find attached the image file pertaining to a read command of Process Value from a PID controller (please zoom in to see everything). Here is a link in case it is not attached:



I converted character by character:

Start of Tx ':' -> 3A
Address if unit 1 and address of unit 2 ( I am not sure whether you combine them or you have to have an ascii for each char, please look at the char. Why do we have address if unit 1 and unit 0 ? 0:
01 -> 31 or you could say 0 1 --> 30 31

Command 1 and Command 2 : 03 -> 33 or 0 3 -> 30 33 (read)

Starting address: 10 00 -> 4130 or 1 0 0 0 -> 31 30 30 30

....

so what do you think?

As for the PID controller, yes, it does accept ASCII protocol in the settings.

Should ASCII data length be 7 or 8? I get both numbers mentioned in different articles and it is confusing a bit.

Now as for sending the message, you have a good point. I have to ask the PLC manufacturer about the s/w utilities that make it work.

Thanks again for your care to educate people. I really look forward to your response.
 
By Cnet means the serial interface. This is the name the PLC manual uses. There is an RS 232 and an RS 485, I am using a 2 wire RS 485 connection.
 
Boy, that protocol example you provided sure looks like Modbus ASCII to me . . .

The example shows you the characters that you would type on the keyboard when using HyperTerminal. HyperTerminal then converts what you type to ASCII for transmission via the serial port.

So the characters in the example have to be converted to ASCII (as you've done) in your routine, unless you're using a terminal tool like Hyperterminal.

Start of Tx ':' -> 3A

Ans: That's correct. Colon is the Modbus ASCII start character.

>Address if unit 1 and address of unit 2 ( I am not sure whether you combine them or you have to have an ascii for each char, please look at the char. Why do we have address if unit 1 and unit 0 ?

Ans: You're suffering from a bad manual writer or maybe a bad translation from Japanese.
There is only a single address composed of two characters.
The address should be:
high order address character, then low order address character.

In the Omron example the slave address was 01, so
high order character = 0, low order character = 1.

The Modbus format requires both characters for the address, so for an address of 01h,

Modbus ASCII would use 30 31 ASCII

Same holds true with the function command, both ASCII characters are needed.
Modbus function command 03h is the most commonly used function: 'read holding registers'.
High order character = 0, low order character = 3.
So the command read holding register, 03h, would translate to 30 33 (ASCII)

> Command 1 and Command 2 : 03 -> 33 or 0 3 -> 30 33 (read)

Ans: You are correct.

So far the message reads (the forum formatting will screw up the columns)

: 0 1 0 3
ASCII: 3A 30 31 30 33

> Starting address: 10 00 -> 4130 or 1 0 0 0 -> 31 30 30 30

Let's assume that the example is correct & works, so that the address for the PV is at 1000h.
(you might want to examine the Modbus map and confirm that the PV is really at 1000h. In fact you might want to fire up Hyperterminal, get a 'read' and see if the PV is really at 1000)

The address is 2 bytes, or 4 characters in hex, 4 characters in ASCII

The conversion to Modbus ASCII is 31 30 30 30, like you proposed.

: 0 1 0 3 1 0 0 0
ASCII: 3A 30 31 30 33 31 30 30 30

Now you have to define how many registers are to be read. If you only want the single value then one value = 0001h or 30 30 30 31 ASCII

: 0 1 0 3 1 0 0 0 0 0 0 1
ASCII: 3A 30 31 30 33 31 30 30 30 30 30 30 31

> Should ASCII data length be 7 or 8? I get both numbers mentioned in different articles and it is confusing a bit.

Ans: Modbus ASCII, by the Standard, is a 7 bit data word.
Modbus RTU is an 8 bit data word. This protocol is clearly Modbus ASCII.
 
Oh your help and knowledge is really useful. Thanks so much!

Yes, it is Modbus ASCII that I am using. Right now I have both PID and PLC setting to 8-bit character set. So I am going off the standard I guess. Btw if you set to 7, does that mean that, for example, 33 will go as 011 0011? I guess it works cause ASCII only has 4's and 3's as the high portion of the byte...


Regarding the hyperterminal, you mentioned checking the 1000H address. That is a fantastic idea but in their manuals I know also that 1000H is the address of PV. Also, I would require an RS 485 to USB converter to hook up to PC and do it and I don't think I want to get that...


Since the RS 485 is between PLC and PID, right now, I just want to have a way to monitor the communication...but the problem is I do not see anything in the PLC software (XG5000) nor in the manuals regarding where to initiate the communication from or what command/function can be added to the ladder logic so that for example when a switch is triggered the PLC issue a command.

Again I really appreciate your time and consideration.
 
The problem with the wrong word size (7 vs 8 bits) is how the serial ports on either handle the data words. It might just work out at 8bits/word. It's worth a try.

Sorry I can't help you on the PLC specifics, I'm just a generic Modbus guy (HMI, SCADA, OPC mostly).

Modbus, until only recently, has been an option on most PLCs, (now it's standard on only a few of the hundreds of models available), so it isn't surprising that you're not finding information on dealing with Modbus for you particular model. PLCs have at least one, sometimes multiple serial ports, but whether Modbus functionality is implemented is firmware/hardware based.

Check with the manufacturer to see what they have to say about Modbus.

Good luck.

Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor