Simple switch matrix - Page 1
Forum section: electronics / projects

author: c4757p
author_rank: Super Contributor
timestamp: September 01, 2013, 12:38:01 am
content: Just thought I'd share this with anybody who is interested. I wanted a switch matrix to do automated testing of another project I'm working on, so I threw this together. I'll add more when I get it completed. (I'm currently dealing with a bug in the firmware that I suspect to be a very smelly brainfart, and I haven't done the enclosure)4x6 matrix of switches, including four matrix positions which allow up to 3A, controlled via USB.Sorry about the picture quality, I couldn't find my camera so I had to use a potato.

author: Paul Price
author_rank: Super Contributor
timestamp: September 01, 2013, 02:09:00 am
content: Looks relay pretty.

author: c4757p
author_rank: Super Contributor
timestamp: September 01, 2013, 02:14:09 am
content: Groan-worthy puns? What, are you trying to bemenow? That'smyjob!By the way, PCB is from Elecrow. Thought I'd give them a try. Not quite as nice as ITead - the silkscreen is smudged in a couple places, the HASL isn't quite L* (this was actually enough to be a bit of an annoyance with the TSSOPs, I imagine it could be a bear with lots of fine-pitched packages and reflow soldering), and the silkscreen registration is off a bit. It just looks kind of cheap, at least up close. One of the boards actually had a solder lump hanging off one of the pads. But electrically, everything is just fine, nothing questionable in the copper and the drill registration is spot on.*I just picked up another one and looked a bit more closely. The HASL finish is perfect on one side, and lumpy on the other. On the lumpy side, the pads rise above the solder mask, so that when you're placing a chip, it tends to fall with its pins in between the pads. There's probably enough stuck to the pads to solder many components with just a bit of flux - I'm not really convinced the hot air ever touched that side... The lumpy side is not consistent, I have about half with smooth top and half with smooth bottom.

author: Dave
author_rank: Super Contributor
timestamp: September 01, 2013, 02:49:18 am
content: Aaaaaaaand... you are going to have to bodge it. You need to tie one of the CBUS pins on the FT230X to ground, and configure the chip, so it doesn't go into suspend mode. Silly FTDI with their buggy chips.Other than that, pretty sweet looking board. What are you going to use it for?

author: c4757p
author_rank: Super Contributor
timestamp: September 01, 2013, 02:58:50 am
content: Dammit! I knew that, too! I knew there'd be something stupid on this board, I threw it together way too quickly. (And notice the lack of mounting holes?)Quote from: Dave on September 01, 2013, 02:49:18 amThe "pressing" need was to do a long-ish-term test of the voltage reference board I just made. I want to switch my only PC-interface-capable multimeter* onto a few signals, including the reference output, internal temperature sense output, input current shunt resistor, and a separate ambient thermometer, once every 30 minutes or so for a few days. (I included many more inputs than I need so I can use it for whatever the hell else I can think of, too)*Not counting the 3468A, which you kindly sent me the interface board for! (Thanks again) But I haven't had a chance to play with the software side of that yet.Edit: Theerrata note from FTDIsays it has been fixed in silicon revision D, which is what I have. Is that true?

author: c4757p
author_rank: Super Contributor
timestamp: September 01, 2013, 03:49:12 am
content: Ah yes, it was indeed a smelly brainfart, I screwed up the PROGMEM accesses in an array of structs containing strings.(The "it's almost midnight and I'm chugging coffee" solution was to just move the data to RAM, since I used a mega168 instead of the mega48 I specified and have bucketfuls of RAM...)Andwhycan't the compiler manage this on its own? God, it has no trouble sticking const data in non-writable blocks on a PC...Works a treat.

author: free_electron
author_rank: Super Contributor
timestamp: September 01, 2013, 05:47:39 am
content: you using those Meder sil reed relays ? ive had bad experience with em. they tend to be sticky ...Coto is far better.

author: David_AVD
author_rank: Super Contributor
timestamp: September 01, 2013, 07:46:55 am
content: Do you have a part number for that 6 pin programming header? I've just started using Atmel devices, but only have unshrouded male headers in stock. It would be nice to get the shrouded version so the programmer can only be plugged in the right way.

author: notsob
author_rank: Frequent Contributor
timestamp: September 01, 2013, 08:27:34 am
content: shrouded headershttp://www.ebay.com/sch/i.html?_trksid=p2050601.m570.l1313.TR12.TRC2.A0.Xshrouded+header&_nkw=shrouded+header&_sacat=0&_from=R40or get name brand ones from a distributor.

author: David_AVD
author_rank: Super Contributor
timestamp: September 01, 2013, 10:14:10 am
content: I know what type the connectors are, but for the life of me couldn't find the 6 pin ones on Digikey or Mouser earlier.After changing the search terms to "PCB header" I narrowed it down and found them. Thanks for the eBay tip though.

author: c4757p
author_rank: Super Contributor
timestamp: September 01, 2013, 12:19:41 pm
content: Quote from: free_electron on September 01, 2013, 05:47:39 amCoto is indeed good. These are Hamlin, actually. I bought them on eBay a few months ago for about half the usual cost and figured I'd put them to good use.David, no idea on the header, it's been loose in a drawer for at least a year now

