Jump to content

Recommended Posts

Posted

Hi everyone and thanks in advance for any help.

I'm working on a field datalogger, based on US5-B10-RA28 hardware equipped with RS485 module, that will read several sensors via Modbus RTU. I tested the hardware configuration with a PC, using MATLAB to query and read the different holding registers belonging to the sensors. But when I start to configure Unilogic Modbus, I can't even receive any information. Maybe I'm using wrong array lenght. I'm posting the matlab working code, the definition of the register from the sensor's manufacturer and the Unilogic program.

Any suggestion is welcome.

 

image.png.54f3bb7dca888dec7ea14af104174742.png

 

image.thumb.png.e72d13b66f100346e5079035c4923088.png

image.thumb.png.466583569bfc34db55c86a3dd4cbe830.png

Posted

Thanks for the fast reply. I have already created the bit type tag called "ActiveR," and it's working to activate communication between the PLC and the sensor slave. However, the Modbus struct variables are always reporting failures. The communication parameters are correct, as I'm using them for MATLAB connection. Do I need to indicate a port number for the Modbus expansion? I couldn't find this information anywhere...

Thx

 

 

Posted

Hi all,

thanks for the support. I tried to change the holding register address to 2089, but had no luck. I noticed that the sensors transmit data using Little Endian order. I used the 4-Byte Swap Type as DCBA under the Advanced panel of Unilogic, which should be the correct byte order for LE.

I'm appending the program sketch and the remote slave Unilogic session below, which is running with different diagnostic parameters.

Thanks for any advice.

V.R.

 

UniStream_070_Data_Sampling_And_Trend_MEDIA.zipimage.thumb.png.35118597b919127680ef1a0912b49488.png

Posted

If you read the manual, then you have to read 10 registers , but your matlab code specifies 5...

you are trying to read data1, wich is an array of 5 reals -> 5x4bytes = 20 bytes

maybe try to read data1 configured as a buffer with 10 bytes and see what this does.

Posted

you want to read 5 reals, but in fact, the value's you want to read are

int32, float, int32,float,float (wich are 20 bytes)

maybe this is the mistake ?

to avoid such problems, just make a buffer of 20 bytes

 

in the help of unilogic :

image.png.f5b8c1590ed08c860687472763a0f20b.png

Posted

According with the reported status (illegal data value), the problem could be related to the type of tag named "Data1", besides it is an array and I´m not sure if the Unitream is capable to fill the array with the read data.

Suggestion: change Data tag to a single element of the array:

image.png.f7ae8e822e510c7161a782fc041773fd.png

Posted

Thanks, Pascal and Gabriel, for your help. I'm back to you with no good news. I used to read 5 registers in MATLAB because it is able to read two of them automatically, so when you write 5 in reality, it's reading 10. The MATLAB code is working fine, and I'm able to collect sensor information directly with no related issues.

I tried using a buffer instead of tags of different lengths before writing in the forum, but it didn't work. I read in the Unilogic manual that it is able to manage vectors correctly. If you try to add another operation line below the first one, it will start from the 11th register.

I'm really lost. I've tried different configurations for the data type, but nothing seems to work.

As suggested byPascal it seems to be a data value problem...

Posted

let's try another software if you can instead of matlab

I use the pc software Powerhud modbus tester tool from powerhud.com

Try with your known values of register start and count to read the data....

I know modbus adressing is sometimes the pain in the XXX -> you have to add 1, or substract 1 of substract 30000, sometimes you don't know....

with powerhud, you really can test it with the values you have to program in unilogic (I don't speak matlab's and it seems that they use a rare system -> you ask 5 registers and they give you 10....))

Posted

Hi Pascal, thanks for your indication.

I use powerhud modbus tester as suggested. It worked well with the following configuration:

image.thumb.png.d4a940a4d4a6e0f04131b9017a5a9340.png

As you can see, to obtain the register values, I need to collect ten addresses. As suggested in a previous post, the first register is the one we want minus 1. In the image, address 2412 is the desired measurement. When converted to a float type under the big-endian column, it gives the correct value. Based on the information I have gathered, I have tried various configuration combinations in Unilogic, but without success. I have also tried deselecting the 4-byte swap type, but so far, nothing has changed. 

Posted

ok, 

have you tried to read into a buffer , instead of an array with 5 reals ?

a buffer with length 20

What I also saw

-> image.png.db1b3eda90d8a54e6109895c6bce377b.png maybe try to change this into General.ON

-> with powerhud, you can read from adress 2409.... what is it with 2089

-> you are sure

      1. communication settings are correctimage.png.96d8a69b8211c9a660b34ee1b1c39b6c.png

     2. with rs485 you have the termination resistors of the end of the line set ?

image.png.fb8bfecf6b300031c06f6a945de3b119.png

 

Posted

First of all, thanks to everyone for helping me. This isn't the first time I've asked for help on this forum, and I've always received superb support.

The problem was simply my fault. I connected the main I/O connector the wrong way around (believe me, it's possible!). Now everything is working fine.

For future reference, if anyone encounters this kind of signal configuration problem, I'm posting a screenshot of the final configuration on the Master side:

  • Tag vectors are working fine. They are 5 addresses long as the sensor values are using two register addresses at a time.
  • The initial correct address number is the desired one minus 1.
  • No word swapping is needed as, in this case, sensors and PLC use the same character order.

Sincerely,

V.R

 

 

image.thumb.png.217d981dedfc8b646a25683a82c5fd43.png

  • Thanks 1
  • MVP 2023
Posted
12 hours ago, wincio said:

The problem was simply my fault. I connected the main I/O connector the wrong way around

Oh, I've never done anything like that.  Wait a minute, how many time have I plugged the Ethernet cable into the expansion port?  The answer is embarrassing.

 

Thanks for getting back to us with your success. 😃

 

Joe T.

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
×
×
  • Create New...

Important Information

This site uses cookies. By clicking I accept, you agree to their use.