wincio Posted November 26 Report Posted November 26 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.
Gabriel Franco Posted November 26 Report Posted November 26 You need to use a bit type tag to activate the periodic reading. Make sure that PLC serial port communication parameters matches the slaves and the slave ID is correct.
wincio Posted November 26 Author Report Posted November 26 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
Gabriel Franco Posted November 26 Report Posted November 26 42 minutes ago, wincio said: Do I need to indicate a port number for the Modbus expansion? I couldn't find this information anywhere... No, you don´t Post your program here to take a look
MVP 2023 Joe Tauser Posted November 27 MVP 2023 Report Posted November 27 The PMC1 and MATLAB may be using a 1-based Modbus table. Unitronics uses a 0-based scheme. Try changing your read address to 2089. Joe T.
wincio Posted November 27 Author Report Posted November 27 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.zip
pascal Posted November 27 Report Posted November 27 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.
pascal Posted November 27 Report Posted November 27 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 :
Gabriel Franco Posted November 27 Report Posted November 27 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:
wincio Posted November 27 Author Report Posted November 27 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...
pascal Posted November 28 Report Posted November 28 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....))
wincio Posted November 28 Author Report Posted November 28 Hi Pascal, thanks for your indication. I use powerhud modbus tester as suggested. It worked well with the following configuration: 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.
pascal Posted November 29 Report Posted November 29 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 -> 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 correct 2. with rs485 you have the termination resistors of the end of the line set ?
wincio Posted November 29 Author Report Posted November 29 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 1
MVP 2023 Joe Tauser Posted November 30 MVP 2023 Report Posted November 30 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now