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:
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
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
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.
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?
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)?
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.
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?
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.