Bit of checks - Page 1
Forum section: electronics / beginners

author: alarai
author_rank: Newbie
timestamp: June 08, 2019, 11:47:40 am
content: Hello,That will be my first post here and most likely not the last.First of all please bear with me I'm an absolute electronics beginner. I've some very old memories of a bit of Technology classes with the relation with Voltage/Intensity/Resistors.... Unfortunately that teacher was not great and as for the realisation of the project, let's just say that not once in the four years there was this subject did we ever managed to complete a project, although I was very interested in doing so. So I'm sure I may have done mistakes although it seems to work on my messy test bench (check picture attached) for which I did a small PCB which ends up working just fine, but it was nothing like what I'm going for, which is to just have everything on a single "quite big" PCB in the end.My very basic project is to replicate the panel that controls the autopilot functions of a Boeing 737, all that to link it to my computer and to my flight simulation program. That has been a very long time thing I wanted to do, and I finally got the time to go for it. I'm a programmer so I knew I could come up with a solution for the programing part. Which is why this will all be linked to an Arduino/Genuino Mega board. As the picture do not show it the whole thing is actually working well as far as I can tell. So that's why I'm onto the next step to make it a nice real thing. And my objective in the end is to make all of this available to anyone that want's it. Basically Open Source Software and Hardware.So you will find attached my complete schematic which I've made through KiCad 5 in PDF. I've tried to use busses and hierarchy so that it's not too messy, so I hope I did it well. It's exactly what I have on the breadboards. And the first page lots of connectors will match the same connectors of the Arduino, basically the idea I have doing this is to upt pins in those places and just link it this way to the Mega board. That way Should I do anohter board for another cockpit, I could just use a single Arduino Mega board and swap it on the right panel to use.To give a summary there is :17 simple leds (green one) which I drive through two 74HC595 ICs and the 17 one is directly linked to an Arduino Input as it would be too much to add another IC for just one LED.21 buttons of which 17 are push buttons and 4 are toggle switches, which inputs I get through three CD4021 ICs6 rotary encoders6 displays of digits which are each one driven by a MAX7219 IC and will have depending on the need either 3, 4 or 5 digits (1 three digits display, 2 two digits displays or 1 three digits and 1 two digits displays respectively)From my time spent on making this I've made sure that there is no ERC error in KiCad, and I've also made sure that each IC has it's own 0.1µF ceramic capacitor between it's VCC and GND (which I know should be as close as possible to the V+ pins when doing the PCB). An exception is the MAX7219 which also have an additional Electrolytic 10µF capacitor as per the datasheet instruction).So obviously to me beginner it seems alright like I did it, but before going further, I think I'd try to get some advices to not make something wrong, as the later stage already seems quite daunting just placing everyting properly on the PCB and wiring seems like a daunting task.Thanks for reading this very long post (I know I tend to write too much) and for the upcoming answers and advices which will be very helpful to me to finally get this little baby done, which is done in the breadboard, but obviously not usable in this sateCheers

author: Brutte
author_rank: Frequent Contributor
timestamp: June 08, 2019, 01:02:22 pm
content: Hi and welcome.My remarks:1. Breadboards hate when you are shuffling these around. Glue them to some plywood. Make some holder for arduino, standoffs and mounting holes for PCBs.2. Your schematic copies and pastes same design several times, with minimal changes. IMHO you should have designed one generic display. Do you really need 4 designs with 2,3,4 and 5 digits? Make a 5 digit one and reuse it. You can always leave some parts unpopulated.3. LEDs use quite a lot of current. Are you sure this is capable of working from USB? Did you try 88888888?4. The MAX7219 has SPI interface. Just connect all of them daisy-chain.5. For current setting for MAX7219 I'd use a potentiometer instead of a fixed resistor.6. Why do you use MAX7219 for 7-segment and 74HC595 for LED? Again - reuse the design and the library and do not multiply designs (unless there is a good reason behind that decision).

