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

Thread: IO Question

  1. #1
    Junior Member
    Join Date
    Jun 2019
    Posts
    3

    IO Question

    Hi PJRCers,

    I'm working on a synth design on the Teensy 3.6 or 4.0 and could use some advice. Basically trying to emulate the controls on an old analog synth like a Moog Model D, but with an experimental interface for playing. This means a lot of pots and switches, more than the Teensy has input pins for.

    What are my options for connecting all these peripheral pots/switches to a Teensy?
    Is a multiplexer what I'm looking for?
    Do I connect another microcontroller with more IO pins via I2C or something like that?
    What are the limitations/benefits to any given approach?

    Thanks so much for any advice!

  2. #2
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,534
    I’d suggest using a touch screen like for example the Nextion 5” or bigger HMI. This allows you to create as many virtual pots, switches, and so on as you need, organize them in pages as it makes sense, with only a few mouse clicks. This is the maximum of flexibility and once a layout created, it communicates your actions with a few bytes over a serial port with up to 250kb/s without generating whatever additional CPU load since the HMI is an independent Subsystem with its own MCU.

  3. #3
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,257
    There are lots of options. One option is to use the I2C or SPI buses to provide digital input/outputs or analog inputs. On I2C, you can connect multiple devices, each with a different address. On SPI, each device has a separate enable pin (CS):


    Using a microprocessor allows you to tailor your inputs/outputs, and you can be more intelligent, of only sending information when something is changed instead of having the 3.6/4.0 having to poll each pin. You might look at the Teensy LC. You can communicate with Serial UARTs, i2c, spi, etc.

  4. #4
    Junior Member
    Join Date
    Jun 2019
    Posts
    3
    Thanks yíall.

    Wow, Michael, thatís exactly what Iím looking for.

    So there might be some efficiency advantages of using a separate microprocessor as opposed to one of these IO expander chips? This may be hard to answer, but do you think using one of those chips would take a significant toll on a teensy 4.0 with say, 16 extra analog inputs? Would the processor speed be the limitation, or is it more complicated than that?

    This is really helpful. Thanks again.

  5. #5
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,257
    Quote Originally Posted by toutant View Post
    Thanks y’all.

    Wow, Michael, that’s exactly what I’m looking for.

    So there might be some efficiency advantages of using a separate microprocessor as opposed to one of these IO expander chips? This may be hard to answer, but do you think using one of those chips would take a significant toll on a teensy 4.0 with say, 16 extra analog inputs? Would the processor speed be the limitation, or is it more complicated than that?

    This is really helpful. Thanks again.
    I don't know. Human reaction time is so much slower than microprocessor time, but i2c speeds are somewhat slow. With the i2c digital boards, there is one or two extra wires that can be used as an interrupt when a button is pressed or released. And instead of doing 8 separate i2c requests to poll each button, the actual interface returns 8 or 16 bits at a time, and you can do one call, and then just look at the bits set/cleared. SPI is somewhat faster than i2c, but it too has bus speed limitations. I believe that all analog reads are done as a step wise refinement.

    I.e. it first compares the voltage with a voltage that is 1/2 of the max value, and if the input voltage is higher, it then compares 1/2 between 1 times the max voltage, and if it is lower, it compares between 0 and 1/2 the max voltage -- it iterates over until the appropriate number of bits requested has been satisfied, and then returns that value. You can change the number of bits used if you need a faster or more accurate value. Note, there are physical limits that without a lot of careful attention to detail, that prevents you from getting too accurate of a reading.

    But the having multiple processors means the slave processors will accumulate all of the state in parallel and ship it off to the master processor. It also allows for the processing to be done nearer where the physical buttons are. If the distance is a factor and/or you have a noisy environment, you can also add things like error correction to make sure the bits got through correctly. And in a complicated setup, you can just replace one outboard processor with some number of buttons and analog inputs, without having to rewire the board. It is so much fun (not) if you have a wire break/solder coming apart/etc. to trace the connection of 50+ wires going into a microprocessor.

    On the other hand, having outboard processors can be more programming.

  6. #6
    Junior Member
    Join Date
    Jun 2019
    Posts
    3
    Fortunately I think there's a good amount of wiggle room in terms of accuracy/refresh rate/resolution for any of these analog inputs. (An LFO rate knob doesn't need precise 1024-value resolution refreshed 100x a second!)

    But this gives me enough to start working it out in an actual circuit to see how different options respond.

    Thanks, again.

Posting Permissions

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