author: baljemmett
author_rank: Unknown
timestamp: September 01, 2013, 11:44:49 pm
content: Quote from: c4757p on September 01, 2013, 02:14:09 amInteresting - I had them make a couple of designs up about six months ago, and don't recall noticing anything amiss (although I have no real experience for comparisons!). Just took a closer look at some of the spares boards and can't spot any issues; either I got lucky or you got unlucky, I guess. I'd presumed, from the identical specs/requirements and even the 'Fusion' branded EAGLE CAM/DRC setting files, that all these cheap prototyping services used the same board house for production - or perhaps several in rotation.(Also, I am very impressed with the output of your potato. Mine always seem to lack fine detail; perhaps I need to parboil them before exposure?)

author: c4757p
author_rank: Super Contributor
timestamp: September 02, 2013, 12:01:42 am
content: Yeah, they probably use the same few board houses. Most of the ones ITead uses must not be too ghastly, I've had very good luck with them. Perhaps I'll give Elecrow another try next time and see if they come out any different.Quote from: baljemmett on September 01, 2013, 11:44:49 pmYou have to hold itjustright. A bit of salt helps, too.Edit: Aaaaaaaaaargh... GCC....... it's a great compiler for PC, but the optimize-for-size mode is pretty crap for MCU. I just dropped from 3280 bytes to 3246 byadding function prototypes for the functions in main.c. I can only presume it was too stupid to "look ahead" and see them while running the optimization if I didn't mention them first.....?And even with -Os, I can spot a few places in the disassembly where it stuffs a register multiple times without actually using the intermediate values...

author: Mike Warren
author_rank: Unknown
timestamp: September 02, 2013, 04:00:04 am
content: Quote from: c4757p on September 02, 2013, 12:01:42 amAnd people keep calling me an idiot for preferring to use AVR Assembler.I thought that FTDI bug was fixed in the latest (D) revision?https://www.eevblog.com/forum/projects/ft230x-what-am-i-missing/msg168068/#msg168068

author: c4757p
author_rank: Super Contributor
timestamp: September 02, 2013, 04:03:43 am
content: Quote from: Mike Warren on September 02, 2013, 04:00:04 amSpeaking of which: I shaved another 5% or so off by compiling the code as - get this -C++.Next bit of firmware will be all assembly. Screw this shit.(Yeah, I'm putting way too much nitpicking and effort into a little serial command interpreter that flips a few relays.)

author: c4757p
author_rank: Super Contributor
timestamp: September 02, 2013, 10:26:53 pm
content: Hey, not too much nitpicking - I'm taking the time to finish off the serial interface code and put together a well-written "standard" serial library for other AVR projects, since I'm switching to AVR. (Most of the good ones out there are GPL)And look at this fart GCC let out:Code:ldi r31,0adc r31,r1clr r31sbci r31,hi8(-(RX_BUFFER))pop r31This is with size optimization ON!I have not left out any r31 operations. So...... clear r31, set r31, clear r31, set r31, set r31. Where's "read r31"? What a piece of shit! Why is "check for register stores not followed by a read" not an optimization step with-Oson?? Kill me now.....Anyway... on to replace a few chunks of code with assembly...I take it the GCC developers haven't had to work with anything with RAM measured in KB in alongtime.

author: Unknown
author_rank: Unknown
timestamp: September 02, 2013, 10:44:57 pm
content: Quote from: c4757p on September 02, 2013, 04:03:43 amThere are subtle differences between how const is defined between C and C++. The C++ definition is stricter and allows for more optimization. There may be other differences that are relevant, for example in the aliasing rules. C++ is not a strict subset of C, although most incompatibilities are fairly minor. It may also be that the C++ compiler has different default flags than the C compiler.Quote from: c4757p on September 02, 2013, 10:26:53 pmMy guess is that they use one of the flags set by sbci after the pop. Note that adc and sbci both set and use the carry flag, and clr sets a bunch of other flags. Although I can't see how adc would set the carry flag since r31 is 0 at that point.Edit: if the carry set was set before the ldi, and r1 is 0xff, then adc will set the carry flag.

author: c4757p
author_rank: Super Contributor
timestamp: September 02, 2013, 10:55:31 pm
content: True. I forgot to mention that the only things between that and the function end were st, lds, subi, and sts, none of which use the carry flag.Silly register use aside, the output is really not that bad; I shouldn't criticize it that much. I can save some more space by replacing a few key sections with assembly, but I have yet to find a whole function that really needs a full asm rewrite.

author: c4757p
author_rank: Super Contributor
timestamp: September 03, 2013, 08:26:18 pm
content: And... here it is!There's only one thing that I don't like - there is actually somewhat substantial leakage between the column inputs (on the order of 50 meg). They run somewhat close together all the way up the PCB (I probably should have unmasked the copper, or at least strips between them). It's just enough to make autoranging DMMs with hi-Z ranges oscillate if the relays are disengaged and voltage is applied.