Arduino based loops switcher project review (i2c, MIDI) - Page 1
Forum section: electronics / projects

author: ltourist
author_rank: Contributor
timestamp: February 22, 2015, 04:05:35 pm
content: Hi,I almost done the PCB for my next (and let's be honest, first real) project, but before ordering it I would like advices and/or errors checking.A barely identical schematic is already done on a breadboard, and the firmware development is almost done (missing some optimizations)The project is an 8 audio loops switcher controller over MIDI and/or USB (using USB-MIDI driver) :Powered with aLM340-5.0Based onarduino micro(ATMega32u4)MIDI achieved via USB-MIDI driver and6n137standardMIDI diagramStorage use an24LC256(i2c)Loops controlled using anMCP23017(i2c)Loops output controlled usingbistable latch relays7 segments displayand user inputs use anAS1115(i2c). Input debouncing is software basedIs there any stupid errors a beginner like me could have done in schematic and/or on PCB layout ? Also, How can I compute the maximum power needed when all relays are turned on/off at the same time ? Is there any special considerations I should take regarding the load spike that might occurs when this happens ?I'm not asking for a full/detailed review, but if someone has some spare time, be my guestThanksEDIT : As it might be useful for some people one day, I updated the schematics and PCB with all remarks :Separated ground planes for audio jacksSeparated 5V rail for relaysUsing ULN2803 for driving relaysChanged bypass wiring based on PeterZ proposalThanks to PeterZ and picandmix

author: picandmix
author_rank: Frequent Contributor
timestamp: February 22, 2015, 06:07:11 pm
content: Thats quiet complex for your first project !From your post it sounds like you are going straight from design to a PCB ?Assume you have not built a prototype on some strip board or similar to prove everything works as you expect, not to mention with the controlling software ?You do really need to prove everything before you waste money on a pcb.Without studying the pcb in detail, the thing that stands out to me are those long thin tracks going to the relays, they look very fine and very close, do they meet the standards of the pcb makers , their sites typically explain what they can and cannot produce.For the relays its case of Ohms and Watts laws, the datasheet gives the voltgaes, resistances and wattage so you should be getting about 14 or 28ma per coil depending on the device.While you have used a lot of transistors and diode to turn them on, using the ULN2803A chip with their 8 drivers and 8 diodes makes thing a lot easier.What you need to check in to and consider is that the transistor used means that there is a voltage drop across it so when switching 5V the coil will only get about 4.4v, so assuming you are using a 5v relay will that voltage be enough ?According the the Datasheet it should be, but you should prove it first.As you can see your relays will create a lot of switching interference on the 5v line which all your micro/logic chips use, so would suggest you add a separate regulated power line for them, to avoid any such problems.Sure others will be able to add some more hopefully constructive help.

author: PeterZ
author_rank: Regular Contributor
timestamp: February 22, 2015, 06:26:33 pm
content: Found one mistake: C10 will kill all your incoming MIDI transmission.

author: ltourist
author_rank: Contributor
timestamp: February 22, 2015, 06:29:09 pm
content: Quote from: PeterZ on February 22, 2015, 06:26:33 pmOops thanks, that one was intended to serve as a decoupling capacitor between VCC and GND for the 6N137. I obviously mixed up the pins

author: ltourist
author_rank: Contributor
timestamp: February 22, 2015, 06:53:29 pm
content: Thanks a lot for the advices !Quote from: picandmix on February 22, 2015, 06:07:11 pmI've already built almost the full circuit on a breadboard (except for the Arduino part, I use an Arduino micro for now). The software is up and running, and all seems to work as expected !For the record, I've already built a similar project with 4 loops using a plain arduino uno and some cheap panel mounting jacks and relay boards. This is the first attempt to make a full home-made deviceQuote from: picandmix on February 22, 2015, 06:07:11 pmThey're 10 mils width (the minimum in my DRC rules) with a 10 mils clearance. It seems that most fabs handle 6 to 8 mils nicely, but I choosed some extra safety. Does the length of those traces can be a problem ? As this is a super-long PCB (around 30cm), each additional centimeters cost a lot more and this is the only way I came up with to reduce the height.Quote from: picandmix on February 22, 2015, 06:07:11 pmThe ULN2803A seems to be very usefull in that case indeed. I'll try to gather some and test those on the breadboard prototype (only four loops are wired on it).Quote from: picandmix on February 22, 2015, 06:07:11 pmWell, I've tested it with the only lacthing relays that my local supplier had in stock and this works flawlessly. But you're right, I should test it with the choosen parts first !Quote from: picandmix on February 22, 2015, 06:07:11 pmThis is a nice suggestion (it may also allows me to choose some "lighter" 5v regulator for the micro part of the circuit). About relays powering, I was wondering if the fact that loads won't be continuous but rather "spike-ous" induce some design considerations ? If I'm right, the maximum load should be around 224mA, which is rather light, but I prefer to ask anyway.Thanks

author: PeterZ
author_rank: Regular Contributor
timestamp: February 22, 2015, 07:01:44 pm
content: Another one: generally you'd need a resistor (like 10k) in series with the bases of the driving transistors (Q1-Q8). The relays are latching ones, which means you probably control them by sending a pulses. However, when the corresponding GPxx goes high it sees a Base-Emitter diode going directly to GND, without any current limiting. MCP23017 can source max 25mA.

author: ltourist
author_rank: Contributor
timestamp: February 22, 2015, 07:11:50 pm
content: I couldn't find that one by myself, thanks a lot again ! I finally understood the whole concept of the current limiting resistor, which was pretty obscur (well, I didn't really see the uses cases) to me before that !As I may go with the ULN2803A and as each Darlington transistor have a 2k7 resistor in series according to the datasheet, it seems I won't need any resistor (I would need a 200R to be within the MCP23017 maximum rating specs).But I learned something today !

