11 years ago.

Rate of change of slide pot feedback

Hi, I am making a variable intake system for a combustion engine. I want to change the length of the engine's runner in order to influence the amount of air going in the cylinder at each cycle. The mechanism is pretty simple from mechanical point of view. I have a 10k slide potentiometer - http://proto-pic.co.uk/slide-pot-motorized-10k-linear-taper/ ; So I want to connect it's slider to a telescopic tube (the runner) and change the length accordingly. If read the value from the potentiometer I can figure out what is the exact position and via PWM I can tell the motor how fast to work. To change the direction I have this H-bridge http://proto-pic.co.uk/motor-driver-1a-dual-tb6612fng/ , in theory if I have two PWM signals - one for forward, and one for backwards I can switch direction. What I don't know is how to monitor (map) the rate of change of the AnalogIn (the feedback from the potentiometer) continuously in order to know if it's increasing or decreasing in order to choose which PWM to activate.

If something is not clear I can explain in details. Please share if you have an idea. Thank you.

1 Answer

11 years ago.

You could use a Ticker and attach it to a function that is called at regular intervals to sample the analog input, average the results and keep track of the rate of change and wether it is increasing or decreasing. Store these values in global variables that are used by your PWM controlloop. Set the Ticker rate (= sampling rate) depending on how fast you expect changes in analog in.

See here for Ticker examples.