author: rstofer
author_rank: Super Contributor
timestamp: June 08, 2019, 01:54:46 pm
content: Definitely consider one of the Maxim display drivers.https://www.maximintegrated.com/en/products/power/display-power-control/MAX7221.htmlI did a Microsoft Flight Simulator external control project some years ago and it was pretty interesting code. I used one of the Teensy 2.0 CPUs because PJRC provided RawHid USB code.https://www.pjrc.com/teensy/rawhid.htmlI have also used one of the Maxim 16 digit display drivers for another project. It is basically just a 40 pin DIP with SPI in and the usual LED driver outputs. You can find various versions on the web site. Whether you can find them in stock is a separate problem. Maxim parts are sometimes hard to source.16 digit driver MAX 6954https://www.maximintegrated.com/en/app-notes/index.mvp/id/321016 digits on a single SPI channel. A really nice chip.https://www.digikey.com/products/en?keywords=max6954It's actually in stock at DigiKey in a 40 pin DIP - the exact one I used.

author: mariush
author_rank: Super Contributor
timestamp: June 08, 2019, 02:16:22 pm
content: I'd add something like 47-100uF near the 0.1uF decoupling capacitors on chips which have the potential of consuming bursts of current all of the sudden.You should consider using a LED driver IC to drive your LEDs.The shift registers are fine but there's some fineprint : most have around 25mA current limit per pin and around 70-100mA overall current limit. So even if you limit current to each LED using resistors to something like 15mA, if all leds are lit you may exceed the overall current limit and your LEDs may become dimmer.There are cheap led driver ICs that are basically a combination of a shift register and current limiting, so you can use them just like shift registers and you set the current limit for all leds with just one resistor. In addition to that, some even let you send a command through i2c or spi that lets you set brightness to a percentage or level (ex 256 levels, a 8 bit value) which sets the leds to a percentage of the maximum current you set with the resistor.For example, check outTLC5916INorTLC5917IN, a 8 channel shift register ... each channel can do up to 120mA and you can set maximum current with one resistor and adjust output current by setting a 8 bit value (output current between 3mA and 120mA ... or the maximum current set by your resistor)So it is a bit more expensive, but you're not having to add one resistor for each led, you only need one resistor per shift registerThey're serial, you only need 4 wires to control multiple of these, you can chain them together like regular shift registers, see page 22 in the datasheet:http://www.ti.com/lit/ds/symlink/tlc5916.pdfAlso notice you can power the chips themselves with 3v..5v and you can power the LEDs separately with up to 20v, so for example if you have a 12v power supply / wallwart adapter or 18v laptop adapter, those leds could be powered directly from this higher voltage and the led drivers will limit the current just fine. This takes the strain out of the 5v power supply ... for example if you set the led current to 10mA, you don't have to worry about 17x10 = 170mA of current loading your 5v linear regulator or USB.As for your buttons, what I would suggest is to use port expanders.A port expander is a chip which creates multiple I/O pins, which can be set to input or output and you can read the state or set the state of each pin from your microcontroller through SPI or i2c.Here's for example some super cheap 16 I/O port expanders:Microchip MCP23017 (i2c) :https://www.digikey.com/product-detail/en/microchip-technology/MCP23017-E-SP/MCP23017-E-SP-ND/894272Microchip MCP23S17 (SPI) :https://www.digikey.com/product-detail/en/microchip-technology/MCP23S17-E-SP/MCP23S17-E-SP-ND/894276You could chain two of these (giving each unique address on the i2c bus or just by using the serial passthrough, pinout is the same on both chips, the i2c version just has two disabled pins that are used for serial on other version) and you get 32 I/O pins.Another benefit of using these is that they support interrupt on change, meaning you can configure them to send you a signal when the state of a single pin changes (like when you'd push a button). So provided you have decent debouncing in your code, you would have to read the state of your buttons only when your Arduino receives an interrupt from the expander chip... so instead of reading 100 times a second, you may read only 20 times a second, whenever a button changes state.If you feel like you need a resistor for buttons you could consider resistor arrays... for example see this 8 x 1k resistor array :https://www.digikey.com/product-detail/en/bourns-inc/4609X-101-102LF/4609X-101-102LF-ND/3593658You connect pin 1 to 5v and the other 8 pins to each button or switch, so when you press a button, 5v goes through button/switch, limited by the 1k resistorIt's more expensive, yes, but you're saving on PCB space, pins, etc... if the buttons are grouped close together.However, for just buttons, considering you have 21 inputs, you could do a trick if you want to save some money :* have one 16 I/O port expander* configure the first two pins as output , and the other 14 pins as inputs.* power the first 14 buttons from the first pin that's set on output , and power the remaining buttons from the second pin set on output , connect the second pin of all buttons and switches to your 14 pins set on input (one button/switch from each set to one input pin)* this works if you don't send power to both sets of buttons at the same time, it's like multiplexing ... this way you can connect up to 28 buttons / switches on your 14 input pins of your port expander chip.In your Arduino, you can set the first output pin high and the second pin low, and now only the first 14 buttons receive power. Wait a ms, then read the 14 inputs ... if a button is pressed, then you get some voltage on your input pins.Now turn off the first output pin and turn on the second pin, wait a ms or so and read the other set of 14 buttonsIf you read buttons every ms, you can basically read all 28 potential buttons 500 times a second (if you wait 1ms between each reading of buttons)The MAX7219 are kind of expensive but if you already bought them, I guess you could use them.If you're not afraid of a tiny bit of surface mount soldering (you can solder these to an adapter board which converts them to DIP) you could have used led driver ICs which have lots of channels.For example, thisTLC5955DCARhas 48 channels, so you could easily display up to 6 digits at the same time using one ( 7 segments + dot , times 6 = 48 channels) and they cost 5$ each if you buy 10, compared to around 10$ for a single genuine MAX7219They also have maximum current limit (30mA), and you can power the LEDs themselves with up to 10v (so if you have a 12v power supply, you could use a 7809 linear regulator to power the leds instead of using 5v)These use SPI, so again you could have all your displays on a single SPI but, chaining all the displays with 6 wires (voltage, ground, serial in and out, clock , latch)

