Converting from binary to hexadecimal and decimal. - Page 1
Forum section: electronics / projects

author: DBoulanger
author_rank: Regular Contributor
timestamp: February 21, 2014, 10:16:13 pm
content: Good day everyone,Just for the fun of playing around with leds, I acquired a basic 8-bit analog to digital converter. Roughly speaking, it simply takes a voltage reading, and compare it to a reference voltage. The result is being presented in binary with leds, the value being in units of 1/255 of the reference voltage. So globally, if the reference voltage is 5.1v and the read voltage is 2V, the display will show 100 (one hundred), which will be 01100100 binary.So far so good. To make use of some extra 7-segment displays I have, I thought that attempting to display that binary value in its hexadecimal and decimal equivalencies would be an interesting little project.For the hexadecimal display, unless I'm being suggested a better approach, I was planning to make use of 2 x MC14495P1 chips. They look simple to hook to the ADC, so at first glace, for simplicity and minimal parts count, I think this could be a good choice. Do you agree ?The decimal part is a different story. After multiple searches on the internet, I found the circuit attached. The right hand side of the circuit, with the 4026 and 4033, is already taken care of since I have 2 x 6 digits counters (4026 based) and 2 x 3 bars of 10 leds hooked as 3 decades via 4017.The way I set them up allows me to chain the way I want, would it be only digits, only bars or a mixture of both. Globally, the counters aren't an issue.On the left side of the schematic, there are 2 x 4526. The price and availability for these ICs aren't the most appealing. These are 4-bits, up/down counters, presttables. Doing some researches on the net, I found some 4029 chips which seem to do a very similar job, not to say identical, to the 4526, but for a fraction of the price.My question is simple : Could the 4029 be actually used instead of the 4526 ? I know, I should read the datasheets, and I did. I just want to make sure so that I won't be buying parts that will only collect the dust because I overlooked at a datasheet detail.As per its hexadecimal counterpart, there are more likely many ways to accomplish what I'm planning to do, but before commiting to something in particular, I'd rather have some opinions and ideas if possible.I clearly understand that a microcontroller could potentially be the best route, but for the moment being, I don't have access to a computer, only a tablet, so programming chips is not quite possible at this moment.As usual, comments, opinions, ideas and alike, are more than welcomed.Regards.

author: dannyf
author_rank: Super Contributor
timestamp: February 21, 2014, 10:34:30 pm
content: QuoteI would think about it differently. All you wanted is to display the number. There are tons of ics that drive leds. Alternatively, memory chips (parallel eeprom or sdram for example) can be used for this. Or better yet, mcus.What you have is too complicated for something this simple.

author: DBoulanger
author_rank: Regular Contributor
timestamp: February 21, 2014, 10:52:53 pm
content: As a matter of fact, there is a lot of ICs to drive leds.I want to use what I have handy as much as possible. I do have spare 7-segment display, no problem there. I do have decimal counters (the 4026 based ones), not a problem there either.I don't have the necessary resources to program mcus and alike, so I have to opt for a mixture of discrete components and some ICs.I realize that this is "forcing" me to take a long road instead of taking nice shortcuts that the mcus are offering. I aggree that doing the things the way I initially planned could be considered as overdoing, but in the actual situation, I don't have much choice, I have to cope with what I have and if I need to buy something, it has to be affordable, not to say cheap.Schematics of alternative routes would be very helpfull too.Regards.

author: edavid
author_rank: Super Contributor
timestamp: February 22, 2014, 12:27:49 am
content: Of course you can use any kind of binary down counter such as 4029, 40103, 74C191, 74C193, although it may take a few gates. Another way is to use a binary up counter and a comparator. Another other way is to use a bunch of adders to combinatorially convert binary to BCD.I'm not sure why you don't just buy a laptop and a device programmer though...

author: edavid
author_rank: Super Contributor
timestamp: February 22, 2014, 12:33:26 am
content: Quote from: wilfred on February 22, 2014, 12:31:39 amYou are missing the point, he wants to take an 8 bit binary input and display the 3 digit decimal equivalent. In other words, convert 8 bit binary to 3 digit BCD.

