LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how can i convert 8-bit data into bcd or Ascii?

im working with 82c55ic,in LABVIEW how can i convert 8-bit data into bcd (that data supply to 7447IC or Ascii codes(that data transmit to LCD display).....i need perfect solution....i try my best to do it myself ...if anyone of u hav worked with that conversion plz mail me the vi..mail adress is:shanisiddqui@yahoo
0 Kudos
Message 1 of 12
(5,315 Views)
Hi there,

First, use the �Quotient & Remainder� function with a constant of �10� to split the numeric value into its decimal digits. Then multiply the quotient with �16� and add the remainder and you will have the bcd value.

Please see the attached example �bcd.vi�.

For more information about bcd, look at this KnowledgeBase.


I hope this answers your question.

Best regards,
Philip C.
Applications Engineer
National Instruments
- Philip Courtois, Thinkbot Solutions

Thinkbot Solutions
0 Kudos
Message 2 of 12
(5,315 Views)

I know this is a very old thread but I thought that the attached code might still be of help to someone....

0 Kudos
Message 3 of 12
(2,587 Views)

Hi Alan,

 


@Alan_K. wrote:

the attached code…


There is no code attached, it's just an image!

 

Why is your code so complicated? Why no use a simple function like this:

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 12
(2,582 Views)

Thanks for providing a much simpler solution Gerd.

 

Much appreciated 

0 Kudos
Message 5 of 12
(2,572 Views)

Thank you for your response to my posting Gerd, and your suggested simpler alternative.

 

However, if you compare the output from the two alternatives, you will see that above a value of 9, your suggestion does not unpack BCD correctly.

 

Perhaps you could compare the two with inputs from 0 to 99 BCD and post your thoughts.

 

Thanks again for your contribution 🙂

 

0 Kudos
Message 6 of 12
(2,563 Views)

Hi Alan,

 


@Alan_K. wrote:

However, if you compare the output from the two alternatives, you will see that above a value of 9, your suggestion does not unpack BCD correctly.

Perhaps you could compare the two with inputs from 0 to 99 BCD and post your thoughts.


The problem with your image is: you forgot to show the radix for each control/constant/indicator (apart from posting code at all).

My "BCD" input expects a decimal number from 0-99, while yours expects a hexadecimal input from 0-99.

 

See this changed example:

Now it expects the (usual) hexadecimal input of 0-99. My simplified example still does not check the input value for sanity - as your example also omits…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 12
(2,538 Views)

@Alan_K. wrote:

I know this is a very old thread but I thought that the attached code might still be of help to someone....


Sorry, but this does not look like BCD.  You should have a nibble for each decade, each nibble being a direct decade value.  A value of 99 should end with a string of values {0x99}.  For a better example, a value of 50 should result in {0x50}.  So a Quotient & Remainder is the way to split up the values into decades.

 

For straight ACII conversion, just using the Number To Decimal String will do the job.  It does have an input to set the minimum length of the resulting string if you need 2 or 3 characters.

 

EDIT:  Oh, the input was supposed to be in hex?  That changes everything.  Yet another reason to attach the actual code instead of just an image.  Also the importance of showing the radix whenever it is not the standard decimal.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 8 of 12
(2,534 Views)

I apologise for not attaching the code, which I have now done.

 

I am not offering this solution as a general purpose solution, but a simple solution which meets my requirements and for which I could not find a ready made alternative.

 

The vi input expects only the digits 0 to 9 in High and Low nibbles i.e 0 to 99 (BCD) No checking is implemented

 

Have I missed a ready made function / solution elsewhere? 🤔

0 Kudos
Message 9 of 12
(2,522 Views)

@Alan_K. wrote:

I apologise for not attaching the code, which I have now done.

 

I am not offering this solution as a general purpose solution, but a simple solution which meets my requirements and for which I could not find a ready made alternative.

 

The vi input expects only the digits 0 to 9 in High and Low nibbles i.e 0 to 99 (BCD) No checking is implemented

 

Have I missed a ready made function / solution elsewhere? 🤔


I notice you are STILL not showing the radix on your numeric control.  HOW IS THE USER SUPPOSED TO KNOW THE INPUT IS SUPPOSED TO BE HEXADECIMAL?  (There's been any number of subtle hints so far; I thought I'd make mine not-so-subtle.)

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 10 of 12
(2,513 Views)