Broad project with many components, need some help please!

Hello everyone!

I will be building a switch panel/status panel (connected to a PC via USB) and would like some general guidance and advice. It's a pretty broad project (for my skill level anyway) and I will be focusing on one thing at a time.

However since I'm ordering components from China I wanted to make sure I don't forget anything crucial that will force me to put the project on hold for a month or more until the stuff arrives.

I will be learning as I go along so please excuse any blatant errors that could have been solved by a simple google search, I'm rushing it a bit so I can order the stuff I will need.

Questions are in bold if you want to skip straight to them.


Disclaimer: I have no idea what I am doing. But it's fun!

I will be using an (or 2 if necessary, 1 is preferred though) ArduinoMega.

So far the components list (already ordered but not yet received) is the following:

[u]INPUT[/u]

36 or 40 switches ON OFF single pole 9 or 12 switches ON OFF ON single pole 16 or 20 tactile momentary buttons 9 or 10 1k pots 15 rotary encoders 1 or 2 rotary switches 4 positions single pole

[u]OUTPUT[/u]

8 3digit 7 segment displays (c.cathode) 1 1602 lcd display (HD44780) 1 3.5in lcd/tft display (most probably need a separate mega for this one)

[u]LEDS/u: red: 5 green: 15 yellow: 1

Chips:

1 IIC/I2C serial interface board module for the 1602 display 1 MAX7219 20 M74HC595B1R 20 CD4051BE 20 SN74HC165N

I've broken down my issues in 4 sections. If you start reading and give up thinking I'm just going to make a bonfire, the last section touches that problem.

[u]A) INPUTS[/u]

I think I should be able to connect all my inputs to a single arduino's pins through cascading the HC165s (for switches and buttons) and the 4051 (for pots and encoders). If I understand correctly cascading 20 HC165s will (at least in theory) gives me 160inputs with a 4pin footprint. I couldn't calculate for the CD4051 because I haven't yet understood when to use analog or digital pins so I don't really know how many it will use in my case.

Question A1: Am I correct in thinking to cascade HC165 and CD4051 in order to connect all my inputs to one mega?

[u]B) OUTPUTS[/u]

Now here's where I think there might be serious issues.

[u]1) 7 segment displays:[/u]

I'm not sure if using HC595s to drive 8 3digit 7segment displays is the best. Is it even feasible? I've seen one tutorial where one HC595 drives one 4digit display (not one chip per digit) so I guess it is feasible by cascading them. However I've read a lot about using a dedicated driver like the MAX7219 rather than shift registers. I understand that this will make my life much easier since it does the multiplexing for you. There's also some current considerations in favor of the MAX if I recall correctly.

Question B1: Could I use 8 cascaded HC595N to drive 8 3digit displays? Or do I need more 595s? Am I crazy not going for the MAX7219?

My display is cathode (at least it says it is on the seller's page. It's model "A-2381AS".) I've read that cathode works well with the MAX7219 but I have no other info.

Question B1a: Will I need transistors if I use the HC595 with my 7segment display (c. cathode)?

[u]2) LEDS[/u]

I assume that I should be able to drive 15 leds with the HC595s since there's plenty of tutorials out there dealing with such a scenario. Or should I also use a MAX7219 for this?

Question B2: Use HC595N or MAX7219 for 15 LEDS?

[u]3) LCD displays[/u]

I admit I haven't had time to look into these yet. I got a board for the 1602 so I think that should save me some pins. No idea on how many pins the 3.5in will use.

[u]C) TOAST![/u]

I haven't done the math yet but I'm pretty sure I'm either going to burn the arduino, the chips or both if I don't take precautions.

I have no documentation on either the 7segment display or the standard 3mm/5mm leds.

[u]1) For the displays:[/u] I realise that usually you need a resistor per segment. But since I will be multiplexing, I need one per digit right? How do I figure out what resistor to use? I've found approximate values for red leds in general (1.8v 15-20mA) but I don't know how to calculate a resistor value for an entire digit out of that info. I've seen people reccomend a 330 or 470 ohm resistor for each segment as a general value. Do I just multiply that value by 7 for a digit? I also hope those things don't need more than 5v...

QUESTION C1: Can I use one resistor per digit? How do I figure out the value with no datasheets?

[u]2) For the LEDS:[/u] Since I don't have datasheets on those either I'll use standard values for each colour. One resistor per led, should be fine right?

QUESTION C2: One resistor per led, should be fine if I use standard values right?

[u]3) For the chips (Input):[/u] I admit I havent looked into this at all yet. But shouldnt switches and pots use minimal current? Or at least not enough to be a concern for the chips? Do I even need resistors for them?

