Host Engineering Forum

General Category => Do-more CPUs and Do-more Designer Software => Topic started by: PLCwannabe on November 15, 2020, 08:49:08 PM

Title: Modbus Issues
Post by: PLCwannabe on November 15, 2020, 08:49:08 PM
I'm trying to set up a Plc/Hmi combo to monitor multiple stand-alone temp controllers via modbus. I can read all the registers just fine on all the temp controllers, but I can't write to any of the writable locations within the controllers. Initially, i thought there was an issue with the Yokogowa controllers, (there are 2 different types,Yokogowa and Schneider)but then I tried writing to the Schneider controllers with no success either. I'm using the MWX and MWR commands and neither is returning any errors.

 The Yokogawa tech support guy said I need to write to the controllers in hexadecimal format. Doesn't the instruction do this automatically as needed? If not what is the best way to format the data before writing it?
Title: Re: Modbus Issues
Post by: ATU on November 16, 2020, 12:54:30 PM
Try reading from those locations that you are writing to and see what the return data looks like. That might give you some clue,
Title: Re: Modbus Issues
Post by: PLCwannabe on November 16, 2020, 02:21:32 PM
I've already done that and can read the values every second. I guess my main question is, do the mwr and mwx instructions format the data as the slave needs it,(when writing) or does it have to be formatted before?
Title: Re: Modbus Issues
Post by: RBPLC on November 16, 2020, 03:09:09 PM
The MWX command does not format the data to match the device. Any formatting that needs to be done will have to be done prior to writing the data to the device.

Edit: You didn't specify a specific device but if the Yokogawa you're using is similar to the PPC5 being offered by AD, it looks like values will have to be converted to BCD prior to writing to the Modbus registers. The BCDTO command will convert real/integers to BCD that can then be sent using the MWX command.
Title: Re: Modbus Issues
Post by: PLCwannabe on November 17, 2020, 10:19:48 AM
  The PPC5 is the direct replacement for the older UT350 that I'm working with, so I will try the BCDTO instruction today.
Title: Re: Modbus Issues
Post by: Controls Guy on November 17, 2020, 12:08:12 PM
That would be incredibly lame, if the case is that they need BCD-formatted data, but documented it as needing hex.
Title: Re: Modbus Issues
Post by: BobO on November 17, 2020, 12:13:50 PM
That would be incredibly lame, if the case is that they need BCD-formatted data, but documented it as needing hex.

They are effectively the same thing. BCD is just hex without A-F.
Title: Re: Modbus Issues
Post by: Controls Guy on November 17, 2020, 12:22:38 PM
They are effectively the same thing. BCD is just hex without A-F.

For decoding yes, for encoding, no.   They can be displayed without knowledge of which format a number is, as in DL's 'BCD/Hex' (because the interpretation will be in the eye of the beholder), but the number known in base 10 as '24' will be 0x18 in hex, represented as 0001 1000 binary, vs. 0010 0100 if needed in BCD.   Thus you have to know how they're going to decode it before you can encode.
Title: Re: Modbus Issues
Post by: BobO on November 17, 2020, 12:27:13 PM
For decoding yes, for encoding, no.   They can be displayed without knowledge of which format a number is, as in DL's 'BCD/Hex' (because the interpretation will be in the eye of the beholder), but the number known in base 10 as '24' will be 0x18 in hex, represented as 0001 1000 binary, vs. 0010 0100 if needed in BCD.   Thus you have to know how they're going to decode it before you can encode.

0x24 = BCD 24

I understand why they might say hex.
Title: Re: Modbus Issues
Post by: Controls Guy on November 17, 2020, 12:39:37 PM
Right!   However, I think most people are going to come to the modbus transaction knowing the decimal representation of the value they want to transmit.   ('24 Hz' or whatever)  ATU had the real answer -- read some data, look at how that's formatted and you can figure out the slave's encoding scheme.
Title: Re: Modbus Issues
Post by: ADC Product Engineer on November 17, 2020, 03:39:19 PM
If I had a dollar for every BCD=Hex argument that I have ever had, I'd have enough to buy something fairly nice.  Reading the data and decoding it is the right answer and for some devices it is the only way to know for sure.  I can't count the number of times the documentation on cheap instruments has been totally wrong as to data typing, endien order, etc, etc.  Testing is worth the time.
Title: Re: Modbus Issues
Post by: Controls Guy on November 17, 2020, 08:14:02 PM
^ x 100.    The documentation is so often vague, misleading or wrong, and it's so easy to figure out empirically if you have the device, why do it any other way?
Title: Re: Modbus Issues
Post by: PLCwannabe on November 17, 2020, 08:58:36 PM
Quote
ATU had the real answer -- read some data, look at how that's formatted and you can figure out the slave's encoding scheme.

When I read the registers, all the data comes back as a whole number. Eg. if Setpoint is 30.0,  300 is returned. If actual temp is 42.5, 425 is returned. But when I try to write 350 to setpoint, it doesn't work, even though that register is listed specifically as a writable location.
 
Title: Re: Modbus Issues
Post by: Controls Guy on November 17, 2020, 10:18:30 PM
If there's no error it sounds like the Modbus transaction is successful, and the controller is not willing to accept the setpoint for some logical reason, like you need to enable it to accept setpoints from the Modbus or something.

What's odd is that both controllers are giving the same symptoms.  Can you write successfully to either controller with Modbus Poll or some similar utility?
Title: Re: Modbus Issues
Post by: PLCwannabe on December 02, 2020, 11:15:32 PM
 Just a short update to wrap up this thread. I reinitialized the temp controller to the factory default setting and reconfigured the modbus parameters, now everything works great. No number formatting needed.
  The second controller that i tried to write to (Schneider Eurotherm) is just too damn complicated (not to mention way overpriced)and has been replaced by a Solo 9696 from AD. Twice as simple, for 1/4 price. GO AD!!