I have been trying to get a soft pot (touch strip potentiometer) working with the teensy for a music controller project. https://www.sparkfun.com/products/8680. Here is my circuit.
It is easy enough to output the absolute position of my finger via Serial or usbMIDI. (Must be sure to use a 10k between the collector pin of the sensor and ground - otherwise you will get random noise when it is not pressed)
I am trying to use the soft pot kind of like a rotary encoder - I want to make increments/decrements to an existing value in software rather than select some fixed position. Volume control for example. Rather than having the sensor select between levels 0-127, I want it to simply increase or decrease by a certain amount from the current value. It will not matter where the finger is initially placed on the soft pot - it is the distance from this initial placement that is the relevant data. So if I place my finger in the middle of the soft pot, then slide up 25% the length of the soft pot, the volume will increase by 25%.
In designing the software side of this, it necessary to be able detect when the sensor is pressed, and when it is released.
QUESTION
Here is the issue. When I press down on the soft pot , the analog input is actually ramping up to the value rather than jumping to it immediately - the same is true for release and ramping down to zero. Hypothetically, this delay/ramp should be able to be managed in software with relevant delays. But the delays are too long, and confusing me because they are much longer than expected. A guy on the phone from SpectraSymbol (soft pot manufacturer) brought up that the teensy data sheet indicates a 10pf internal capacitor for the adc, so with a 10kish resistor(the soft pot) the delay should be less than a microsecond. I am seeing delays from 10-50 MILLISECONDS! This is approaching being slower than my movement which won't work. Here is my teensy code and the output I'm seeing when I press, hold, and release.
int a=0;
int alag=10;
void setup(){
pinMode(A0,INPUT);
Serial.begin(9600);
}
void loop(){
a = analogRead(A0);
if(abs(a-alag)>7){
Serial.print(millis());
Serial.print('\t');
Serial.println(a/8);
alag=a;
}
}
__________________________
6567 0 *
6567 1
6579 0
6580 1 noise fluctuations between 0 and 1 ... I am not pressing it
6580 0
6605 1
6605 0 *
12958 21 * I press the soft pot and it takes until 13,047ms to get to the value I am actually at, 97
12958 82
12958 83
12958 84
12958 85
12958 87
12959 88
12959 89
12959 90
12959 91
12964 90
12971 91
12975 92
12983 93
12990 94
13006 95
13024 96
13047 97 HERE *
16248 96
17898 97
18757 96 * I hold the value for a few seconds and then begin release here
18763 95
18766 94
18769 93
18770 92
18773 91
18773 90
18775 89
18776 87
18777 86
18777 85
18777 84
18778 83
18778 82
18778 81
18778 78
18778 76
18778 70
18778 62
18778 47
18778 35
18778 0 and it finally gets to zero here. it is taking 18ms to release to zero. *
18779 1
18780 0
18782 1
18782 0
18783 1
18783 0
18786 1
18786 0
18786 1
18786 0
18787 1
Why is there a delay thousands of times longer than expected? Is this sort of delay actually just inherent to using an analog sensor with a micro controller, or is there something I can do to make things more immediate? And if anyone has any code ideas for my relative positions sensing I am happily all ears!
It is easy enough to output the absolute position of my finger via Serial or usbMIDI. (Must be sure to use a 10k between the collector pin of the sensor and ground - otherwise you will get random noise when it is not pressed)
I am trying to use the soft pot kind of like a rotary encoder - I want to make increments/decrements to an existing value in software rather than select some fixed position. Volume control for example. Rather than having the sensor select between levels 0-127, I want it to simply increase or decrease by a certain amount from the current value. It will not matter where the finger is initially placed on the soft pot - it is the distance from this initial placement that is the relevant data. So if I place my finger in the middle of the soft pot, then slide up 25% the length of the soft pot, the volume will increase by 25%.
In designing the software side of this, it necessary to be able detect when the sensor is pressed, and when it is released.
QUESTION
Here is the issue. When I press down on the soft pot , the analog input is actually ramping up to the value rather than jumping to it immediately - the same is true for release and ramping down to zero. Hypothetically, this delay/ramp should be able to be managed in software with relevant delays. But the delays are too long, and confusing me because they are much longer than expected. A guy on the phone from SpectraSymbol (soft pot manufacturer) brought up that the teensy data sheet indicates a 10pf internal capacitor for the adc, so with a 10kish resistor(the soft pot) the delay should be less than a microsecond. I am seeing delays from 10-50 MILLISECONDS! This is approaching being slower than my movement which won't work. Here is my teensy code and the output I'm seeing when I press, hold, and release.
int a=0;
int alag=10;
void setup(){
pinMode(A0,INPUT);
Serial.begin(9600);
}
void loop(){
a = analogRead(A0);
if(abs(a-alag)>7){
Serial.print(millis());
Serial.print('\t');
Serial.println(a/8);
alag=a;
}
}
__________________________
6567 0 *
6567 1
6579 0
6580 1 noise fluctuations between 0 and 1 ... I am not pressing it
6580 0
6605 1
6605 0 *
12958 21 * I press the soft pot and it takes until 13,047ms to get to the value I am actually at, 97
12958 82
12958 83
12958 84
12958 85
12958 87
12959 88
12959 89
12959 90
12959 91
12964 90
12971 91
12975 92
12983 93
12990 94
13006 95
13024 96
13047 97 HERE *
16248 96
17898 97
18757 96 * I hold the value for a few seconds and then begin release here
18763 95
18766 94
18769 93
18770 92
18773 91
18773 90
18775 89
18776 87
18777 86
18777 85
18777 84
18778 83
18778 82
18778 81
18778 78
18778 76
18778 70
18778 62
18778 47
18778 35
18778 0 and it finally gets to zero here. it is taking 18ms to release to zero. *
18779 1
18780 0
18782 1
18782 0
18783 1
18783 0
18786 1
18786 0
18786 1
18786 0
18787 1
Why is there a delay thousands of times longer than expected? Is this sort of delay actually just inherent to using an analog sensor with a micro controller, or is there something I can do to make things more immediate? And if anyone has any code ideas for my relative positions sensing I am happily all ears!