author: PeterZ
author_rank: Regular Contributor
timestamp: February 22, 2015, 08:13:59 pm
content: Yep, using two ULNs instead of that small crowd of transistors is a good idea. One thing i'd add is to separate the ground paths for the audio signal and the relay power. You actually don't need to connect the audio ground with the rest of the circuit. There is no active electronics powered from the 5V in the signal path. There are just contacts inside the relays which will turn on or bypass an external device. The grounds will be provided by the i/o cables. Good solution would be to provide one point where you can connect the power ground and the audio signal ground (ground lift switch etc) if necessary.The way you laid out the pcb right now may lead to potential problems:- switching transients from the relays coupling into the signal path (ground return path!)- since you will be plugging many different devices (mains powered too) into the loops, it may create nasty ground loops resulting in low f hum.Next option: you could use a slightly different bypass scheme (see the attachment). The difference is when the device present in the loop is bypassed, it's input is grounded, thus killing any possible oscillations. From my experience, if you plug a high gain distortion pedal into one loop, even the proximity of the contacts within a relay is enough to make a screaming oscillator out of it. There are few other factors involved, like if the input is in phase with the output, but it really depends on a particular FX pedal, something you may have no control over.I have designed and built a few midi controlled bypass switchers in the past. As usually, the devil is in the details!Is the midi channel fixed or it will be editable via push buttons/display?Nice to see someone using Kicad! Enjoying it myself too!

author: picandmix
author_rank: Frequent Contributor
timestamp: February 22, 2015, 08:16:02 pm
content: It all depends on how confident you are regarding your design and testing to date.Trying to modify such as small board as that, due to finding a bug, could be problematic.As for those long lines, I'm no pcb expert, thats a specialist subject in itself, but given they are just the low speed dc lines to the relays they should be ok.However the long lines from the switches could well be a problem, I know from experience that long unshielded lead on inputs can pick up lots of interference from the relay switching.You might want to consider some filters at the IC end of those lines, perhaps something like these ? though its a design area not often covered.http://www.farnell.com/datasheets/321055.pdfThat ULN2803 can connect drively to your IC and relay coil, no extra parts needed, but do ensure you have the 'freewheel diode' pin 10 connected to Vcc.The usual 100nf close across its power line and I always like to put 100uf or so across to help smooth any peaks.There is a whole range of relay drivers ULN 2003 2004 etc designed for use with different logic levels .I'm no Midi user, so just have to ask, whats the purpose of the latching relays v standard ones ?Also the smd pcb , are you having that printed and the components assembled for you, it looks like a lot of delicate ics to fix yourself, by whatever method ?

author: ltourist
author_rank: Contributor
timestamp: February 22, 2015, 10:55:01 pm
content: I'm really glad to see that amount of help regarding my circuit. Thanks to the both of you.So :Quote from: PeterZ on February 22, 2015, 08:13:59 pmIasked about thatsome time ago and came to the conclusion that separated ground planes wasn't necessary. Are you talking about separated ground planes or just leaving the ground planes as it is (covering the audio path) and isolate the jacks ground from it ?About the ground return path. Actually, I just saw that my Q?? GND isn't covered by the ground planes most of the time. That is a consequence of the complex routing due to the many transistors used. I hope I can get rid of it with the UN.As far as I understand ground return path, a signal GND will always try to "return" as closely as possible to its "origin". So I must provide the simpliest and fatest way to do that. Is that correct ?Quote from: PeterZ on February 22, 2015, 08:13:59 pmI haven't noticed any hum in my previous 4 loops switcher, but that's also a nice suggestion. God I wish I knew this earlier, so I would not have to do the audio path routing again. A real pain in the ass to do without using vias !The MIDI channel will be up to user from 1 to 15 (or in omni mode if set to 0).Quote from: picandmix on February 22, 2015, 08:16:02 pmDoes it matter that those switches will be on a separated board (that line is a v-score) ? I could eventually shield the board from the back side, but the ground plane should be pretty good doing that ? Moreover, if a dedicated power supply is used for the relays, there shouldn't be any interference back from the relays to the rest of the PCB, right ?The freewhell diode usage has been duly noted.Quote from: picandmix on February 22, 2015, 08:16:02 pmThey only drain power while changing state. It's not midi or audio related. But on my 4 loops system (so, 8 standard relays), I'm nearly using the full 1A load to maintain them in labor. With lachting relays, I'll only use about 224mA max !For now, I'm planing to do this myself (love soldering :p), but I want them to be "pick and place compliant" in the case I make more of them. The most delicate IC is the AS1115 which has a very small pitch, but it's managable if you do it patiently (already soldered one on an adapter to use on my breadboard).

