Big Red Button

CAN Emergency Stop Exercise

Task

Log the sensor's frames and obey the emergency stop for as long as the board runs: if a frame has standard ID 0x300 to 0x303: print_frame() it if a frame has standard ID 0x010: motor_stop() within 3 ms if neither: do nothing The registers and bit fields are on the Datasheet tab.

Circuit

Block diagram: U1, an STM32F4, reads CAN RX on PA11 and drives CAN TX on PA12 through U2, a CAN transceiver, onto the CANH and CANL bus with a 120 ohm terminator R1 and R2 at each end; on the bus U4, the emergency stop, sends ID 0x010, U3, the sensor, sends IDs 0x300 to 0x303, and other nodes send their own frames; PA5 drives the enable input of M1, the motor driver, and PA9 carries USART1 TX to J1, a serial console

Pass condition

Every sensor frame prints one line, in arrival order. PA5 falls within 3 ms of the stop frame, as figure 2 shows. With no stop frame, PA5 stays high.

Expected output for the stop in a burst case: sensor frames at 10.0, 20.1, 20.4, 20.7, 21.3 and 30.0 ms and the stop frame 0x010 at 21.0 ms; the serial console logs all six sensor frames in arrival order, and PA5, high since power-up, falls between 21 and 24 ms, within 3 ms of the stop

Notes

While your program runs, the bench sends the stop frame, other nodes' frames and sensor frames, some in bursts. Leave the given code as is: print_frame() prints one line, and returns once it has gone out at 115200 baud: about 2.3 ms can_start() puts CAN1 on the bus at 500 kbit/s motor_run() PA5 high, the motor runs; main calls it first motor_stop() PA5 low, the motor stops

Related challenges

Loading the interactive arena.