LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing Float Value to Delta PLC using MB Ethernet Master Query

Solved!
Go to solution

Hello Friends,

I am trying to write float value to Delta 12SE PLC registers using MB Ethernet write multiple registers function. I wish to write exact value e.g. 25.48 to registers but it is writing only 25.00. I have gone through multiple links on the forum like below but failed to understand the exact solution. 

https://forums.ni.com/t5/Instrument-Control-GPIB-Serial/how-to-write-floating-point-value-in-modbus/...

 

https://forums.ni.com/t5/LabVIEW/How-can-i-write-the-floats-value-in-Unitronics-vision230-plc/td-p/8....

From this link I got logic as : Take a single (4 bytes). Flatten it to a string (4 bytes) Split this string into two parts of 2 bytes each. Typecast these into u16 (16x2=32 bits).

 

I tried to code it but failed to code it actually.

 

I would appreciate if anyone can help me if there is any ready to use solution which I can opt. 

Thanks.

0 Kudos
Message 1 of 9
(6,179 Views)

Then you should attach your code that failed so we can see what you did and make suggestions on how to fix it!

0 Kudos
Message 2 of 9
(6,168 Views)

You need to create 2 U16 values with respect to the float values and then write it to the plc. BElow is a reference image for you.

ed.PNG

 


CLD Using LabVIEW since 2013
0 Kudos
Message 3 of 9
(6,151 Views)

You can typecast the float to a 1-D array of U16.

 

The one thing you may have to watch out for is if you need most significant or least significant word first.  If it is wrong, you may have to swap the U16 elements.

0 Kudos
Message 4 of 9
(6,147 Views)

Thank you Kartik. I tried as suggested however I am getting 2.819 value on PLC side when I pass 20.47 through LV. Please refer attached vi for your reference. 

 

Even when I tried reading float value from PLC using exact reverse way of write code, I am getting different value on LV side.

 

Not sure if I am missing anything on LV side or PLC side.

 

Thanks.

0 Kudos
Message 5 of 9
(6,135 Views)

Thanks Raven. As suggested I have swapped hi and lo values in vi attached above but no luck. I am getting different value on PLC side.

 

0 Kudos
Message 6 of 9
(6,134 Views)

You are writing the values correctly but the problem is when your read. You are writing a double float and while reading you are reading it in float thats why you are getting that value (2.819). Upload your vi where you read it.


CLD Using LabVIEW since 2013
0 Kudos
Message 7 of 9
(6,130 Views)

I am getting 2.819 on PLC side. Please refer attached image.

0 Kudos
Message 8 of 9
(6,127 Views)
Solution
Accepted by fagcontrols

Hello All,

Have gone through couple of more blogs and modified the code. It worked. Now I am able to write the exact value to PLC and also can read the written value from PLC to LV. Attached the vi for reference.

Thank you Kartik and Raven for the help. Appreciated.

 

https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019O2SSAU

image.png Thank you.

0 Kudos
Message 9 of 9
(6,121 Views)