LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Koyo PLC uses BCD. How do I get BCD values in LabView

My touch screen and PLC are both from Automation Direct.  The plc analog registers are BCD.  In LabView when I read those values, they are read in decimal.  I would like to display the results in the native BCD.  Please help.
0 Kudos
Message 1 of 13
(7,360 Views)

Which BCD? "Regular" or "Packed". Also, how would you want to display it? As a string of zeros and ones (characters), or as a Boolean array, or as a numeric indicator? How are you reading the register?

 

You can look at the example here for a start. If you change the display format of the "bcd" indicator to binary and set the minimum field width to accomodate the largest value you have (be sure to select pad with zeros on the left) you'll get a numeric indicator displaying BCD. Note that the example only works up to 99 since it only performs the integer quotient operation once. Still, you can easily modify it to suit your needs. 

Message 2 of 13
(7,348 Views)
All I know is that my PLC says that everything is BCD.  and the number 25 in my PLC is translated in LabView as 37.  How do I make it read 25 as it is in the PLC?  Sorry that I don't know more.  Just when I thought I knew enough to get by...
0 Kudos
Message 3 of 13
(7,343 Views)
25 would be the hexadecimal value. 25 Hex = 37 decimal. To have a numeric indicator display in hex, right click on the indicator and select "Format and Precision". Select "Hexadecimal". You may also want to have the radix displayed so you know the number shown is hexadecimal. With the Properties dialog open this is accessible in the "Appearance" tab. Select the "Show Radix" checkbox. You can also display the radix by right-clicking on the indicator and selecting "Visible Items -> Radix".
Message 4 of 13
(7,341 Views)

smercurio_fc wrote:
25 would be the hexadecimal value. 25 Hex = 37 decimal. To have a numeric indicator display in hex, right click on the indicator and select "Format and Precision". Select "Hexadecimal". You may also want to have the radix displayed so you know the number shown is hexadecimal. With the Properties dialog open this is accessible in the "Appearance" tab. Select the "Show Radix" checkbox. You can also display the radix by right-clicking on the indicator and selecting "Visible Items -> Radix".

This seems to have gotten me very close to solving my problem.  Thanks for clearing up my BCD Hex confusion.  I guess I need to read up on that more.  Your solution however is not working for me because when I choose hexadecimal from the options, it doesn't pick it.  It remains at decimal.  The same is true with octal and binary.  I cannot choose anything other than decimal.  Any suggestions on how to make the dial read hex would be appreciated.

0 Kudos
Message 5 of 13
(7,310 Views)
Try changing the representation from floating point to an integer representation (probably an I16, since you're reading a register).

___________________
Try to take over the world!
Message 6 of 13
(7,305 Views)
Ok I got it to change to read as hex, (I guess I was trying to edit while it was running before) but now my guage is displaying numbers and letters (hex values).  The dial is reading 25, but I don't want it to display hex values.  No one wants to look at a dial and say, "Oh, the pressure is at 1C."  What am I missing here?
0 Kudos
Message 7 of 13
(7,300 Views)

Remember that this setting is only a display setting. The number is whatever value you assign it.

 

If you are receiving your values as a string, you can use the Hexadecimal String to Number primitive to convert the string to the value you want.

 

If that doesn't help, you should post the code or at least an image of it.


___________________
Try to take over the world!
Message 8 of 13
(7,294 Views)

Hi Orion,

 

The number to string conversion functions will be best suited to convert an integer to BCD for display purposes.  If the goal is to have a meter on the Front Panel which you can display BCD numbers and yet not have the "1A", "1B", etc... hex numbers appear, then you can use the VIs below to convert to and from BCD.  I also wrote a BCD Test VI that demonstrates how these conversion VIs are used.

 

Please note that the least significant nibble of the Integer In parameter will never be greater than 1001 (9).  Therefore, integer values 10-15, 26-31, 42-47, etc... are invalid and will never appear as the Integer In parameter.  If you put these numbers into the BCD Test VI, they are not converted properly because they have no BCD counterpart.  This is because the least significant nibble in these is greater than 1001.

 

I hope this helps,

- Erik

Message 9 of 13
(7,193 Views)
Thanks Erik.  I actually made my own "To BCD" sub vi using the methods you showed me and it seems to work so far.  I even got to play around with the icon editor. Thanks for your help
0 Kudos
Message 10 of 13
(7,190 Views)