Posted 29 Oct 2018 Hi guys, I have an M221 and trying to read process data from a HACH controller via Modbus 485. In the Read_Var function block I need to configure ObjType, FirstObj, Quantity and IndexData. Slave ID is 3 and I am using SL2. So, say if I wanted to read to following registers, Register #40001, Data Type Integer, Length 1, Description- Sensor Measure Register #40005, Data Type Float, Length 2, Description - Sensor Temp Register #40007, Data Type String, Length 6, Description - Sensor Name what do I put into the Read_Var function ? I am completely new to this and it's just not clear to me. Thanks John Share this post Link to post Share on other sites
Posted 30 Oct 2018 @JohnB315 For easy example you could config each parameter on %READ_VAR each block as describe as follow Id: Modbus Slave ID ObjType: Type of data that you read 0 - Read 4xxxx address 1 - Read 1xxxx address 2 - Read 0xxxx address 3 - Read 3xxxx address FirstObj: Which first register at you read (40001 means Holding Register at register 1) Quantity: number of register that you read IndexData: Which %MW number that you need to collect data (such as 1 means use %MW1) If you have understand concept you can use one %READ_VAR block to read data from device by change FirstObj, Quantity and IndexData by use %READ_VAR0.FIRSTOBJ, %READ_VAR0.QUANTITY and %READ_VAR0.INDEXDATA 1 person likes this Share this post Link to post Share on other sites
Posted 30 Oct 2018 Wasan explained it perfectly. But just in case here is a video....not in english but you will get the idea https://www.youtube.com/watch?v=ejsIh7hmbXo 1 person likes this Share this post Link to post Share on other sites
Posted 31 Oct 2018 Thank you Wasan, I couldn't have asked for a better explanation. It worked but I had to offset the address by -1 (40001 = 0, 40002 = 1 etc.) to get a response otherwise it will return an error. Now, the next stage of my confusion, the value in the %MW I get back is random, anything from -322xx to +20000 or 30000. I was expecting something in line with the actual sensor measurement (pH), or do I need to scale it like a mA value ? If so could you please tell me the steps involved ? Also, is there a simple way to view what value is in a %MW while I am online during testing in somachine basic? Share this post Link to post Share on other sites
Posted 31 Oct 2018 8 hours ago, cHud said: Wasan explained it perfectly. But just in case here is a video....not in english but you will get the idea https://www.youtube.com/watch?v=ejsIh7hmbXo Thanks cHud Share this post Link to post Share on other sites
Posted 1 Nov 2018 You use animation tables to view values online Also it could be that the byte order is swapped around of the register you are reading. Try reading a register which has a constant small value in like date or something to do your tests 1 person likes this Share this post Link to post Share on other sites
Posted 1 Nov 2018 Thanks cHud. So, a little update, I have managed to figure out how to display any floating point variable. Take Register #40005, Float, Length 2, according to slave's Modbus map. First, the ObjType is 0 - to access the 4xxxx registers like Wasan said. Then, in my case #40005 - sensor temp. I needed to offset by -1, so FirstObj will be 4. Quantity - the no. of %MW needed, 2 in this case, I used %MW0 and %MW1, IndexData is the starting point, %MW0 Now, I finally realised I need to look at the value of both memory locations combined, either a double or floating word, %MD or %MF %MF0/%MD0 = %MW0 + %MW1, ----- %MF1/%MD1 = %MW1 + %MW2 %MF2/%MD2 = %MW2 + %MW3 ---- %MF3/%MD3 = %MW3 + %MW4 etc. %MFx or %MDx = %MWx + %MW(x+1) All I need to do is put the corresponding %MF in the animation table and boom....there's the sensor reading. Following on from that, can anyone tell me what to do with Register #40007, Data Type String, Length 6 ? Share this post Link to post Share on other sites
Posted 1 Nov 2018 @JohnB315 For string variable you should use Animation Table to show them by Example I have input "TEST STRING" to M0 for 10 words by use %MW0:10 = "TEST STRING" in operation box. Then I create animation table for %MW0 to %MW10 then right click at %MW then select ASCII. They will show data in ASCII string by start from right to left and for each %MW can collect 2 character. Share this post Link to post Share on other sites