How to convert BCD to DEC

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
Desdewit
Posts: 130
Joined: Sat Feb 26, 2011 4:26 am
Location: South Africa
Has thanked: 25 times
Been thanked: 11 times
Contact:

How to convert BCD to DEC

Post by Desdewit »

Hallo

What is the quickest way to get BCD to DEC or Ascii to be displayed on lcd?

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 364 times
Been thanked: 716 times
Contact:

Re: How to convert BCD to DEC

Post by JohnCrow »

There is a good article on Wikipedia on BCD

http://en.wikipedia.org/wiki/Binary-coded_decimal
1 in 10 people understand binary, the other one doesn't !

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: How to convert BCD to DEC

Post by medelec35 »

Not sure how well this will work:

Code: Select all

dec = (bcd >> 4) * 10 + (bcd & 15)
Martin
Martin

Desdewit
Posts: 130
Joined: Sat Feb 26, 2011 4:26 am
Location: South Africa
Has thanked: 25 times
Been thanked: 11 times
Contact:

Re: How to convert BCD to DEC

Post by Desdewit »

Thanks I will give it a go.

Desdewit
Posts: 130
Joined: Sat Feb 26, 2011 4:26 am
Location: South Africa
Has thanked: 25 times
Been thanked: 11 times
Contact:

Re: How to convert BCD to DEC

Post by Desdewit »

Hi Martin / John

I've tested the code after I did some reading and my onboard RTCC is running at last. Thanks for the help. :lol:

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: How to convert BCD to DEC

Post by medelec35 »

Hi Desdewit,
Glad it's working for you.
If the code that worked was different to what I posted, would you mind posting it please, to help others that may be faced with the same issue.
Or was it the code I posted you used?

Maritin
Martin

Desdewit
Posts: 130
Joined: Sat Feb 26, 2011 4:26 am
Location: South Africa
Has thanked: 25 times
Been thanked: 11 times
Contact:

Re: How to convert BCD to DEC

Post by Desdewit »

Hi Martin

The code you posted worked but I will post a basic program for the onboard rtc over the weekend. :wink:

Post Reply