REXYGEN Community Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Login

    asci conversion

    Modbus TCP
    2
    4
    975
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      MikeyH
      last edited by MikeyH

      Hi All,

      I'm reading the display register of a controller. The value is 32bit so I get an asci value of "2956538157". What's the best to convert that value to a real number. Real number here is -19

      Modbus setting are, register_32, readable, swap words flag on

      Modbus flag read, 2956538157. This should be -19

      If I turn off the swap word flag I get 825077817, that is roughly -19

      Cheers,

      Mike

      1 Reply Last reply Reply Quote 0
      • cechuratC
        cechurat
        last edited by

        Hi Mike,

        in REXYGEN 3 we have introduced "Register String" in Modbus driver.

        Register string: text variable (Count is the number of bytes occupied by text in this case)
        

        Did you try out this option? Instead of the "Swap word" flag try to set the "Swap byte" flag since every character is represented by a byte.

        Let me know if it helped.

        Cheers,
        Tomas

        M 1 Reply Last reply Reply Quote 0
        • cechuratC cechurat moved this topic from REXYGEN Studio on
        • M
          MikeyH @cechurat
          last edited by

          @cechurat Hi Tomas,

          That works perfectly, thank you.

          The next thing to solve! The display on the device I am reading does not use a decimal point below -9.9. So I get the same values from the register. -9.9 and above I can add again to get the decimal, -99 plus gain is -9.9. But -10 and below I can't use gain as -10 becomes -1.0. Is there a clean way in REXYGEN to handle this?

          Cheers,
          Mike

          cechuratC 1 Reply Last reply Reply Quote 0
          • cechuratC
            cechurat @MikeyH
            last edited by

            @MikeyH Hi Mike,

            I'm glad it works for you 😉

            For the "variable decimal point" I would use blocks MUL and CNDR. CNDR configure so it reflects the changing of the gain according to the value.

            You will probably find many other solutions which will lead you to the desired behaviour (e.g. SSW for switching gain according to the value)

            Hope it helps.

            Cheers,
            Tomas

            1 Reply Last reply Reply Quote 0
            • First post
              Last post

            This is a community forum for REXYGEN users and fans. Detailed information can be found at REXYGEN homepage.

            There is also an outdated REXYGEN community forum.

            Powered by NodeBB.