author: rstofer
author_rank: Super Contributor
timestamp: June 08, 2019, 03:58:57 pm
content: I would build up a PC with the Maxim 6954 chip, a header for the SPI data, clock and ground to come in, a header for the power/gnd and headers for each display. That's all I board would have on the board.For each display, I would build small PCBs to mount the 7 segment displays with as many digits as seems appropriate and a header to match whatever I brought out of the master board above.I would want these displays to be modular and built in some easily managed scheme.There are also display drivers for individual LEDs or, more likely, an array of LEDs.I tend to use locking MTA style connectors like this:https://www.digikey.com/product-detail/en/te-connectivity-amp-connectors/640445-6/A1973-ND/109099Or, I might see if these will work:https://www.sparkfun.com/products/11441With these displays, all the hard work is done. Unfortunately, they will all be 4 digits. Maybe that could still work...

author: alarai
author_rank: Newbie
timestamp: June 08, 2019, 04:24:58 pm
content: Well that's already a lot of things :p I'll try to answerQuote from: Brutte on June 08, 2019, 01:02:22 pmSo trying to go in order, it's true I've not thought of reusability.For the digits yes I really think I need the different size because it makes things more manageable as I'm trying to then fit everything in the size of the real thing which is about 480mm by 73mm, so making the full 5 digits all along means it will take 10% more of the space I have on the width to have the 7 additional 0.36 7 digit units, and as there is all the other components I need it seems to me it would be hard to find space for everything and the traces.Quote from: Brutte on June 08, 2019, 01:02:22 pmIt's a bit hard to say for sure but on my test it seems to work. In the case I need more would it be correct to for example take the 5V from the Arduino like I've done so far but then add some port on the side to get an additional USB connector just to pull power from a second port so that it's enough. In which case should I separate those and drive different parts or just use them all on the same net together ?Quote from: Brutte on June 08, 2019, 01:02:22 pmIt's something I had not thought of. I'll try to see as the main thing I need is to controlled each one separately as much as possible, which makes the program easier as it just does all the samething, and that I need on some of these to blink, so if I need to update all 6 screens every time I want to update only one that might not be the best solution. Also I'm not sure it's easy to run everything on the full width onf the board.Quote from: Brutte on June 08, 2019, 01:02:22 pmI'll see to that, this one is easy.Quote from: Brutte on June 08, 2019, 01:02:22 pmWell for this one it's from what I've seen I would need much more pins of the arduino to control a 4 digits module from the example I've seen i needs 7 pins instead of 3 for the max7219 so it seemed better to me to use those as I would need a lot more traces and ICs in a "constrained space".

