Cruise

Motor Speed Hold Exercise

Task

A car's cruise control holds the speed the driver set, up hills and down them, whatever the car is carrying.

Hold the motor's shaft at 9,000 RPM for 300 ms, whatever load the rig puts on it, then print: DONE The motor's registers are in the Circuit figure.

Circuit

Circuit: the rig puts a load on the motor's shaft that changes during the run, U1 STM32F4 writes DUTY and CTRL to the motor M1 at 0x50061000 and reads SPEED back, and prints on USART1 TX, PA9, to a terminal; the motor's registers DUTY, CTRL and SPEED are listed with offset, access and units

Pass condition

From 50 ms to the end of the run, the shaft stays within 300 RPM of 9,000 RPM. DONE comes once the 300 ms are up, and the motor never latches a fault.

Expected shape of one run: the shaft's speed climbs from 0 and, from 50 ms to the end of the 300 ms hold, stays inside the band from 8,700 to 9,300 RPM, wherever the load puts it within the band; DONE prints after 300 ms and the motor trace latches no fault

Notes

The rig's load changes between runs and during a run, and can slow the shaft by up to 2,500 RPM. Duty is how hard the motor is driven, in thousandths of full power. The drive's tuning is a duty of 300, plus 1 for every 2 RPM the shaft runs below 9,000 RPM, or minus 1 for every 2 RPM above it, kept from 0 to 500. Set the duty at least once a millisecond.

Related challenges

Loading the interactive arena.