BCD HEX to DINT or REAL

JeffKiper

Lifetime Supporting Member + Moderator
Join Date
Jun 2006
Location
Indiana
Posts
2,460
I have a sensor that only puts out a Hex value via BCD in 6 digits. It is a material thickness gauge. I am not on site so I can't test it yet. I want to take these 25 bit and create a REAL or DINT out of them.
Iam planning on using a MVM to break them up into individual Hex values but I would like to be able to display them to the operator in meaningfull values to them.
I am sure the sensor configuration will effect this greatly if I create a floating point. this device can't transmit the decimal point so 12.345 gets transmitted as 12345. I ASSuME that I can just do a DIVide and get the decimal in the correct position.
This system is looking to make sure that they don't get Double material thickness. 2 piece stuck together.

Any suggestions

BCD HEX Image.jpg
 
I could be wrong, but I think you can simply use the FRD instruction (From BCD to Decimal) with an A/B PLC. If you're using a SLC/PLC5 without DINTs, you may need two FRDs to do the whole 6 digits and a bit of math to combine them into a float.

Of course you'll want to wire those bits to consecutive input points starting with zero or map them into a DINT (or two INTS) first.
 
Last edited:
A FRD might do that one bit but how do I put them together? I was thinking of something like a Concatenate except not using s ASCII string.
h#00FF = b#1111 1111 =d#255
I will get the gauge up and running and do little trial and error testing to get it communicating.
 
Are you using a SLC/PLC5?

My first instinct is to (after the FRDs) MUL the MSW (BCD digits 5 and 6) by 10000 with a destination float, and then ADD the LSW to it. After break I can try that in Emulate...
 
Then just use a 32 bit MVM to mask out the sign bit (bit 24), then FRD the result to a DINT destination, OTE the sign bit to bit 32 of that DINT. Then scale it to a float if necessary.
 
Damn that looks a lot cleaner than anything I was coming up with. These l are spread out over a 4 different input cards 1734-ib8 cards. So there is a little bit of manipulation needed to move then into a DINT. a few MVM and I should have it in 1 DINT.
 
Hey, Jeff!

Be sure to put error trapping logic after the FRDs!

Check the help file on Fred and Tod and follow their advice.

I have fixed many a Fred and Tod where a machine would run perfect for years until the mechanical thumbwheel switch produced an invalid BCD bit pattern. Either that, or the resulting math faulted the SLC/Micro.

Also, be aware of what this can do to the rest of your controls...in some cases you can keep trucking and report a fault. In other cases, where the result of the signal can generate waste or machine damage, then shut her down...

PiEaCe!
 
The system will not run if the signal is outside accepted range. I will be working on this Monday or Tuesday
 
Then just use a 32 bit MVM to mask out the sign bit (bit 24), then FRD the result to a DINT destination, OTE the sign bit to bit 32 of that DINT. Then scale it to a float if necessary.
I don't think that would work for the negative numbers as the readout is a 'sign plus magnitude' while a DINT has a '2's complement' format.

Do the MVM but after the FRD, if the sign bit was true then subtract the result from zero to get the proper negative value.
 
Guys this got moved to the bottom over the list for a little while. When it jumps back up I will revive this thread.
As always thanks for the help
 

Similar Topics

I'm working on updating a waste water plant to modern processors except on vendor supplied systems. On of the vendor systems uses old Direct...
Replies
2
Views
1,796
Guys, I have an issue that i dont understand and am hoping that someone has an idea. I have a Lauer PCS950C HMI communicating with a Siemens...
Replies
5
Views
2,331
Hi all, I am looking for a BCD or hex thumbwheel switch. I only plan to use 0-7 (3 bits). I prefer something that has leads already. I would...
Replies
6
Views
2,744
i'm newbie in PLC, would u like to help me, plese.. i'm using an instruction MOV, for moving Hexadecimal data #0020 which is &32 in decimal,to...
Replies
3
Views
1,820
i'm confusing about an instruction in PLC, need your help, please.. i MOV(021) a data #0010 in hexadecimal then i stored it in memory D100 after...
Replies
4
Views
1,905
Back
Top Bottom