We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(Refer to the Adafruit article) Starting here: Flying_Fader_Arduino, in the go_to_position function starting at line 100:
go_to_position
void go_to_position(int new_position) { fader_pos = int(analogRead(fader) / 4); while (abs(fader_pos - new_position) > 4) { if (fader_pos > new_position) { speed = 2.25 * abs(fader_pos - new_position) / 256 + 0.2; speed = constrain(speed, -1.0, 1.0); if (speed > 0.0) { analogWrite(pwmA, 255); analogWrite(pwmB, 0); } } if (fader_pos < new_position) { speed = 2.25 * abs(fader_pos - new_position) / 256 - 0.2; speed = constrain(speed, -1.0, 1.0); if (speed > 0.0) { analogWrite(pwmA, 0); analogWrite(pwmB, 255); } } fader_pos = int(analogRead(fader) / 4); } analogWrite(pwmA, 0); analogWrite(pwmB, 0); }
Looks to me like the duty cycle is always 100% when the fader is moving. The speed calculation is not really useful.
Compare to the Circuit Python version (starting at line 60):
def go_to_position(new_position): global fader_pos # pylint: disable=global-statement fader_pos = int(fader.value//256) while abs(fader_pos - new_position) > 2 : if fader_pos > new_position : speed = 2.25 * abs(fader_pos - new_position) / 256 + 0.12 speed = clamp(speed, -1.0, 1.0) motor1.throttle = speed led[0] = (fader_pos, 0, 0) if MIDI_DEMO: global fader_cc # pylint: disable=global-statement fader_cc = int(fader_pos / 2) # cc is 0-127 midi.send(ControlChange(fader_cc_number, fader_cc)) if fader_pos < new_position: speed = -2.25 * abs(fader_pos - new_position) / 256 - 0.12 speed = clamp(speed, -1.0, 1.0) motor1.throttle = speed led[0] = (fader_pos, 0, 0) if MIDI_DEMO: fader_cc = int(fader_pos / 2) # cc is 0-127 midi.send(ControlChange(fader_cc_number, fader_cc)) fader_pos = int(fader.value//256) motor1.throttle = None
Here we see the PWM duty cycle, which is the throttle member of the motor1 instance, being set to the (clamped) calculated speed.
throttle
motor1
speed
Why the difference? A typo? Untested code? Just wondering.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
(Refer to the Adafruit article)
Starting here: Flying_Fader_Arduino, in the
go_to_position
function starting at line 100:Looks to me like the duty cycle is always 100% when the fader is moving. The speed calculation is not really useful.
Compare to the Circuit Python version (starting at line 60):
Here we see the PWM duty cycle, which is the
throttle
member of themotor1
instance, being set to the (clamped) calculatedspeed
.Why the difference? A typo? Untested code? Just wondering.
The text was updated successfully, but these errors were encountered: