Host Engineering Forum

General Category => DirectSOFT => Topic started by: ScottB on July 20, 2012, 08:49:01 AM

Title: DL06 BCD/Hex numeric conversion for use in Lookout Direct GUI as decimal
Post by: ScottB on July 20, 2012, 08:49:01 AM
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??
Title: Re: DL06 BCD/Hex numeric conversion for use in Lookout Direct GUI as decimal
Post by: franji1 on July 20, 2012, 02:05:42 PM
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)
Title: Re: DL06 BCD/Hex numeric conversion for use in Lookout Direct GUI as decimal
Post by: ScottB on July 21, 2012, 07:38:13 AM
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.
Title: Re: DL06 BCD/Hex numeric conversion for use in Lookout Direct GUI as decimal
Post by: b_carlton on July 21, 2012, 09:51:20 AM
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.
Title: Re: DL06 BCD/Hex numeric conversion for use in Lookout Direct GUI as decimal
Post by: ScottB on July 21, 2012, 10:23:34 AM
Thanks Mr. Carlton,
I apprecitate it!