You can't. However, you need to work out how fast you need to detect the change. What is your application? What are you really trying to do? Why do you think it needs to be that fast?
I'm developing a project about solar tracker. In this project, I'm including the switch to avoid the motor going beyond this range. So, there are two switches (in opposite sides) for axis (two axis).
Moreover, the switch is also used to calibrate the potentiometer. For this, these are the steps:
- switch is activated,
- Read the value of the potentiometer
- Compare the reading value of the potentiometer and a set value (stored in EEPROM).
- If this difference is greater than X value, I want to replace this value read to that stored in EEPROM.
- Change the direction of the motor
- Moves the motor until hit the switch (placed in the opposite side).
- Read the value from the potentiometer again (but,
- Change again the direction of the motor
- Move 90º degrees and stop
This aims to read the position from both switches (both sides from the same axis) , by using the potentiometer and calibrate this one.
This routine would be within Interrupt Service Routine, but it is much long and my routine requires some increment of time to run the motor.
And other problem: In the sixth step, the Interrupt is called again and instead of following to seventh step, it will call the Interrupt again and go back to the first step, but it isn't what I want.
Can I solve this? Which is the best way to calibrate potentiometer by using Switch, while I use the switch to limit movement too?