Connecting several teensies via serial

Status
Not open for further replies.
Hi,

I'm making a musical keyboard using the touchRead() function with some 16channel multiplexers. But it's an awful lot of keys, so, in order to scan them all fast, I need at least 4 teensies. So I thought I could have those 4 scanning and sending the data to a fifth teensy, the one that'd be plugged to the usb and would power the rest through the Vout pin. We'll call this the mother teensy.

Two issues:
1) a teensy has only 3 serials, how do I connect 4 of them to the mother? Maybe if they share the same serial in and serial out, the mother could guide them like: "1st teensy, hand me your readings. Ok, now that you're done it's time for the 2nd teensy. Ok, now the 3rd... etc" and so prevent their messages from overlapping. Would this work? Would it add any significant delay?

2) how many teensies can I power from the mother? Considering each is handling 6 16channel muxes.
Could this affect to the performance of the touchRead() function?

Thanks for reading.
(By the way, this is a continuation of this project: http://forum.pjrc.com/threads/26602-Isomorphic-keyboard )
 
Though it might seem intimidating, if you can get CAN to work, it's sort of perfect for something like this.
 
I recommend a single serial bus or I2C doing all this work.

For either implementation, I would look into using the EasyTransfer library from Bill Porter that would do all the heavy lifting. Then use a master-slave approach where the master goes round and and round querying each teensy for an update and the teensy's replying which keys are active.
 
Thank you for your quick responses!

I'll take a look into the I2C approach. CAN sounds promising but perhaps too much of a hassle for me.

Constantin, when you say a single serial bus - do you mean a setup more or less like the one I described above? If so, is there any significant difference between that and using I2C, performance-wise? It would be nice to save one hardware component.

Does anyone know how to calculate an aproximation for 2)? I'm planning more complicated instruments for the future and it would give some peace of mind to know where's the limit.

Thanks again for your attention :)
 
You can break out the VUSB pin on the master and use that to power all the slave teensies using the VIN pin. That way, the master does not have to supply power to any teensy, your USB bus will.

Theoretically, you should be able to hook up all 5 teensies to one USB bus as long as they're not maxing themselves out... after all, each teensy might be able to draw about 150mA before its voltage regulator starts to burn out. Under normal operation, I'd expect a power draw per teensy to be closer to 30mA. Also consider that while a standard computer-based USB connection can handle 500mA per spec, external chargers don't usually look for a negotiated rate, they simply supply as much as they can / is needed.

The advantage of the serial bus is that you don't need the pull up resistors and in some ways it's easier to debug than I2C communications. I've used 1MBit/s communications in the past (same PCB, two atmel AVRs talking to each other) so it can be done either way. I'd lean toward serial simply due to implementation speed and you can modify the buffer easily to accommodate longer messages.

Externally, I would consider designating a input pin or three to determine the "address" of the teensy. That way you can write one 'slave' program and plug a teensy into any of the PCB headers and it would just work, no reprogramming for each position required. You could either use a analog resistance approach (i.e. use an analog input pin on a voltage divider where voltage varies by position) or use multiple digital pins pulled high or low to determine the 'bus address'. The former approach requires one pin and two resistors per teensy, the latter approach would require three digital pins (for up to 8 addresses).

All that said, if it were me, I would be scanning these keys using multiplexers, not lots of teensies. It's less money and IMO also easier to implement. Here is how I would do it:

1) Use multiple 16:1 multiplexers like the CD4067BE series from TI (even comes in a DIP form factor, i.e. bread-boardable!)
2) These multiplexers require four digital address pins, and perhaps a fifth pin on your teensy in case you want to play with the strobe pin (i.e. enable). Power would come from the teensy, they don't need much.
3) Bring all the inputs back from the multiplexers to the teensy. You'll need one digital input per multiplexer, the multiplexers can share the four address pins + the strobe pin.
4) Whether you have one multiplexer attached or 15, the approach remains the same: change the address, allow the signal to settle, then read each input channel, rinse repeat.
5) Perhaps a pull-down resistor (10k) on each line would help establish whether there is a digital 'on' signal or not? Others likely have way more experience with this than I, I'd defer to them! But easy enough to breadboad and experiment.

For a keyboard application, a single teensy should have more than enough bandwidth to cover hundreds of input keys without issues, especially if the signals are digital (i.e. over a hundred scans of each key per second). For analog operation, there could perhaps be a need for a buffer (op amp) and a different mux (analog devices makes some very nice ones for analog operations that have very low 'on' resistance). IIRC, the Teensy ADC can operate north of 100ksps in 16 bit mode. As long as you take care of the inputs (i.e. present it with a good signal), you should be able to sample a lot of signals with just one teensy...
 
Last edited:
Thanks Constantin, all my worries solved!
I like the idea of using digital pins as address.

I'm using 16chan multiplexers already, more specifically the CD74HC4067E from TI, but when one teensy is reading all channels from more than 6 multiplexers you can clearly notice it's scanning slow enough to miss rhythmic gestures. I think the main reason for this is the large base capacitance the multiplexers add to the reading (about 3000). Perhaps it's a matter of finding the right multiplexer, I'll keep trying different models.
 
Wow, that is a lot of capacitance being added. FWIW, I've used the ADG706 series from AD in the past and the spec sheet claims 5pF capacitance. The 'only' downside is the cost $6.5 ea, and the form factor (harder to breadboard a TSSOP-28).

All that said, I'm sure Paul would be delighted to sell you more teensies, so I'll stop promoting other solutions. ;)
 
Wow, that is a lot of capacitance being added. FWIW, I've used the ADG706 series from AD in the past and the spec sheet claims 5pF capacitance. The 'only' downside is the cost $6.5 ea, and the form factor (harder to breadboard a TSSOP-28).

All that said, I'm sure Paul would be delighted to sell you more teensies, so I'll stop promoting other solutions. ;)

Too late :p
I just realized those muxes have an ON resistance of 2.5 ohms, while the ones from TI had around 70 ohms, that might be the reason.
However, I bought the muxes already so for this time teensies are coming :)
 
Status
Not open for further replies.
Back
Top