author: PeterZ
author_rank: Regular Contributor
timestamp: February 23, 2015, 09:07:18 am
content: Quote from: ltourist on February 22, 2015, 10:55:01 pmI'm talking about separating the in/out jacks ground from the rest of the circuit. I would just split the ground plane as shown on the pic below and use a switch/jumper to connect it to the main GND. Btw, are there any non visible vias? Some of the transistors are not even connected to the ground (gnd.png).Why to separate grounds? While in theory in may not be required, you have to remember you will be using the device with many different types, some of them will be isolated from the mains earth line, some not. How do you plan to power your device is another story. It's easy to run into grounding issues. I'm certainly not trying to show you the best way, just judging from my experience it good to provide a few extra options at the design stage. Especially if it is one of your first projects.Quote from: ltourist on February 22, 2015, 10:55:01 pmThat switching scheme is not really about reducing hum, but rather keeping the unused devices inputs not floating.Is there any reason for not using vias?Btw, if your 4 loop version using non latching relays draws 1A of current, there might be something wrong with the circuit (lack of Qx base resistors i guess).

author: ltourist
author_rank: Contributor
timestamp: February 23, 2015, 01:00:56 pm
content: Hmmm I always though that if I split the ground plane for audio ground, I had to make it cover the whole audio path including the relays. (seethat topic)No, I missed some gnd connection as I said earlier. The problem is that my KiCad version does not seems to consider ground planes as connections (or I misunderstood the "unconnected" tool) so nearly every GND I have is marked as unconnected.Quote from: PeterZ on February 23, 2015, 09:07:18 amOk I see. I restarted the relay schematic yesterday around 1AM but give it up pretty fastI'll resume it this evening.There is no reason why I try to not use vias here apart from minimizing their numberI've read multiple times that via number should be minimized without really understanding why (because I cannot learn everything at once) so I take this advice as granted and applied it the extreme way to the audio path signal.As for the relays on the 4 loops version, they're controlled by a board with a schematic approxymately equivalent tothat oneso it should be OK on that side. But they powered from the same power line used by the logic, and each of those relays needs approx 120mA to stay in labor, thus consuming a total of approx 1A.

author: ltourist
author_rank: Contributor
timestamp: February 23, 2015, 11:59:33 pm
content: Quote from: PeterZ on February 23, 2015, 09:07:18 amI've just noticed that with your wiring that hot point of each jack could be wired to standard ground and their ground would be connected to analog ground at the same time. Does this not risk to create any sort of problem (even if the audio signal does not pass along those wires in that particular case) ?

author: ltourist
author_rank: Contributor
timestamp: March 03, 2015, 11:19:59 pm
content: If any of you is still monitoring this topic, I updated the first post with the updated schematics and pcb according to your recommandations. Thanks to both of you !The only thing I didn't include was the EMI filters on the switches : these are two separated board and they will be separated by several centimeters from each other so it shouldn't be any problem.I'll probably gonna order the PCB by the end of the week. If I find some time, I might upload some pictures of the results and (let's hope not) comment on errors to avoid for others

author: PeterZ
author_rank: Regular Contributor
timestamp: March 04, 2015, 08:29:23 am
content: Oh sorry, i missed your previous post.Surely, if you are going to mute the signal on the SEND jack, you want the signal line to be connected with the analog ground, not the digital/power ground of your controller circuit. What happens if you decide to isolate the audio ground from the rest (R2 not installed) and the relay will short it to ground potential as you have done now? It may be floating or not. Tie pin 4 of the relays to GNDA. The changes on the pcb won't be too drastic, you can run a short track from the pin 4 to analog ground plane.

author: ltourist
author_rank: Contributor
timestamp: March 04, 2015, 12:26:16 pm
content: Don't worryThat's what I thought when I started reading your answer : pull a wire from pin 4 to the GNDA plane rather than inducing a complicated ground plane shapeI also spotted an error on schematics : R7 (the interrupt pull up resistor on the front panel driver) should be tied to VDD not GND.Thanks again for all your answers, you've been of great help !