author: DBoulanger
author_rank: Regular Contributor
timestamp: February 22, 2014, 02:14:22 am
content: Wilfred: You're right, this it what I'm trying to do, along with the 2 hexadecimal digits.edavid: For obvious reasons, the CD4511 isn't the chip I need. Perhaps you based your suggestion on your comprehension of my intents, but the things weren't as clear as they should have been I guess.The MC14495P1 is much cheaper than the DM9368 you're suggesting. For what I need, which is simply displaying the hexadecimal equivalency of an 8-Bit number, $15 a piece is definitively too much. For close to $10 I could get 4 x MC14495P1, so pricewise the decision isn't too difficult to make.At this very moment, spending money on a laptop is not part of my plans. There are other things which deserve a higher priority right now. Being unemployed right now, lead me to minimize expenses for hobby purposes. I'm not doing electronic projects for money, its purely for fun.When it will be appropriate to do so, yes I more likely will consider to take a dive in the mcus world, but for now, if I can achieve my goals with minimal investment and maximum of enjoyement, I don't mind taking the long way.Thanks for your comments.

author: mariush
author_rank: Super Contributor
timestamp: February 22, 2014, 02:49:27 am
content: QuoteQuoteApparently, spending $15-20 for a chip programmer is too much, but spending $10 on 4 dumb chips is acceptable. Talk about spending money wisely.Here's a simple and cheap programmer:https://www.sparkfun.com/products/9825An atmega328 is 1-2$, a shift register to multiply the outputs for several digits is cheap, 10-20 cents...

author: DBoulanger
author_rank: Regular Contributor
timestamp: February 22, 2014, 03:08:53 am
content: Marius,I'm sincerely sorry, but spending $15-$20 on a chip programmer when you don't have access to a computer isn't much smarter than buying tires on sale even though you don't have a car !As I mentioned earlier, and perhaps you've overlooked, spending money on a laptop right now is not part of my plans, so suggesting me to buy a microcontroller programmer doesn't sound much wiser to me than having me spend $10 on 4 dumb chips for a dumb project as we're at it.The explanations I provided in my previous posts were meant to be as precise as possible. Reading them throughly would help preventing false assumptions and perhaps make wiser suggestions.Regards.

author: mariush
author_rank: Super Contributor
timestamp: February 22, 2014, 03:24:43 am
content: Oh come on, honestly... you don't have to buy a LAPTOP for a hobby.You can find old desktop computers on Craigslist, ebay or those sites with recycling themes (freecycle or whatever) for 20-50$. You can find a cheap 15-17" lcd on eBay for 10-25$.Could even go in a pawn shop or Goodwill or something like that and find some stuff for cheap. If you're not in US, eBay can still give you good scores.Basically for under 100$ you can buy a full working computer, with display keyboard mouse speakers, everything... even an old Pentium 3 is good enough to write some code and upload to a chip as a hobby. You don't need a 2-300$ or more on a laptop to type some stuff.I can literally go into a used pc store here in my crappy country that has 24% VAT on anything and buy an old Dell Pentium 4 PC for about 70$ (in local currency). If I'm lucky, I can find an old Compaq Pentium 4 system forabout 35$I can find similar desktop systems on local classified sites (craigslist like) for $25-50.You can always find excuses but if you like to do something you think hard and work around these.

author: edavid
author_rank: Super Contributor
timestamp: February 22, 2014, 04:03:17 am
content: Quote from: DBoulanger on February 22, 2014, 02:14:22 amAhem, I was not the person who suggested that.

author: edavid
author_rank: Super Contributor
timestamp: February 22, 2014, 04:04:12 am
content: Quote from: mariush on February 22, 2014, 03:24:43 amWhy not, you can get a good used laptop for $50-100...

author: Skimask
author_rank: Super Contributor
timestamp: February 22, 2014, 04:39:43 am
content: Hell, I've got two older Gateway's right here that run Linux just fine. I'll GIVE him one. But he's gotta pick it up.

author: DBoulanger
author_rank: Regular Contributor
timestamp: February 22, 2014, 07:36:12 am
content: Skimask: Thanks for the offer, but this is not what I'm looking for.edavid : Sorry for the error. The way the text was formatted lead me to believe that it was you who suggested the CD4511. My bad.mariush : Thanks for your input, but this is not the way I want to go.To everyone : At the beginning of this thread, I simply asked a question to confirm if what I was planning to do was feasable. I also enquiry about alternatives, which you provided.On the other hand, I thought I made clear that I didn't want to go the mcus route. Despite this statement, I've been suggested with more expensive chips than what I was initially planning to buy, ways to do it with a mcu, where to buy a mcu programmer, where to get a cheap computer. Globally almost everything in the world except what I was initially looking for.Once for all, can we stop refering to these mcus when the initial goal is to achieve a project without them ?The objective was to do this project in a fun way, not judging the use of dumb chips nor wise investments. Let's stick to the original idea, period. If I'm asking for miracles, then tell me, no more no less.Let me put it clear : I don't want to use a mcu for this project. If you can give me ideas, with potentially some schematic to show your design, great, I'll be more than glad to look at it. Please, put your mcus based designs and computers shopping lists aside for the moment being.Regards.

