Challenge - 5 Problems
ESC Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateOutput of ESC signal processing code
What is the output of this code simulating ESC signal processing for motor speed control?
Drone Programming
def esc_signal(pwm_value): # PWM value from 1000 to 2000 microseconds if pwm_value < 1100: return 0 # motor off elif pwm_value > 1900: return 100 # max speed else: # linear scale between 0 and 100 return (pwm_value - 1100) / 8 print(int(esc_signal(1050))) print(int(esc_signal(1500))) print(int(esc_signal(1950)))
Attempts:
2 left
💡 Hint
Think about how the PWM value maps to motor speed in the code.
✗ Incorrect
The function returns 0 if PWM is below 1100, 100 if above 1900, else linearly scales between 0 and 100. For 1050, output is 0; for 1500, (1500-1100)/8=50; for 1950, output is 100.
🧠 Conceptual
intermediatePrimary role of an ESC in a drone
Which option best describes the primary role of an ESC (Electronic Speed Controller) in a drone?
Attempts:
2 left
💡 Hint
Think about what controls the motor speed in response to commands.
✗ Incorrect
An ESC receives signals from the flight controller and adjusts the power to the motors to control their speed.
🔧 Debug
advancedIdentify the error in ESC signal scaling code
What error will this ESC signal scaling code cause when run?
Drone Programming
def esc_speed(pwm): if pwm < 1100: return 0 elif pwm > 1900: return 100 else: return (pwm - 1100) / 0 print(esc_speed(1500))
Attempts:
2 left
💡 Hint
Look carefully at the division operation in the else block.
✗ Incorrect
Dividing by zero causes a ZeroDivisionError at runtime.
📝 Syntax
advancedSyntax error in ESC control function
Which option contains the correct syntax for this ESC control function?
Drone Programming
def esc_control(pwm): if pwm < 1100 return 0 elif pwm > 1900: return 100 else: return (pwm - 1100) / 8
Attempts:
2 left
💡 Hint
Check where colons are missing after if and else statements.
✗ Incorrect
Python requires a colon after if, elif, and else statements. Only option A has all colons correctly placed.
🚀 Application
expertCalculate motor speed from ESC PWM input
Given an ESC that maps PWM input from 1100 to 1900 microseconds linearly to motor speed 0 to 100%, what is the motor speed for PWM input 1700?
Attempts:
2 left
💡 Hint
Calculate the fraction of the way 1700 is between 1100 and 1900, then multiply by 100.
✗ Incorrect
Range is 1900-1100=800. 1700-1100=600. Fraction is 600/800=0.75. Motor speed is 0.75*100=75% (option A).
