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

Thread: SoftPot to Pitch Bend MIDI questions.

  1. #1

    SoftPot to Pitch Bend MIDI questions.

    Hello everyone. I recently got a Teensy 3.2 along with a SpectraSymbol 500mm SoftPot, which I am hooking up with a breadboard. My goal is to make a ribbon MIDI controller that outputs pitch bend information.

    I have some noob questions about this:

    1. Am I hooking it up right? I have the middle pin going to A1, a wire from the negative pin to the teensy AGND, and a wire from the 3.3V of the Teensy to the positive pin.

    2. What are the differences in the analog pins of the Teensy? Does it matter which one I plug into?

    2. Do I need a pullup or pulldown resistor? I see conflicting answers everywhere I look about this. Can't seem to get it straight.

    3. What is the best way to cut down MIDI information. With the Teensy running at its normal speed it generates a huge amount of MIDI messages. Right now there is some noise in the output, ideally there would be a way to smooth out the noise but not smudge really fast pitch transitions. I essentially want the ribbon controller to behave as a string on a stringed instrument: when you hold the string steady, there is no pitch wavering, but you can still instantaneously change pitch by putting another finger down. I'm having trouble achieving this with filtering.

    4. My analog reading on my SoftPot seems to settle at around 180-280 when it isn't being touched. Is this normal? It shouldn't be a problem because I bought a long force sensor to put underneath the SoftPot for Aftertouch messages and also the ability to detect when pitch bend information should be sent, but I'm just curious.

    If anyone has any insight I would appreciate it!

  2. #2
    Senior Member
    Join Date
    Nov 2015
    Location
    Wales
    Posts
    579
    1) Yes that's correct, although don't forget to set the Teensy to use the 3.3V reference for the ADC. This is done with analogReference()

    2) No idea. I believe the ones on the top are 5V tolerant and the ones on the bottom aren't

    2.2?) Nope, you want to measure the voltage between the 'wiper' and ground. If you pulled this up or down the voltage wouldn't directly represent the resistance

    3) Sounds like you want to filter out the low frequencies. Perhaps a software high pass filter?

    4) Sounds like your noise floor is 0->100 and your pot has an offset of 80. When you read your value minus 80 from it and ignore any high frequency noise under 100

  3. #3
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,851
    On the Teensy 3.2, the analog pins that can also act as digital pins (A0-A9, A15-A20) are 5v tolerant, while the analog pins that are analog only (A10-A14) are not 5v tolerant.

    Note, when doing an analog read on pins that are 5v tolerant, anything voltage over 3.3v (or whatever the reference is) is treated the same as the analog reference.

  4. #4
    Thanks for the responses.

    Would the reference already be set to the right value? Whenever I see example Teensy code I don't see anyone calling analogReference(). I'm putting analogReference(DEFAULT); in my code now but it doesn't seem to make a difference.

    I think I worded one of my questions awkwardly. The noise I am experiencing doesn't doesn't range from 0 to 100.

    This is how it is working:

    - If I touch the potentiometer at the top I get about 1023. If I let go of it it stabilizes at around 280.
    - If I touch the potentiometer at the bottom I get about 1. If i let go of it it stabilizes at around 180.
    - There is about +-3 in about mid-high frequency noise.

    I feel like a high pass filter would absolutely ravage my readings, since it would get rid of all slow movement on the ribbon wouldn't it?

  5. #5
    I'm not sure this is possible or practical, or even the best way to do this, but I guess in my mind I'm sort of looking for an intelligent algorithm that can change how it samples based on how fast potentiometer readings are changing. If you are moving fast it samples faster, if you are moving slow it samples slower. It would also be able to differentiate between noise and movement, so it could smooth out the noise without compromising important readings.

  6. #6
    Senior Member adrian's Avatar
    Join Date
    Oct 2015
    Location
    Wellington, NZ
    Posts
    504
    One way to get less readings is to only get a reading if there has been a change ... hysterisis .... so if the new reading (using a sample rate of X ...) is the same as the 'current' reading plus or minus 4, then there is no midi output. if the new reading is different from the 'current' reading plus or minus 4 then there is midi output ...

    Here is some code illustrating the approach .... the variable "hyst' is the amount of hysterisis... 4 is what I use for really jittery pots.

    Code:
                      if (currentPinRead > (hystPinRead + hyst)) {
    					currentPinRead = hystPinRead;
    					//call decrease ... midiout (currentPinRead) ...
    					
    				}
    			      else if (hystPinRead > (currentPinRead + hyst)){
    						currentPinRead = hystPinRead;
    						// call increase ... midiout (currentPinRead) ...
    				}
    Now the sample rate ... you would be surprised how slow you need to sample!!! For a fader attached to a teensy analog pin, you can sample every 2 milliseconds and still get good smooth data....

    As for the noise you get when you are not touching the softpot, that is very peculiar (to me) ... I think you need to look at the analog circuit you are using, or maybe just get a fader .... they work great ... or an ordinary rotary pot .. As you may have guessed, I have no idea what a softpot is ...

    Does it have a separate capacative touch line?? maybe you could use that to switch off sampling when there is no contract with the pot ...

  7. #7
    Thanks for the help. This is what I bought https://www.sparkfun.com/products/8681

    I don't think it has a capacitive touch line. I'm pretty new to this so I wouldn't know how to check.

    For the hysteresis, I suppose you would have to linearly increase or decrease to the target value, or else it would lower the resolution of the readings. I'll have to experiment with it.

  8. #8
    Senior Member oddson's Avatar
    Join Date
    Feb 2013
    Location
    Isle in the Salish Sea
    Posts
    1,360
    I wonder if the drift on release is the 'wiper' losing electrical contact with the resistive material. Maybe that is where the pull down suggestion comes from.

  9. #9
    I even saw a suggestion to put a 10k Ohm resistor between the power source and pot and a different 10k Ohm resistor between the ground and pot. I tried that and it made the signal about 3 times more noisy. It did however make the bottom of the pot read about 200 or so, and when you let go it would slowly fall below that value.

    Really not sure how I am going to do this.

    I think if I were to implement hysteresis it would have to be upon averages over some period of time. Doing it to raw analog read values isn't giving me good results. I will have to experiment and think about it more.

  10. #10
    Senior Member
    Join Date
    Nov 2015
    Location
    Wales
    Posts
    579
    Can you attach this to an oscilloscope and check the signals are actually noisy?

  11. #11
    Senior Member adrian's Avatar
    Join Date
    Oct 2015
    Location
    Wellington, NZ
    Posts
    504
    @Xenomoamor good suggestion ..

    @Alkamist ... increase the hysterisis !! Averaging is good too ... neither will cure your floating value issue... I suspect that is the nature of softpots. As to hysterisis reducing your resolution ... that is correct, I think, but even for pitch bend (which goes from -8196 to 8195 or something) if you are staying wit the the standard of a couple of semitones (is it 4 each way or two, can't remember), you don't need that smooth / high resolution.... OBviously more is better, andyou don't want audible laddering, but I remember using quite chunky values for the one pitch bend project I did ....

  12. #12
    Senior Member adrian's Avatar
    Join Date
    Oct 2015
    Location
    Wellington, NZ
    Posts
    504
    So the middle pin of the softpot floats when there is no pressure according to this website ... that would explain your floating value for no pressure ... they recommend a weak pullup of 100kohms... makes sense ...

    Interestingly they say to not connect the softpot directly to the power supply, but rather use resistors .... don't know why ... I'm not an electrical engineer (or an engineer of any type at all!!) .. maybe it stabilises things.... may well reduce resolution, but if it gives you a stable read .....

  13. #13
    Senior Member
    Join Date
    Nov 2015
    Location
    Wales
    Posts
    579
    Quote Originally Posted by adrian View Post
    Interestingly they say to not connect the softpot directly to the power supply
    This is probably to limit the maximum current in case it's resistance drops to a low value

    I'm not surprised it floats though, I imagine it has some capacitance just looking at how it's constructed

  14. #14
    Senior Member adrian's Avatar
    Join Date
    Oct 2015
    Location
    Wellington, NZ
    Posts
    504
    Quote Originally Posted by Xenoamor View Post
    This is probably to limit the maximum current in case it's resistance drops to a low value
    Yes I saw a report of unwanted heating ....I'm guessing you are saying its a 'preventative' measure? Anyways, they do look quite cool these softpots....they appear to be actually designed to always have a 'wiper' / 'stylus' putting pressure on them ...(that what all the design notes reccomend) so I guess for the recommended application , the lack of pressure / floating etc is not a consideration...

Posting Permissions

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