News:

  • June 10, 2026, 06:15:28 AM

Login with username, password and session length

Author Topic: DL06 BCD/Hex numeric conversion for use in Lookout Direct GUI as decimal  (Read 13711 times)

ScottB

  • Newbie
  • *
  • Posts: 3
Hello,
This is going to be a dumb question for you experts I'm sure. I have an electrical metering device I am reading in through Modbus which provides that device's internal calendar/clock. I am having a tough time with converting these values held in the PLC registers to plain decimal numbers to represent a GUI timestamp on the Lookout screen. I would like to do all conversion in the PLC and tag them for use in the GUI. For instance, I see "3B" occur in the "seconds" byte in DirectSoft 5 "data view" but the label in LookoutDirect gives an incorrect representation. What I am I missing here guys? It just cant be that complicated is it??

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3827
    • Host Engineering
It appears it IS decimal, not BCD.  3B is an invalid BCD value.  But decimal, it's 59 (3 * 16 + 11).  Your display is probably formated to look at it as BCD.  Change it to decimal or binary or integer or whatever it calls "normal" integers (NOT Binary Coded Decimal, BCD)

ScottB

  • Newbie
  • *
  • Posts: 3
Thanks for the help. In this case the high order byte was the seconds, and the low ordered byte was the minutes; of the same Vmem location. I had to do some OUTL and SHFR to get the bytes seperated into thier own Vmems for things to make sense. Im not quite sure why the data viewer shows BCD/Hex as the same formatting structure. I suppose it takes a few years of hammering away at things to become an expert. Thanks again.

b_carlton

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 606
    • thePLCguy
Quote
Im not quite sure why the data viewer shows BCD/Hex as the same formatting structure.

The easy answer is ... because they are.

As far as formatting a BCD is no more than a subset of the hex representation. You are simply showing a character for each 4 bit section (nibble I believe). Now, what they mean as far as an actual value is the essential difference.
An output is a PLC's way of getting its inputs to change.

ScottB

  • Newbie
  • *
  • Posts: 3
Thanks Mr. Carlton,
I apprecitate it!