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 2: the scope catches one edge
The debug channel, part two: the drive has a software scope inside, and the PC configures it, arms it and pulls the data back over 32a's MAVLink serial line. The running example is the same two-turn move: the scope is armed 100 ms before the target, records four channels (62 pos_tar_p, 63 pos_now_p, 134 speed_now_rad_s, 67 iq_tar_A) and triggers when the speed rises through 300 rpm (31.4159 rad/s), 1000 points with 20 % before the trigger. First a guess: how long do 100 ms of data take to reach the PC? 272.7 ms on the wire, almost three times as long. The framework page: what the PC sends on the left (configure, arm, poll, pull), the seven stops in the middle, the capture on the right (201 rows before the trigger, 798 after) with the download cost and the real runs. Seven stops: choose the channels (ScopeConfig 30014 goes into kScopeObject and the reply is only an echo; the threshold field is an int32, so a float channel gets the float's bits, 0x41FB53D1; control word 1 configures: scope_channel_config looks each channel up in the parameter database, 16 bytes a sample, at most 2000 samples in the 32,000-byte buffer, a ring of 8000 bytes per channel; reading ScopeControl back gives status 0); arm (control word 2 only opens sample_isr_flag); every tick (the TIM5 position loop at 10 kHz: PosSpeedLoopCtrl ends with AppParamSyncUser, then ScopeIsrHandle, so it records this tick's results; scope_data_sample_run reads each channel through its pointer and, before the trigger, writes with ringbuffer_put_overlayable, which overwrites the oldest; the 64-bit position keeps its low 32 bits); four samples decide (scope_trigger_catch: for a rising edge the oldest at or below the threshold, the newest at or above, the oldest below the newest; 300 rpm is due at tick 500, it fires at tick 502, with ticks 497-501 at 31.21-31.38 and two dips inside the window); where the window starts (change_count_rule: offset = 1000 × 20 / 100 + 2 = 202, the 2 being half the window; the read pointer goes 202 samples back, so row 0 is tick 301, not 302, and the trigger is row 201; from then on ringbuffer_put, which never overwrites); full, then packed (the count reaches 1000 at tick 1300; on the next tick the status becomes 2, the switch closes, and each channel gets 34 packets, the last holding 10; the scope never pushes); pulled, packet by packet (the bench polls every 10 ms and sees status 2 at tick 1400; per packet it writes ScopeControl with control word 0xFF and frame_info = channel << 16 | packet, then READ_PARAM ScopeData 30016, and ScopeChannelDataRead copies 120 bytes past the read pointer: 136 packets, 272 frames each way, 25,134 bytes, 272.7 ms). The check: the bench logs the same four variables straight from kAxis every tick, and all 1000 downloaded rows in all four channels match bit for bit. Skipped: the live waveform (WaveformMap), falling edges, and the ways a capture lies (32c). Your turn: at 50 % delay row 0 is tick 1 and the trigger is row 501; control word 3, sample now, captures ticks -1000 to -1, before the motor moves.