This part is for members
Membership opens soon. Leave your email and we'll tell you the day it does. Founding members get the launch price.
Keep watching the free partsThe debug channel 1: one message, one reply
The debug channel, part one: a PC tool talks to the drive over MAVLink on a serial line, and we follow one message, the one that turns the motor two turns (AppMotionParam, Target_position = 262,144). It opens with the whole episode on one framework page: every frame from the PC goes down one of two branches, a read or a write; a write checks, field by field, whether the PC is in control, and then the drive replies. The page: the frame on the wire on the left (0xFD, length, sequence, sender, ID 30059, one whole 95-byte struct, checksum: 107 bytes, 1.16 ms at 921,600 baud), the seven stops through the drive in the middle, what a reply means and the real runs on the right. The bench, sil-mac/ep32's mav32, plays the PC tool: real MAVLink 2 frames packed with servohub's generated headers, handed to the unchanged MavlinkRecvCallback. Seven stops: the bytes arrive (USART2's DMA fills the 512-byte mavlink_rx_buff; when the line goes quiet, the idle interrupt HOST_UART_IRQ_TASK hands over the count; priority 8, below the current loop's ADC at 2 and the position loop's TIM5 at 3, so the loops can interrupt a message halfway); one frame per burst (mavlink_parse_char, and the loop breaks at the first complete frame: mode and enable sent in one burst give one reply, the mode becomes 3, the enable is lost and the control word stays 0; fix/mavlink-every-frame-in-buffer gives two replies and control word 1); read before you write (READ_PARAM carries a struct_id, and the read case fills the whole struct with 23 get_app_ calls; one message is one whole struct, so the tool reads first: 10 rpm, 10 rpm/s, target 0, then changes three fields and writes it back); who is in control (one generated line per field: set it only when the authority is COMM_CONTROL_HOST, then put get_app_ in the reply; at power-up it is COMM_CONTROL_BUS; without taking control the whole script is refused and every reply says so, the motor stays at 0; AppPermissionConfig sets the authority with no guard, so anyone on the line can take control, and it isn't saved to flash; from then on the bus is refused, 0x08000022 as 30a measured); the target lands (with the host in control PP mode needs no bit-4 edge: 262,144 at tick 3,488, 348.8 ms after the write); two kinds of reply (app messages reply with the drive's value; control-layer messages like PmsmConfig reply with the decoded message itself: with the bus in control, pn = 10 is answered 10 while kAxis keeps 5; the 31 fields the parameter database marks HighLevelParam, gains, filters and the authority itself, are written whoever is in control, so you can tune a running joint); the reply goes out (MotorCtlParamSetUpdata recomputes the derived settings after every write, then the reply is packed and sent with HAL_UART_Transmit_DMA; the whole script is 9 frames and 309 bytes out, 9 replies and 493 bytes back; fix/mavlink-reply-actual-value builds the reply after the update from the read case, and pn = 10 is answered 5). Skipped: the scope and the live waveform (32b), MAVLink over CAN, file transfer and firmware upgrade (episode 34), the host tool's older message IDs. Your turn: with the bus in control, double kp_s and the speed limit: kp_s sticks, the limit is refused but the reply says 1,256.6; with the host in control the limit is still 628.3, recomputed from speed_max_rpm.