Results 1 to 7 of 7

Thread: Real numbers via rs-232

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2004
    Posts
    4

    Question Real numbers via rs-232

    I am communicating with a PLC using Modbus. The PLC is outputing its data to me in as a 4 byte real number. To view the data I am converting it to hex and displaying the hex on my screen but I cannot figure out how to grab the 4 bytes from the middle of my string and convert them to a single real number.
    Any suggestions would be appreciated.

    Thanks
    Jerry
    Jerry

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Real numbers via rs-232

    is it a 4-digit number, or a 4-byte LONG number?

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2004
    Posts
    4

    Re: Real numbers via rs-232

    I was told it is a 4 byte real number. When I view it as ASCII it does not make any real sense as to how to convert it. The PLC stores the data in BCD as well and I have taken that data to compare it to the real number value and cannot see how they relate. Unfortunately the BCD location will change so I cannot use that for my program.

    Wish I had more information to give you, but that is all I have.

    Thanks
    Jerry

  4. #4
    Hyperactive Member Maven's Avatar
    Join Date
    Feb 2003
    Location
    Greeneville, TN
    Posts
    322

    Re: Real numbers via rs-232

    Quote Originally Posted by tipper
    I was told it is a 4 byte real number. When I view it as ASCII it does not make any real sense as to how to convert it. The PLC stores the data in BCD as well and I have taken that data to compare it to the real number value and cannot see how they relate. Unfortunately the BCD location will change so I cannot use that for my program.

    Wish I had more information to give you, but that is all I have.

    Thanks
    http://www.ray.masmcode.com/tutorial/fpuchap2.htm#real4
    Education is an admirable thing, but it is well to remember from time to time that nothing that is worth knowing can be taught. - Oscar Wilde

  5. #5

    Thread Starter
    New Member
    Join Date
    Mar 2004
    Posts
    4

    Re: Real numbers via rs-232

    Thanks,

    I read throught the article and now I understand what I am getting. It also gives me an idea of what I have to do to either convert it manually, or revise the way I am bringing in the data to hopefully get VB to do it for me.

    Jerry
    Jerry

  6. #6
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Real numbers via rs-232

    i find it hard to believe that it is giving you a floating point number. Convert it to binary and post it here. We'll look at it for you.

  7. #7
    Hyperactive Member Maven's Avatar
    Join Date
    Feb 2003
    Location
    Greeneville, TN
    Posts
    322

    Re: Real numbers via rs-232

    Quote Originally Posted by tipper
    Thanks,

    I read throught the article and now I understand what I am getting. It also gives me an idea of what I have to do to either convert it manually, or revise the way I am bringing in the data to hopefully get VB to do it for me.

    Jerry
    If I'm not mistaken a 4 byte real is a visual basic single.
    Education is an admirable thing, but it is well to remember from time to time that nothing that is worth knowing can be taught. - Oscar Wilde

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width