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

Thread: MIDI pot chatter / noise

  1. #1

    MIDI pot chatter / noise

    Hi,
    I used a teensy 2.0 and other poeple's tried and true code to run a simple usb midi controller with 6 footswitches. It worked perfectly.

    Then I decided to just use 3 footswitches and 12 potentiometers as a second project.

    Here's the issue: If I just solder a single potentiometer to the teensy directly to A0, ground, and vcc it works perfectly. When I connect more there seems to be random chatter or noise that the teensy converts into MIDI CC signals. The footswitches still work flawlessly as well.

    So: 1 pot = Perfect
    Footswitches by themselves = perfect
    more than 1 pot = random chatter.

    any help? I wonder if the amount of wire needed for 12 pots is picking up interference but how could I possibly avoid that?! I'm not using excessive loops of wire or anything. Is there a known Issue I am missing in terms of hooking it all up together? The potentiometers are cheap ones but they all seem to be fine when working on their own (B10k)

    DJTT_DIY_MIDI.ino

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,064
    Sometimes adding a small ceramic capacitor close each analog input pin and GND helps. Usually values between 1 nF to 100 nF (0.1 uF) work well.

    If you have a long wire, sometimes adding a series resistor between the pin and the wire helps. Usually 1K is a good resistor value to use. The resistor works together with the capacitor to filter away high frequency noise, so try the capacitor first and only add the resistor if needed.

    If you are sending 5V power to pots connected by long wires, the power line can also pick up noise. There's also a risk of the power getting shorted to GND. Usually a PTC "fuse" is used between the 5V power and the wire to the pot. Try to get one rated for 50 mA or less. Adding a ceramic capacitor between the 5V power (on the long wire side of the PTC fuse) can also help if the noise pickup is bad. Larger value capacitors are ok for the power wires, but usually ceramic capacitors are more effective than other types, even if those others are larger capacitance. Avoid low quality ceramics, pretty much all the ones where the 3 letter code starts with "Y" or "Z". The "X" ones are good, and NP0 or C0G are the highest quality (but usually only fairly low values). Plastic film capacitors also work pretty well for filtering away noise, but they tend to be physically larger and more expensive than ceramic.

    Sometimes noisy measurements are unavoidable. Of course you should try adding those capacitors and other parts first, to get the signals as good as possible. But if you need to do more to clean it up in software, the ResponsiveAnalogRead library can help. Look for its examples in File > Examples > ResponsiveAnalogRead.

  3. #3
    Senior Member oddson's Avatar
    Join Date
    Feb 2013
    Location
    Isle in the Salish Sea
    Posts
    1,090
    Even thought the smoothing code isn't great in that old sketch it should be enough to eliminate chatter from pot noise if you build carefully and there are no long wire runs.

    (Make sure you don't leave any pin you are reading 'floating'. If the chatter is mostly or exclusively on one CC value look for wiring problems from that pin.)

    Apart from any build issues I would recommend switching to the example file "Many_button_knobs" in the Teensy/USB_MIDI examples (it's not perfect either but it's a huge improvement over the code you're using).

    https://github.com/PaulStoffregen/Te...aster/USB_MIDI

    This uses the basic features of the ResponsiveAnalogRead library to which Paul's response refers.

    Hardware filtering and power conditioning steps are not normally needed for seven-bit resolution as the noise is usually in bits 9 and 10 only with a good pot and a short, clean wire run.

  4. #4
    Member ETMoody3's Avatar
    Join Date
    Mar 2014
    Location
    New Ulm, Mn
    Posts
    36
    A trick I use very often to good result is to "oversample" the inputs.

    Code:
    int filterArray[5]{};
    
     for (int l =0; l <5; l ++)
     {
      filterArray[l]=analogRead(yourPin);
     }
    
    int bunny = ((filterArray[0]+filterArray[1]+filterArray[2]+filterArray[3]+filterArray[4])/5);
    where bunny is the controller data you want and yourPin is attached to the pot.

    I have a *lot* of these little filters going in different devices ( some on attiny 85 chips ) and have no issues with the time this takes.

    As for putting knobs or optical sensors in a remote box up to 30 feet away I like to use another microcontroller like a sparkfun pro mini 3v as a i2c slave. Or an attiny85.
    Last edited by ETMoody3; 05-05-2019 at 01:10 AM. Reason: something to add

Posting Permissions

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