author: alarai
author_rank: Newbie
timestamp: June 08, 2019, 04:31:25 pm
content: Quote from: mariush on June 08, 2019, 02:16:22 pmWill take sometime to take in it looks better than what I did though I'm not sure I would manage all that which sims basically much more complex thant what I'm managing so far.I must say I absolutely don't know if I need those resistors for the buttons, as I basically took that from the example I found so I've not really wondered about that. And for the resistance array it seeems it might be complicated becaue the buttons are completely scattered on the PCB not at all next one to another except a few.I will remain clear of SMD I really have no confiodence in using those with my skills :p

author: mariush
author_rank: Super Contributor
timestamp: June 08, 2019, 05:23:17 pm
content: In general, I'm reluctant to use Maxim parts because they're often out of stock and they're expensive in low volume. Also, often things that have these on boards are using fake Max7219 chips, or chips that failed various quality checks, so quality between individual display boards can vary.I'd like to add a few things for you to consider.If you plan to power everything from 5v from your USB, you really should concern yourself with power consumption.Chips like MAX7219 are LINEAR led drivers, which means that they're not very efficient.Let's go with an example: Let's say you have a red or green or amber seven segment digit and you limit the current to 10mA for each segment and you display an 8 with your MAX 7219 chip.Since all seven segments are turned on, the seven segment digit will consume 7 x 10mA , plus a few mA consumed by the chip itself... let's say 75mA in total. This means the display will consume 5v x 75mA = 375mWWith more digits, the power consumption will be about the same, because the MAX chip will turn on and off digits so at any point in time, only one digit is actually powered - your eyes are just too slow and see all digits lit up. If you record with a camera, you will see that some digits are brighter than others, or you'll see some flickering, caused by the multiplexing.But you seem to have 6 displays so in total, these displays may consume up to 6 x 75mA = 450mA if you show a full 8 digit and you limit the current to 10mA per segment... that's a lot of current.However, you know that the forward voltage of red leds is around 1.7v..1.9v and green/yellow/amber leds typically have a forward voltage of around 2v..2.2v so the actual seven segment display consumes only 2.2v x 70mA = 150mW ... around 250mW is wasted as heat inside the MAX7219 driver. It's practically less than 50% efficient overall.These chips require minimum 4v to function, so you can't really get this power consumption much lower.Now, if you look at the chips I suggested above like TLC5916IN, you can see a major benefit : the leds can be powered by another power supply.You know that the forward voltage of the leds will be around 2v..2.2v, so you could power the leds from 2.5v or 3v.What you can do is to buy a very cheap highly efficient switching regulator to convert 5v to 2.5v with around 90-95% efficiency, here's a 1$ example on eBay :example linkSo if you need 0.5A of current at 2.5v, this dc-dc converter will take only around 275-300mA from 5v. You're saving around 200-250mA by doing this.The chip itself can continue to be powered from 5v but will only consume a few mA, but the actual power hungry stuff, the segments, will be powered from lower voltage so there's gonna be less losses.The downside is that each of these led drivers can only do 8 leds, so one digit (seven segments + dot).Of course, you can chain multiple together to have 2 digit , 3 digit and so on but you need seven segment displays that are common anode, but each segment is separate.Here's some examples:* single digit yellow-green 2v 20mA :https://www.digikey.com/product-detail/en/inolux/INND-TS56YGAB/1830-1157-ND/7604996* single digit red :https://www.digikey.com/product-detail/en/inolux/INND-TS30RAB/1830-1146-ND/7604982* two digit red :https://www.digikey.com/product-detail/en/broadcom-limited/HDSP-521G/516-1208-5-ND/637472The two digit usually have two anodes, so you can light up only one digit at a time if you want.You can mix single digit and dual digit to get 5 digits if you need toAnother downside of not using a MAX chip is that you lose that automatic multiplexing, so if you have 4 digits and use 4 drivers in series, and you display 8888, then you'll consume 4 times as many segments lit up at the same time, compared to using a single MAX chip, but since you're powering the segments with only 2.5v you're not really consuming the same amount of power.Instead of around 350mW, you're now using 2.5v x 4 x 70mA = 700mW ... which only around twice as much power.You don't get flickering as you no longer multiplex.However, there's nothing saying you can't save power by multiplexing. Since you have the individual anodes, you could use for example a single 8 bit led driver with multiple digits. You just have to switch between digits ( set the 8 bits on the driver, send power to anode of first digit, wait a few ms, turn off anode, update driver with next digit's segments, turn on anode for 2nd digit and so on)For each display, you'd have the 4 data wires for the led driver and the 5v and ground to power the chip itself, and you'd have 2.5v (or higher) for each digit's anode.Or, you could multiplex at display level... have each display turn on for 5-10ms, then turn off for 5-10ms while the other display is on

