Announcement

Collapse
No announcement yet.

BRX Do-More Modbus Float32 Conversion from two 16bit Words

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts


  • BRX Do-More Modbus Float32 Conversion from two 16bit Words

    I've been trying to convert 2 16 bit integers into a float 32 value with the BRX PLC. I haven't done this in a few years but the last time I did was on an AB PLC, I believe you just needed to copy the two integers. I've searched and searched and I just come up with links to floating point conversions that make no sense. The 2 16 bit values I'm polling in to the PLC are correct and if I use Modbus poll, set to big Endian float32 on the two registers, I get the correct value. Has anyone actually done this in a BRX? I'm getting pretty frustrated because this should not be very hard, I spent the first half of the day converting a stupid Siemens Float 64 formula to work on this, IDK....


  • #2
    I should follow this up with this, so no one wastes their time in this area, I do not want to know the math behind this, I do not care today and it will only aggravate me further. I understand why a thoughtful reply would include this but it would be a waste of time, I used to know how and why but there is only so much room in one's brain for stuff. I only care about the conversion relevent to the BRX or even any Ladder logic, if I could find my old AB files I could see how I did this several years ago when I still cared.

    Comment



    • #3
      If the byte/word order is correct, and you are using even offsets as the first word, you can simply cast. If it was stored in V0 and V1, just reference V0:R to access as float.

      Barring that, use the SUBSCRIBE instruction to handle byte word ordering, alignment, and conversion.

      Comment



      • #4
        Use PUBLISH or SUBSCRIBE. Also search Casting in the help file.
        If you have an urgent issue, please contact AutomationDirect's Technical Support team.

        AutomationDirect.com Technical Support: 1(800) 633-0405 or (770) 844-4200 Email Tech Support

        Comment



        • #5
          Got ya, thanks I'll try storing the value in the V memory and look at the casting subscribe stuff, although I haven't used casting or Subscribe so I don't know what it is.

          Comment



          • #6
            Originally posted by Dirtybeef View Post
            Got ya, thanks I'll try storing the value in the V memory and look at the casting subscribe stuff, although I haven't used casting or Subscribe so I don't know what it is.
            Doesn't have to be V memory, I just used that as an example. Where is it stored now?

            Comment



            • #7
              Click image for larger version

Name:	Screenshot (157).png
Views:	37
Size:	924.3 KB
ID:	126829

              Comment



              • #8
                I made the data type, it will accept binary inputs, shows the two 16 bit words in binary but I can't move the custom data type to an R memory space. I don't think I'm following this right.

                Comment



                • #9
                  BobO Right now I changed this to put the two values in the V5 and V6, they were in DLV1511 and DLV1512.

                  Comment



                  • #10
                    Originally posted by Dirtybeef View Post
                    BobO Right now I changed this to put the two values in the V5 and V6, they were in DLV1511 and DLV1512.
                    Needs to be even first to cast. DLV1510-11 or DLV1512-13 are fine. Then cast with :R...DLV1510:R.

                    Comment



                    • #11
                      Casting will only work if the byte word order is correct though. If the value doesn't look right, you'll need to use SUBSCRIBE to convert.

                      Comment



                      • #12
                        Thanks BobO, I'm not sure I understand " Then cast with :R...DLV1510:R." what is the ":R"? I'll change this to Even Memory right now.

                        Comment



                        • #13
                          Click image for larger version

Name:	Screenshot (159).png
Views:	39
Size:	871.1 KB
ID:	126836

                          Comment



                          • #14
                            The casting automatically add a D so it's :RD, no idea why, can't find it in the manual.

                            Comment



                            • #15
                              Same thing on publish and subscribe. The value I'm trying to get out of this disaster is 55.6

                              Click image for larger version

Name:	Screenshot (161).png
Views:	38
Size:	658.0 KB
ID:	126839

                              Comment

                              Working...
                              X