Backspin

DC Motor Safe Reversal Exercise

Task

A conveyor in a parcel depot moves parcels forward all day. When one jams, the operator presses REVERSE to back the belt up and free it.

Run the motor forward at the duty the depot sets. Once its speed holds steady, print it. On REVERSE, run the motor backward at the same duty and print its speed again: SPEED 12000 RPM SPEED -12000 RPM The motor's registers are in the Circuit figure.

Circuit

Circuit: the depot's controller sets the duty and the operator's REVERSE button drives PA0 of U1 STM32F4; U1 writes DUTY, DIR and CTRL to the conveyor motor M1 at 0x50061000 and reads SPEED back, the belt's load presses on M1, and U1 prints on USART1 TX, PA9, to a terminal; M1's registers DUTY, DIR, CTRL, SPEED, CURRENT and FAULT are listed with offset, access and units

Pass condition

Each SPEED line, forward then backward, shows the speed the shaft holds, within 800 ms of reset. The motor never latches a fault.

Expected output at duty 400 with no load: the shaft speeds up forward and holds 12,000 RPM, and the first line prints; REVERSE is pressed at 200 ms; the shaft slows, then runs backward and holds -12,000 RPM, and the second line prints; the motor trace latches no fault

Notes

The depot sets the duty as your code starts, from 300 to 550. Duty is how hard the motor is driven, in thousandths of full power. The operator presses REVERSE on PA0 once, after the belt has reached its forward speed. The load on the belt changes from run to run. A fault is the motor tripping its protection. FAULT in the Circuit figure records it.

Related challenges

Loading the interactive arena.