Quote:
Originally Posted by ujamerstand /img/forum/go_quote.gif
If I understand you correctly, all the dedicated controller does is to determine the actual direction of the RE from wiper readings
|
RE and wiper? are you mixing the rotary encoder and pot?
Quote:
this is then sent to either the CW or CCW pin on the lcduino? Is the readings from RE that bad to need a dedicated controller specifically for this purpose? |
CW and CCW are signals *from* the controller to the motor (from the arduino to the l293d h-bridge chip and the chip then turns the motor one way or the other).
so the feedback loop is: the cpu reads the analog voltage from the pot, across wiper and gnd. it gets a 0-1023 value and comes up with a percent of fullscale; it then uses that to scale the native volume level and sends that value to the volume engine part (relay, pga, whatever).
the way the code works right now is that the analog value from the pot is sensed at every poll loop and if the value changes from the last stable value, we detect a 'user knob operation' and we take that value and scale the 0..255 (say) value for volume and immediately update the volume engine. that volume change takes effect right away; and if you turn the knob, the engine tracks that.
the motor stuff is done via sticky bits
at the top of the big polling loop, the controller checks the wiper position and compares it against where it should be, given the current 'volume' byte value. if the compared value is not right, it figures if it should turn the motor one way or the other. it starts that operation and it STICKS, all the while, the code is free to continue its big polling loop and service other tasks. the big polling loop comes up to the top again and checks that pot/volume relationship again. if they are close it sends a 'stop' message to the motor (another sticky/latched message) and the polling loop continues on down. if the motor needs to be reversed, a 'stop, change direction' is sent and the pollling loop, again, continues. this achieves the effect of a background motor 'catch-up' with immediate foreground volume change events. the user interface never feels laggy or slow; even if the motor is still playing catch-up