Electrical Energy Calculator
Calculate electricity use from power and duration, or constant DC voltage and current. Compare energy use over different operating times in watt-hours, kilowatt-hours and joules.
Open toolInteractive calculation is unavailable until JavaScript loads. The formulas, worked examples and references below remain available.
Map a servo command, such as an angle, to a pulse width between calibrated endpoints, and back, with the timer compare value for the PWM period.
Choose Pulse for a command, or Command for a pulse.
Enter the two pulse endpoints in microseconds and the command values they correspond to. Measured endpoints from your own servo give the most accurate mapping.
Enter the command, or the pulse width, or drag the slider between the endpoints.
Enter the PWM frequency and choose the timer resolution to see the period, the timer compare value and the pulse the timer actually produces.
The graph shows the mapping line between your endpoints and marks your value. Copy result copies the pulse and compare value. Reset restores the starting example: 0 to 180 between 1000 and 2000 μs, command 90, 50 Hz and 16 bits.
A hobby servo reads the length of a repeating high pulse, not its duty cycle as such. About 1500 μs is centre; shorter and longer pulses move the horn towards each end.
Between the endpoints the position is close to proportional to the pulse width, so the command is mapped with a straight line through the two calibrated endpoints. A command outside the endpoints is refused rather than clamped.
Nominal endpoints such as 1000 and 2000 μs are a convention, not a guarantee. Many servos travel further with 500 to 2500 μs, and the Arduino Servo library defaults to 544 and 2400 μs. Driving past the mechanical stops makes a servo stall and draw high current.
The pulse repeats every period. 50 Hz (a 20 ms period) is the classic rate; many digital servos accept faster rates. The pulse must always be shorter than the period.
A hardware timer can only produce whole counts. With 2^b counts per period, each count is the period divided by 2^b, so low resolutions at low frequencies give coarse pulse steps. When the count cannot hit the pulse exactly, the tool says so and shows the error.
Assumptions and limitations: servo position is linear in pulse width between the endpoints, and the timer has 2^b counts per PWM period. Dead band, non-linearity and load are not modelled. For timers whose period is a different number of counts (for example ARR + 1 on STM32), replace 2^b with that count. General PWM duty-cycle, frequency and period calculations belong to the PWM duty-cycle calculator.
Pulse for a command: P = Pmin + (c − cmin) × (Pmax − Pmin) ÷ (cmax − cmin)
Command for a pulse: c = cmin + (P − Pmin) × (cmax − cmin) ÷ (Pmax − Pmin)
Period: T = 1,000,000 ÷ f, in μs
Compare value: n = round(P ÷ T × 2^b) for a timer with 2^b counts per period
Produced pulse: Pq = n × T ÷ 2^b
Endpoints 1000–2000 μs for 0–180°, command 90°, 50 Hz, 16 bits: 1500 μs; 7.5 % of the period; compare value 4915; produced pulse 1499.94 μs. 90° is halfway, so the pulse is halfway between the endpoints. 1500 ÷ 20000 × 65536 = 4915.2, rounded to 4915, so there is no exact setting: the timer gives 0.06 μs less.
Arduino defaults 544–2400 μs for 0–180°, command 90°: 1472 μs. Halfway between 544 and 2400 is 1472, not 1500. Using the 1500 μs convention with these endpoints puts the horn slightly off centre.
Endpoints 1000–2000 μs for 0–180°, pulse 1200 μs: Command 36°. 1200 μs is one fifth of the way from 1000 to 2000, and one fifth of 180° is 36°.
Arduino Servo library source (Servo.h)
Available now
Calculate electricity use from power and duration, or constant DC voltage and current. Compare energy use over different operating times in watt-hours, kilowatt-hours and joules.
Open tool →Available now
Add up to 20 resistors in series using Ω, kΩ or MΩ for circuit analysis and electricity calculations, with a diagram and running total.
Open tool →Available now
Convert absolute temperatures between Celsius, Fahrenheit and kelvin.
Open tool →Nice audio board working as expected.
Given the fact that this was my first purchase and I made it thinking I was buying genuine Yihua products, this has been a setback. I received a lesser known OEM brand called MYTO and while both the products seem to be similar from appearance, my real contention is the quality and quantity of the brass wool. On top of that not informing the customer about the unavailability of the Yihua product and instead sending a product from a different brand is also antagonising. Henceforth, I might just have to think twice before ordering from ThinkRobotics.
TOF MINIF Range Sensor - UART TOF Time-of-Flight Laser Range Sensor
We are disappointed with our recent order experience. We clearly communicated our requirement for 433 MHz antennas on WhatsApp, but the issue remains unresolved. We have been following up for more than 10 days and are still waiting for a proper refund resolution.
As a regular B2B customer, we expected better support. This experience has affected our trust in ThinkRobotics, and we may have to consider other suppliers for future purchases. We request a fair and prompt refund.
Anodised Aluminium Cup Head Washers (Pack of 10)