Good day,
I am working with a motorized fader and have been trying to use to touchRead function as a way to interrupt the fader when it is in motion. I've been experiencing some odd (maybe) behaviour and although I have a work around I wanted to check if this is normal, if there is a problem with my use of touchRead or if maybe I need to improve my circuit. so here's the simplest form of the code that returns the result I'm talking about:
I am using a teensy 3.6 and I have the CPU speed (of the teensy) set down to 96MHz as some other parts of my code are unstable when it is running at 180MHz. But basically when the fader is not touched the touchRead function returns a value that is pretty stable around 3800 however, when I touch the fader the touchRead function returns a value that bounces between maybe 200-300 and to over 4000. For the moment I am averaging reads and for the most part it works because touchRead is very stable when not touched however, this introduces a slight delay from when I touch the fader to when it detects a touch. As the motorized fader in this project is mostly snapping from one value to another as quickly as possible I would like to get a more stable read from the touchPin so that, for example, the fader motor stops as quickly as possible if it slams into someone's finger.
As for the circuit I have the touch sense pin on the motorized fader going directly into the pin A9 on the teensy. The teensy is mounted inside an enclosure with a PC (motherboard, processor, GPU, power supply, etc) and the motorized fader is mounted to the outside of the chasis which is grounded. So maybe there is some interference going on? Any assistance on this would be greatly appreciated as I have not been able to find much documentation on the touchRead function.
Best regards,
-Andrew
I am working with a motorized fader and have been trying to use to touchRead function as a way to interrupt the fader when it is in motion. I've been experiencing some odd (maybe) behaviour and although I have a work around I wanted to check if this is normal, if there is a problem with my use of touchRead or if maybe I need to improve my circuit. so here's the simplest form of the code that returns the result I'm talking about:
Code:
#define TOUCH_PIN A9
void setup() {
Serial.begin(115200);
pinModer(TOUCH_PIN, INPUT_PULLUP);
}
void loop() {
int touchVAL = touchRead(TOUCH_PIN);
Serial.println(touchVAL);
}
I am using a teensy 3.6 and I have the CPU speed (of the teensy) set down to 96MHz as some other parts of my code are unstable when it is running at 180MHz. But basically when the fader is not touched the touchRead function returns a value that is pretty stable around 3800 however, when I touch the fader the touchRead function returns a value that bounces between maybe 200-300 and to over 4000. For the moment I am averaging reads and for the most part it works because touchRead is very stable when not touched however, this introduces a slight delay from when I touch the fader to when it detects a touch. As the motorized fader in this project is mostly snapping from one value to another as quickly as possible I would like to get a more stable read from the touchPin so that, for example, the fader motor stops as quickly as possible if it slams into someone's finger.
As for the circuit I have the touch sense pin on the motorized fader going directly into the pin A9 on the teensy. The teensy is mounted inside an enclosure with a PC (motherboard, processor, GPU, power supply, etc) and the motorized fader is mounted to the outside of the chasis which is grounded. So maybe there is some interference going on? Any assistance on this would be greatly appreciated as I have not been able to find much documentation on the touchRead function.
Best regards,
-Andrew