2.5 digit bcd to 8 bit encoding?

Nov 18, 2014 53 Replies

Your life will be complicated by the fact that you need to do something that's easy to implement in logic.

So your parent data ranges from 0x000 to 0x18f. If you use a the MSB as a flag, then you can let x = 0x00 to 0x7f correspond to y = range + x, where range is retained from sample to sample.

Then you can let x = 0x80 to 0xff to correspond to y = (x - 0x80) * 8.

All in all, if you don't use a PAL you'll need about half a dozen chips on each side of the link instead of one microprocessor, the "kit" that you'll be avoiding buying costs $29.95, and the code that you don't want to learn how to write will run to about 20 lines of C (maybe 100 of assembly). But it's your decision.

Tim Wescott Wescott Design Services http://www.wescottdesign.com

I don't have enough time left in my life to NOT use microprocessors for this kind of stuff!

You can get a 20-pin ARM Cortex part for less than $2 in onsies (less than $1 in quantity). An ST-Link programmer costs $29.95 from DigiKey. And if ALL you're doing is looking at segments and spitting out RS-232, the code should be fairly straightforward.

Tim Wescott Wescott Design Services http://www.wescottdesign.com

well

the

encode

units

to

then

that

mixture.

How are you going to deal with 2.77?

?-/

Unless you are going to send multiple characters there is a big problem. You have 400 input states possible and only 256 transmission states possible. Not possible without some other kind of limitations.

?-/

and $29.95 is the expensive one, you can just get one of the eval kits like:

formatting link

$7.88 and it includes an ST-link

-Lasse

One option is to map the range in such a way as to preserve fractional dynamic range or simpler to compress the higher range readings. eg.

Simplest case is to keep 0..a and then step in twos.

Solve

a+1 + (400-a)/2 = 256

a/2 + 201 = 256

hence a = 110

(ignoring fencepost errors or algebra slips)

Regards, Martin Brown

well behaved input packed double binary of 01110111 with unit 2 or 3 logged from the previous pass in the x.9x data and wait for the next x.9x transmitted data to update the units info

He is taking advantage of the fact that the value changes very slowly. If decreasing it will hit x.9y before it reaches x.8y. The 9 in the tens place will contain the new value for x and will be latched. On increasing when x.0y is reached the previous value stored will be incremented.

I think this will take a bit more logic than he realizes. Detecting the crossing from x.9 to x+1.0 will require a FF and logic. Then he will need a loadable counter to remember the units and increment. I understand the idea, but I think he would be just as well off simply detecting the .9 to .0 and .0 to .9 transitions and counting up or down as needed. The thing has to start with a value near zero or it won't work at the start anyway. His approach does at least have the advantage of setting the correct value on the tenths reaching .9 in case they get corrupted. The up and down transitions can be detected when the D7 bit transitions and the D6 bit matches. That makes it two FFs.

An up transition is stored D7 = 1, stored D4 = 1, the present D7 = 0 and present D4 = 0. The down transition is the stored D7 = 0, stored D4 =

0, present D7 = 1 and present D4 = 1. I assume he has a strobe to say when the data is valid which is used to clock everything. Not sure how he plans to interface with the UART, etc.
Rick

As it stands I have 3 banks of latched BCD, 2 bits for units and 4 bits each for the tenths and hundredths. Hold lines D5 and D6 low until the 2 analogue switch gates pass the units data into the "9" encoding when both D4 and D7 are high.

i meant droppered instead of held , so can be H or L for 0 to 7 use but data passed by the analogue switch takes priority in the "9" tenths situation

If the data is moving slowly you may consider sending just the difference with the previous value. In this way 8 bits are more than enough (assuming this is what you wanted). Of course this has problems if you don't know an initial value or if you lose a packet... Ad-hoc tricks may help for your particular problem, which you haven't described accurately enough.

Pere

I remember the face on ones. They must have been fairly easily (cheaply) available surplus as we made a digital clock using them and built from parts salvaged from old ICL1900 boards. The lit digit would jump forwards and backwards when it counted up in sequence.

I think they were exactly round. I wonder what happened to that clock?

Regards, Martin Brown

well

the

encode

units

to

general

then

that

mixture.

gate

And if you are not getting them? What then?

?-/

is

at

0 to

general

that

have

gate

the

down

advantage

get

bit

0 and

D4 =

say

how

That assumes that you regularly get 9s and not 7s or 5s.

?-/

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required