Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 13 of 13

Thread: Teensy 3.0 speed and how to connect many leds, buttons and potis?

  1. #1

    Teensy 3.0 speed and how to connect many leds, buttons and potis?

    Hi,

    I'm working on a drum sequencer with 60 knobs, 40 buttons and 80 leds… I currently prototyp it with an arduino mega2560, but I consider to switch to a Teensy 3.0 or Due… I would prefer the Teensy for it's smaller size, but I'm not sure about it's speed and i/o connections…

    1. Is the Teensy 3.0 faster than a mega2560? The mega runs at 16mhz, the Teensy at 48MHz. It should be faster, shouldn't it? Are there any things I need to note (maybe a slower flash, slower i/o pin access, slower spi, etc.?)?
    2. Also how compares the Teensy to the Due? If I would overclock it at 96Mhz it should be also faster, right?
    3. Can I use the timer like on the mega2560? My drum sequencer dependents on the timer for correct midi clock.
    4. How would you connect so many leds, buttons and potis on a Teensy? I need a fast responsive time and the leds should blink without noticable lag (thats why I consider to switch to faster microcontroller). My current setups runs with daisy chained 595s for LEDs, daisy chained 165s for Buttons and 4051s for the potis… Can I improve this setup for faster responsiveness (I currently don't notice any lags, but my sequencer code is maybe only to 10% finished)? Will a faster microcontroller read/write the pins faster?
    5. Will it slowdown the hardware spi, if I connect 2 devices on it (a sd card reader and an oled display)?

    Thanks. I hope I didn't asked to many (stupid) questions :/

  2. #2
    Senior Member MickMad's Avatar
    Join Date
    Feb 2013
    Location
    Essonne, France
    Posts
    154
    1. You answered yourself.
    2. Teensy 3.0 and Arduino Due are quite similar, yet different. The main difference is the processor. The Due has a cortex M3, while the Teensy 3.0 has a cortex M4. Moreover, the Teensy 3.0 processor has a different set of peripherals than the one on the Due, altough most of them are equivalent.
    3. Yeah , you can use the timer, although your old code for the mega2560 will be useless on the Teensy 3.0; I mean, the processor-specific code will be useless, your application-specific code can be the same. Look for PIT Timer and FlexTimer on the forum for more info about the timers on the Teensy 3.0
    4. If your setup worked on the mega2560, I can't see why shouldn't it work on the Teensy 3.0. I mean, a multiplexer works indipendently of the stuff you plug it into. And of course, a faster microcontroller will read/write faster.
    5. I don't know, but you can use multiple ports so there should be no problem.

    Just one more thing: welcome to the forum !!

  3. #3
    Thanks

    6. Pit Timer seems to be the same as the timers on arduino/avr, right? Are they as precise as arduino timers?

    7. I'm a bit confused about adding external power supply to 3.0. How much volt should I add? And If both usb and external power is supplied, what happens, if I disconnect e.g. the usb? Will it automatically switch to external power without turning off? So can I use booth?

    8. Do the touch pins allow to detects touches on encoders/potis? I remember to read about it.

    9. How do I address the different serial ports? Can I send different data over them (e.g. for several midi outputs)?

    10. Do I need to provide voltage to the aref pin or is it as default 3.3v?

    Thanks again
    Last edited by flocked; 10-20-2013 at 12:54 AM.

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    17,022
    So many questions! You'll generally get better answers if you describe more of what you're trying to accomplish.

    It sounds like you're trying to build a MIDI controller, perhaps with a huge number of inputs?

    Teensy 3.0 is faster than Arduino Mega and similar in speed to Arduino Mega. But for applications that are primarily I/O, how you design your software, and the quality of the libraries you use, will make a dramatic difference. That's why you can get much better advise here if you write about what you're trying to accomplish. Many of us have a lot of experience, but you don't gain much from our experience if we just answer simply factual questions about the hardware.

  5. #5
    Okay,sorry

    So I try to build a small midi drum sequencer which controls and sequence an external drum expander (a drum synthesizer without sequencer and sound parameter knobs, but midi input).
    There are two midi ports connected to tx and rx. The sequencer sends 24 midi clock ticks in every quarter note. That's why I need a precise timer. I use a 16 bit timer on Mega.
    It has 40 buttons: 16 step buttons, 10 track buttons (for switching between bass drum, hihat, etc.) and several other buttons. The buttons should of course react immediately. I currently have them connected via 5 daisy chained 74HC165, but I'm not sure If I will get performance issues later when my code get's more complex. Is there a better way to handle this many inputs?
    Same question with all my leds. I use 34 bi color leds (three leads) & 52 normal leds. This are 15 74HC595. They are again daisy chained.
    For my 64 potentiometer I use 9 4051. The potis change the sound parameter of my drum sequencer. They send midi cc values to the drum expander.8 4051 are connected to the input of one 4051. I need to read the potis as fast as possible to change the sound without any lack.
    I also have two things connected via SPI. An oled 128x64 display and a sd card reader for saving the patterns.
    Should I stay with this many 4051s, 595s and 165s or are they to slow? And should I connect them normally to my Teensy or should I connect the 494 and 165 via SPI? As said I already have the oled and sd card connected to it and I fear a slowdown.

    Thanks again

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    17,022
    I think any of these boards will be fast enough.

    Just to keep things in perspective, a 3 byte MIDI message transmitted by a serial port to that drum machine takes 0.96 ms. Human perception of "instant" is limited to about 10 ms.

    These are both very long times, compared to rapidly clocking shift register data.

    The Teensy3 ADC is faster and can be configured for different speed vs resolution trade-offs. For 64 pots, you probably want that better speed. But even with the "slow" ADC on Teensy2, at 0.1 ms each, you can still read them all in 6.4 ms, which is far less than human perception of lag. They also aren't always needed at all times, since many control parameters of certain sounds that trigger at certain times, so you really only need to read the pot in the instant before that happens.

    Of course, it's possible to design slow software, no matter how fast the hardware is or can be. Teensy3 will make things a little easier, but paying attention to doing things well in the software is the thing that will make the biggest improvement in responsiveness.

    However, I would recommend you do NOT use Arduino Due. I just looked at their code again to double check, and both USARTClass.cpp and UARTClass.cpp lack interrupt-based buffering in their write() functions. Due only buffers incoming serial data, not outgoing. To make this project work well, you really need buffering of the outgoing MIDI messages, so your code can keep scanning the inputs and generating the data with proper timing. Without buffering, your Serial1.write() or Serial1.print() (or the code within the MIDI library that transmits) will stall when it needs to wait for the previous 2 bytes to transmit. Output buffer is critically important for this project. All Teensy boards have it in the core libraries, and most Arduino boards have it, except Due.

  7. #7
    Awesome thanks! I just bought the 3.0

    I „finished“ the schematics for my drum sequencer and I would love to finally start to design the board. However I’m not sure, if I connected everything correctly. It is my first schematic and two months ago I never really touched electronics (except soldering…).

    I would be super grateful, if someone could check my eagle schematic. I get a few warnings.

    A few things to note:

    - I’m not sure, if I’m using the 4051 correctly. :/
    - I’m only using the OLED and SD card with SPI, as I fear a slowdown If I connect the 165s/595s via SPI. Would it slowdown or could I connect everything on SPI?
    - I’m currently using a microsd shield by adafruit. I might add the sd reader on my own, but I got confused If I still need a 3.3v regulator (Teensy provides 3.3v)
    -I didn’t chain all 595s in one chain as I somewhere read that it gets slower the more 165 I chain.

    Can I use the touchRead() to detect touches on encoders? Something like this.

    Here is the link to the schematic: https://www.dropbox.com/s/nwp7lgp8o2...%20Machine.zip

    Thanks
    Last edited by flocked; 10-21-2013 at 06:01 PM.

  8. #8
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    17,022
    I'll take a quick look, if you post a schematic as a PDF. (I don't use Eagle)

    Can I use the touchRead() to detect touches on encoders?
    No. Or at least not in any reasonable way.

    touchRead() reads the capacitive coupling (to GND) of whatever metal is connected to the pin.

    For rotary encoders, you need the Encoder library.

  9. #9
    Thanks!
    Here is the link to the schematic as pdf: Link

  10. #10
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    17,022
    Those 74HC595's might have trouble driving enough current for LEDs when running from only 3.3 volts. It will probably work, but the LEDs might not be as bright as you want.

    I didn't see values for the pots. Using 10K should work fine. You probably want to avoid higher than 10K. You'll probably also need a brief delay between switching the 4051 mux and reading the analog voltage, to allow time for the resistance of the pot to charge the capacitance of all those other chips. Probably 10 to 20 microseconds is plenty.

  11. #11
    Thanks (:

    Yes the potis will be 10k.

    Can I anyhow get more current for the LEDs? Could I maybe connect the 595 VCCs to the power of the power jack (on pdf 1)? I plan to connect a 5v power supply. But I also want the LEDs to light, if the Teensy is only connected via USB… :/

    And did I connected the power jack correctly to the Teensy? I'm a bit confused about usb power vs. a external power supply. I want the following behavior: If I connect an external power supply the Teensy should use it and if the power supply gets removed it should use the usb as power (if usb is connected…). Do I need to add anything?
    Last edited by flocked; 10-21-2013 at 08:27 PM.

  12. #12
    Okay. I answered most of the questions myself

    However I'm still facing the problem of driving 32 one color + 40 bi color leds (these) with the Teensy. As you said, driving this many leds with 3.3v 120ma drops the brightness to much.

    I thought about using constant current LED sink driver with a separate voltage (5v or 12v, that I have also available on my board). These driver seem great tlc5925 & tlc5926.

    However someone told me that I can't use them as they don't handle such a high voltage at the output.

    I'm getting confused. Do you think that I can use them?

    ---
    btw. I ordered a pcb with 6 different capacitive slider designs to try out which works best with Teensy. i will soon write a small post about touch sliders & touchread

  13. #13
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    17,022
    Quote Originally Posted by flocked View Post
    I thought about using constant current LED sink driver with a separate voltage (5v or 12v, that I have also available on my board). These driver seem great tlc5925 & tlc5926.
    Those look pretty nice. The LEDs control is only on/off, not PWM dimming.

    However someone told me that I can't use them as they don't handle such a high voltage at the output.
    The datasheet says they can run on 5 volts, but not 12 volts. Should work fine if you use only 1 LED per pin, or maybe 2 in series, if you have pairs you want to turn on together.

    I'm getting confused. Do you think that I can use them?
    I think so.

    One possible issue is the input signal voltage they require. It says logic low is 0 to 0.3*Vdd and logic high is 0.7*Vdd to Vdd. Anything between 0.3*Vdd to 0.7*Vdd could be unknown. If you use 5.0 volts for Vdd, those two points are 1.5V and 3.5V.

    Teensy 3.0 will output a 0 to 3.3V signal. So the logic high output from a Teensy 3.0 pin doesn't quite get to the 3.5V these chips need for a reliable logic high. You're very close. It will probably work anyway. But to be properly designed within the specs, a best approach would use 4 buffers to increase Teensy 3.0's 0 to 3.3V signal to 0 to 5v. A 74HCT245 chip would be one way. It's low input is 0 to 0.8V and it's high is 2.4V to 5V, and it will output a 0 to 5V signal that meets the input specs for those LED driver chips.


    btw. I ordered a pcb with 6 different capacitive slider designs to try out which works best with Teensy. i will soon write a small post about touch sliders & touchread
    I hope you'll share your findings, maybe even with a photo?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •