Announcement

Collapse
No announcement yet.

Convert decimal to binary in DL05

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


  • Convert decimal to binary in DL05

    I have a DL05 with analog input. Connected to the analog side is a 0-10V pot. The value that is written to the PLC memory is in binary and (I presume) is scaled so that 0V = 0 and 10V = 65535. The PLC is connected to a PC via serial modbus and the PC is sending a number which should be in decimal format. I need to compare this number to the binary number produced by the analog module.

    I see a conversion instruction for going from BCD to binary but nothing to deal with decimal numbers.

    The decimal number coming from the PC is between 0 and 10 with 4 decimal places. Another thought I had was to scale the number from the PC so that it's full range represented 0 - 65535 instead of 0.0000 to 10.0000.

    How would you all go after this?

    From a precision perspective, I'm good with one decimal place. Could I round the floating point number (4.5692) to (4.6), multiply that by 10 (46), write that to the 05 V memory then use the conversion instruction to go from BCD to binary? I recall from another post that multiplying a decimal with one decimal place by 10 produced it's BCD equivalent. Or I could configure the analog module to write in BCD and not have to convert anything. Will this work?

    Thanks
    Last edited by rrc1962; 12-20-2010, 05:43 PM.


  • #2
    Writing a floating point number to a DL05 isn't going to work since the DL05 can't handle floating point.

    With that being said, I would round the number, multiply by 10 then write it to the DL05. It should come in as a binary formatted number which you could then directly compare to the a scaled version of the analog number.
    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



    • #3
      Originally posted by ADC App Assist View Post
      Writing a floating point number to a DL05 isn't going to work since the DL05 can't handle floating point.

      With that being said, I would round the number, multiply by 10 then write it to the DL05. It should come in as a binary formatted number which you could then directly compare to the a scaled version of the analog number.
      What I did was scale my input on the PC so it also ranged from 0 - 4095, same as the range from the analog module. So when I run the slider to about half way, I get about 2000. Same value written to the PLC when the pot is about half way.

      Comment

      Working...
      X