QUESTION C3: Will I have any trouble with current limitation on the HC165 and CD4051 for my inputs?

[u]4) For the chips (output):[/u] From what I've read the HC595 can handle 6mA per output. I'm ok with stressing it a bit but I don't want them to burn, it will be a nightmare to debug.

QUESTION C4: Can I connect the outputs in the ways described above without burning my chips up? If not possible, what are the alternatives?Also, how can I calculate in advance how much current I'll be drawing?

[u]5) For the board[/u]: From what I've read there's a max of 40mA per pin and 200mA total (but I've read something about 800mA being available although I don't know how that is possible since USB is usually limited at around 500mA). Is my project going to burn the Arduino? How can I calculate how much current I will be drawing (per pin and total)? If it's going to burn it, how do I do it? Transistors or external power? Both?

QUESTION C5: Can I connect the inputs and outputs in the ways described above without burning the ArduinoMega's pins or the entire thing? If yes, do I need to use transistors/external power with higher amperage? Also, how can I calculate in advance how much current I'll be drawing?

[u]D) PARTS[/u]

I realise I'm still missing a few crucial components like resistors and caps. I was going to get a kit but then I realised that I will most probably need a lot of a certain value rather than a few of many values.

QUESTION D1: Can you, based on the description of the project, recommend certain values for resistors/caps/transistors etc I should get (for example the values I'll probably need the most for 7 segment resistors, LED resistors, decoupling caps etc).


I hope everything is clear (lol who am I kidding). Please don't hesitate to criticize, offer ideas, ask me for more details. I'm just starting with this stuff so I'm open to suggestions. Like I said in the beginning I will be taking my time and working on one thing at a time, but I want to get the hardware sorted out as much as I can.

Thank you!

QUESTION C1: Can I use one resistor per digit?

No, you need one resistor per segment otherwise the brightness will change depending on how many segments are on.

QUESTION C2: One resistor per led, should be fine if I use standard values right?

Yes but what is the "standard value"?

QUESTION C3: Will I have any trouble with current limitation on the HC165 and CD4051 for my inputs?

I think you don't understand inputs, there is no need for any current limiting. See:- http://www.thebox.myzen.co.uk/Tutorial/Inputs.html

QUESTION C4: Can I connect the outputs in the ways described above without burning my chips up? If not possible, what are the alternatives?Also, how can I calculate in advance how much current I'll be drawing?

You have not described how you are going to connect them up so who knows? Answer that and I can answer the rest of the question. However if you use a TPIC6B595 you can handle 150mA per output.

QUESTION C5: Can I connect the inputs and outputs in the ways described above without burning the ArduinoMega's pins or the entire thing?

Inputs do not take any current. Outputs do. Work out the current for one LED and multiply up. You design the current limiting resistor to give you a current, so you decide what that current is and then decide the resistor that will give you that, not the other way round.

UESTION D1: Can you, based on the description of the project, recommend certain values for resistors/caps/transistors etc I should get

No.

Other notes:-

15 rotary encoders

Ouch that will take some monitoring.

3.5in lcd/tft display (most probably need a separate mega for this one)

No you can run it off the same one but you have to get the right sort of display because you have to have enough memory to buffer a screen.

This looks like the sort of question where you want to use our time to save your money.

Why not just buy the parts locally as you need them? And support local businesses (who might then be more inclined to support the business that employs you)

...R

Thank you very much for answering GM, really appreciate you taking the time!

Grumpy_Mike: No, you need one resistor per segment otherwise the brightness will change depending on how many segments are on.

You are right, I made a mistake thinking it like that. I figured 7 segments * 3 = 21 resistors per display but then I realised that's not how it works at all with multidigit displays. I'll need 7 or 8 resistors per display (3digits) if using the HC595, right?

Yes but what is the "standard value"?

Looking online I found a few typical values here and there. For example here http://www.instructables.com/id/Choosing-The-Resistor-To-Use-With-LEDs/

In any case I don't have datasheets for either the standards leds or the leds in the 7segment so I guess I'll have to use such typical values as a starter and then experiment with different resistor values if not satisfied.

I think you don't understand inputs, there is no need for any current limiting. See:- http://www.thebox.myzen.co.uk/Tutorial/Inputs.html

That was my initial thought but I figured I should ask anyway. Thank you for the link though, I understand things much better now.

You have not described how you are going to connect them up so who knows? Answer that and I can answer the rest of the question. However if you use a TPIC6B595 you can handle 150mA per output

.

Yup, that's the jackpot question but I am unfortunately not sure of my connections yet. I'm thinking of connecting the displays in arrays of two displays with two cascaded 595s in each array, so one shift register per 3digit display.Something like this but cascaded.

For the LEDs I was thinking of using two 595s to drive the 15 leds. Like here

Inputs do not take any current. Outputs do. Work out the current for one LED and multiply up. You design the current limiting resistor to give you a current, so you decide what that current is and then decide the resistor that will give you that, not the other way round.

You are right, I'm going to run some numbers and get back at you for that. However I'm a bit unsure on how to go about the calculations so I would appreciate some help.

For example lets say I want to calculate the resistor values for one 3digit display with red leds but I have no datasheet. Here they suggest between 330 and 560 ohms for a 4digit display but they don't explain how they get that value.

If I use 560ohm resistors at 5v(I'm just going to assume that the displays I have use 5v to make my life easier) that's 8.9mA per output or 71.2mA total. That's beyond the HC595s limits (6mA per channel and 70mA total) but let's say vdroop will lower that to acceptable levels.

How do I figure out how much current the Arduino pins will be drawing? Divide the total (71.2mA) by the the number of pins (so 71.2mA / 3 pins = 23.73mA per pin) ?

If I cascade 2 shift registers, do I add the total current and divide by pins [(71.2mA+71.2ma) / 3pins = 47.6mA per pin)?

As far as the LEDS are concerned, since I don't have a vdroop chart for the HC795 I'll use something like 5mA for each led. Might be bright enough, you never know with leds. That will be less than the 6mA pin limit and the 70mA total.

No.

I mean like the most common values that I would be using. For example I'll be getting a few dozen 10uf and 100nF capacitors to decouple the chips. Some 330-680ohm resistors. Maybe some 2n2222 and BC547 transistors just in case. Anyway, it's not that important I'll figure it out as I go along.

Ouch that will take some monitoring.

Can you expand on this? Or just link me to a source. I was reading here and there on using encoders with the arduino and if I understand correctly problems might arise by having so many loops monitoring for changes.

I'll be using the encoders to feed input to the PC and then exporting the results to the 7segment displays.

No you can run it off the same one but you have to get the right sort of display because you have to have enough memory to buffer a screen.

The seller stated it was for an arduino mega. controller R61581 if it helps.

Robin2: This looks like the sort of question where you want to use our time to save your money.

Why not just buy the parts locally as you need them? And support local businesses (who might then be more inclined to support the business that employs you)

...R

Not really, I'm mostly looking for guidance on what hardware I'll be needing for my project. I'll buy what I can afford locally and the rest online.

The first thing you must learn is that instructables are crap when it comes to electronics, do not believe anything posted there. Some things might be right but there is so much wrong it is not worth taking the risk.

You need current limiting on LEDs here is why:- http://www.thebox.myzen.co.uk/Tutorial/LEDs.html You need a vital piece of information before you can calculate the resistor value, and that is the forward voltage drop when the LED is taking the required current. This is in the data sheet. If it is not in the data sheet then as a second best you can measure it. Take something like a 220R resistor and the LED and connect it up to 5V. Now measure the voltage across the LED, you can use this for your calculations call it Vf.

Next decide how much current you want the LED to run at, normally this will be the maximum in the data sheet but it can be lower with little difference to the brightness. Then for any given current the calculation is (Vsupply - Vf) / current in amps = resistance in ohms.

So if Vf is 2V and you have a 5V supply and want to run the LED at 15mA then the resistor should be:- ( 5 - 2 ) / 0.015 = 200R

Grumpy_Mike: The first thing you must learn is that instructables are crap when it comes to electronics, do not believe anything posted there. Some things might be right but there is so much wrong it is not worth taking the risk.

You need current limiting on LEDs here is why:- http://www.thebox.myzen.co.uk/Tutorial/LEDs.html You need a vital piece of information before you can calculate the resistor value, and that is the forward voltage drop when the LED is taking the required current. This is in the data sheet. If it is not in the data sheet then as a second best you can measure it. Take something like a 220R resistor and the LED and connect it up to 5V. Now measure the voltage across the LED, you can use this for your calculations call it Vf.

Next decide how much current you want the LED to run at, normally this will be the maximum in the data sheet but it can be lower with little difference to the brightness. Then for any given current the calculation is (Vsupply - Vf) / current in amps = resistance in ohms.

So if Vf is 2V and you have a 5V supply and want to run the LED at 15mA then the resistor should be:- ( 5 - 2 ) / 0.015 = 200R

Thanks GM, I'll measure the voltage drop when the leds arrive. I think I should be able to run them at 50% or less than their max current. I've done it before with IR leds and it works just fine. Most leds are pretty bright nowadays and I'll be using these as indicators, not illuminators anyway.

I'm still a bit confused about this part though:

For example lets say I want to calculate the resistor values for one 3digit display with red leds but I have no datasheet. Here they suggest between 330 and 560 ohms for a 4digit display but they don't explain how they get that value.

If I use 560ohm resistors at 5v(I'm just going to assume that the displays I have use 5v to make my life easier) that's 8.9mA per output or 71.2mA total. That's beyond the HC595s limits (6mA per channel and 70mA total) but let's say vdroop will lower that to acceptable levels.

How do I figure out how much current the Arduino pins will be drawing? Divide the total (71.2mA) by the the number of pins (so 71.2mA / 3 pins = 23.73mA per pin) ?

If I cascade 2 shift registers, do I add the total current and divide by pins [(71.2mA+71.2ma) / 3pins = 47.6mA per pin)?

As far as the LEDS are concerned, since I don't have a vdroop chart for the HC795 I'll use something like 5mA for each led. Might be bright enough, you never know with leds. That will be less than the 6mA pin limit and the 70mA total.

Are my assumptions correct here? Is that how you calculate current draw on the pins and for cascaded shift registers?

but let's say vdroop will lower that to acceptable levels.

Are my assumptions correct here?

No. You calculate the current draw for each pin assuming it has a 5V output. Then you add up all the current for all the LEDs you want to drive from that chip. If it exceeds the limits of what that chip can supply you then either redesign for lower current or scrap the design and try something new.

You do not cascade shift registers you chain them. You do cascade analogue switches. The two are both very different configurations.

Grumpy_Mike: No. You calculate the current draw for each pin assuming it has a 5V output. Then you add up all the current for all the LEDs you want to drive from that chip. If it exceeds the limits of what that chip can supply you then either redesign for lower current or scrap the design and try something new.

You do not cascade shift registers you chain them. You do cascade analogue switches. The two are both very different configurations.

OK thanks for the corrections. So I use a resistor value that keeps everything in check for each pin at 5v and for the total (and the displays are bright enough). How do I go about finding the current draw for the arduino pins for both single and daisy chained shift registers?

Divide the total (71.2mA) by the the number of pins (so 71.2mA / 3 pins = 23.73mA per pin) ?

If I cascade 2 shift registers, do I add the total current and divide by pins [(71.2mA+71.2ma) / 3pins = 47.6mA per pin)?"

Is this wrong?

vhf1:
Not really, I’m mostly looking for guidance on what hardware I’ll be needing for my project. I’ll buy what I can afford locally and the rest online.

I guess what I really had in mind was that, at your apparent state of knowledge, it would be a good idea to take the project in small steps. Buy one or two components and figure out with a short program how to get them to work. Then get some more parts and do the same thing. When you know how to make all the different parts (and their programs) work separately then start to join them together into your major project.

…R

When you use a shift register the current draw is from the shift register, it has nothing to do with the arduino output. So you look at the data sheet for the shift register you are using. If you have two chained shift registers you treat each one separately, chained or not it makes no odds.

Robin2: I guess what I really had in mind was that, at your apparent state of knowledge, it would be a good idea to take the project in small steps. Buy one or two components and figure out with a short program how to get them to work. Then get some more parts and do the same thing. When you know how to make all the different parts (and their programs) work separately then start to join them together into your major project.

...R

You are absolutely right, that's what I will be doing. Small steps. I'm handy with a soldering iron and general tinkering but haven't really used logic or microcontrollers before. I was just thinking that if someone confirmed that I needed several components that are much cheaper to buy bulk from an online seller I might as well get that information now. But also it's always good to get some general feedback early on a project when you are not really sure of what you are doing.

So yeah, I really appreciate your comments and I hope I didn't seem like wanting you to do all the work for me. On second thought I should have broken down my questions in to parts and posted them in the relevant sections of the forum.

However since I'm ordering components from China

Check prices locally first. Where are you located? Dipmicro.com, digikey.com, mouser.com, taydaelectronics.com (Thailand but shipping from CO it seems) all have very good prices and often with better technical data than China/ebay websites and without 2-3-4 week shipping times. Check the price break points as well. Often bumping up to the next quantity (say 22 -> 25) level can save you money. Even simple stuff like resistors - buy 100 vs 65, total price can be lower even with the higher quantity. Put yourself together a spreadsheet showing your costs to make easy comparisons.

vhf1: On second thought I should have broken down my questions in to parts and posted them in the relevant sections of the forum.

Better to keep them all together so it is easy to see all the info without jumping around.

...R