author: Nominal Animal
author_rank: Super Contributor
timestamp: June 08, 2019, 06:25:01 pm
content: You might wish to take a look at Robert Archers 737-200 project video:He is using15+(no,31+) Teensy microcontrollers (programmed in the Arduino environment). The Teensyduino add-on even has dedicated support forflight simulator controls. Because of the native USB support (not USB serial), no OS drivers are needed; the Teensies work as native joystics/keyboards/human interface devices in all OSes.

author: Brutte
author_rank: Frequent Contributor
timestamp: June 08, 2019, 08:47:31 pm
content: Quote from: alarai on June 08, 2019, 04:24:58 pmUse external power supply. USB is not a good source to power such count of LEDs. Leave some headroom.Quote from: alarai on June 08, 2019, 04:24:58 pmUse one SPI and connect everything daisy-chain. You do not want to play with 6 SPI interfaces.Quote from: alarai on June 08, 2019, 04:24:58 pmDaisy-chain. Then you need 4 pins (and power) no matter how many modules you have.Again, I would suggest using one design, one chip and go in the direction of modularization and simplification instead of burning resources.Design one SPI module to drive one 7-segment display (or 8 LEDs).Then write a library and test this one module till you reach perfection.Then connect as many modules as you need, in daisy chain.Mind you do not have to have those modules physically separated. These may be 5 designs one-by-one on same PCB. Choose modularity here and burn energy during flight.Also, if you do daisy-chain, I find it very convenient to loop MISO from last SPI slave back to uC.This is not necessary in many applications (as in yours) but in a development you can super easily find out any bugs that can happen in transmission as data shifted out and data shifted in is in some relation (this is usually same thing but delayed).

author: alarai
author_rank: Newbie
timestamp: June 09, 2019, 09:56:18 am
content: Ok well from all of this I'm trying to improve things.I don't think of using the 74HC595 as it would just be too much as I'd need one IC for each Digit which means 23 Ics even if they can be chained it'll just use so much space on the board, unless doing some kind of daughter boards and all but I4m really not really ready to go in that direction.Although I feel like I should definitely use less MAX7219 and use them to actually control with one a pair of digits displays.Right now I had in order a 3 digits, a 4 digits, another 3 digits, two 5 digits and one 3 digits.I could use one for the 3 and 4 digits, and two for each pair of 5 and 3 digits. which cut by half the number of MAX7219 used. As for commonality I could eventually use this IC as well for the single LEDs.I've tried to make the basic layout of the board for the parts that will be manipulated, I really can't see adding unique ICs per digits on this space. I've imported a reasonable enough picture to have a reference for placing those active components. Maybe using SMD IC would leave more space but I4m really not confident enough in using those.