author: amyk
author_rank: Super Contributor
timestamp: February 22, 2014, 09:10:15 am
content: You're going to need a divider, which means reinventing quite a bit of an MCU. Subtraction and loops will be involved.

author: dannyf
author_rank: Super Contributor
timestamp: February 22, 2014, 12:59:00 pm
content: QuoteHe did configure the 4526 into a programmable divider.The issue is that he used the one-shot configuration. A slight twist would have solved him problem.

author: dannyf
author_rank: Super Contributor
timestamp: February 22, 2014, 01:33:58 pm
content: The basic design is sound: you use a programmable counter that resets the 3 counters once the programmable counter has reached zero.The issue is in the details: those programmable counters give the full count on the first cycle, and then, as configured, produce the right count-down. So I think you will need its TC pin to not only reset the 3 digit counters but also enable them so there is no display (update) until the count has been depleted.

author: edavid
author_rank: Super Contributor
timestamp: February 22, 2014, 03:57:46 pm
content: Quote from: dannyf on February 22, 2014, 01:33:58 pmNo, the issue is in the cost of the 4526s - he was looking for something cheaper.

author: deephaven
author_rank: Frequent Contributor
timestamp: February 22, 2014, 05:03:13 pm
content: Quote from: Dawgie on February 22, 2014, 09:06:31 amHe said he had a tablet.

author: dannyf
author_rank: Super Contributor
timestamp: February 22, 2014, 07:37:19 pm
content: QuoteSure. As a matter of fact, other programmable dividers can be used as well.

author: DBoulanger
author_rank: Regular Contributor
timestamp: February 22, 2014, 11:16:50 pm
content: Wilfred : I really liked the Apollo XIII analogy. This is exactly what I'm doing, taking basic circuits and putting them together to accomplish the desired work. Doing so, I have a better feeling of what's going on behind the scene and I do acquire some knowledge that wouldn't have been acquired otherwise.When I will look at circuit schematics in the future and see dividers, bit counters and so on, then at least I will have a better understanding of what is accomplished and will have more ease at putting in place alternative ways of doing the same.Dannyf : Now knowing that I can use 4029 ICs in place of the 4526, will ensure me that if what I'm doing isn't working as planned, then this will be because I didn't connect something properly and not because the original IC used in the schematic had some specific characteristics.You mentionned "He did configure the 4526 into a programmable divider. The issue is that he used the one-shot configuration. A slight twist would have solved him problem."Sorry for my ignorance, but could you clarify for me what you meant by that ?---------Just to make sure everything is clear, I'm not the one who created the circuit schematic. While doing researches on the net, I saw it and when I realized that the final step was using 4026 ICs, in the same way I created my 6 digits counters, I concluded that adding the front logic/components on a separate small board, could then used as an add-on to my counters. So what I have to do now is concentrate on how oftenly I'll feed the 4029 and at which speed I want the data to be converted to its decimal equivalency. Overall, I want it to be as visual and as fonctional as possible, so yes, there will be leds added, adjustable clock rate (via a 7555 oscillator) so that the overall process could be slowed down and could be used to "visualise" the overall process.I'm not looking for something optimal, but simply functional, fun, with some bells and whistles if possible. I have no deadline, so time isn't an issue. I'm the type of electronic enthousiast who is having a good time when things are more challenging, so this project looks promissing !Thanks guys for your feedback.

author: dannyf
author_rank: Super Contributor
timestamp: February 23, 2014, 12:46:33 am
content: 4526 is fairly unusual in that when it first counts down, it will count down from the max (15 on the lsb) to 0, and then from the programmed limit to 0. You should read a few datasheets on that as it is not mentioned in some of them.

author: edavid
author_rank: Super Contributor
timestamp: February 23, 2014, 01:58:46 am
content: Quote from: dannyf on February 23, 2014, 12:46:33 amI think this is wrong, or irrelevant. The OP's circuit uses the async preset, so it will start from the programmed N.

author: Zero999
author_rank: Super Contributor
timestamp: February 23, 2014, 11:05:46 am
content: You can do this with standard combinational logic, possibly even diode and resistor logic, with some inverters/buffers to compensate for the losses.