Lab 9

C · Local Linux terminal

Zoom out without changing the generator

Your computer

Embedded Systems · Oscilloscope timebase. You are measuring a 10 Hz signal. A 100 ms screen shows one period. Press KEY0 twice and the label changes to 300 ms, but the trace still shows one period. Is the generator slowing down, or is the scope giving you the wrong scale?

Use Linux, a C compiler and Python 3. This activity starts with the working rising and falling triggers from the preceding exercise. The input file records the 10 Hz setting of the timer-driven generator. Leave that file alone throughout the experiment.

Press a key between sweeps

From the unzipped directory, run the five-sweep sequence below. The key file contains one hexadecimal edge mask for each new sweep. The sequence is no press, KEY0, KEY0, KEY1, KEY1. The acquisition reads each mask once, so a change applies to the whole next frame.

cc -std=c11 -O2 -Wall -Wextra -Werror starter/scope.c -lrt -o scope
export SCOPE_KEYS=resources/key-edges.txt
export SCOPE_REPLAY_SLOW=4
./scope edges resources/generator-10.csv 1 5 4096 zoom > zoom.csv
python3 resources/read_sweep.py zoom.csv

Open zoom-01.svg and zoom-03.svg. Compare their rightmost time labels and the number of cycles visible. The CSV column spacing is a second way to measure the timebase. Multiply step_ns by 320 and divide by one million to get the window duration in milliseconds.

Two replay captures with the horizontal scale set to 300 ms. The upper capture fits one period of the 10 Hz input; the lower capture fits three.

Both traces have the same input frequency and scale label. Which agrees with the generator? What input frequency would you incorrectly infer from the other?

Fix the time between samples

Open starter/scope.c and find sampling_interval_ns. Derive the interval from the requested sweep duration and the number of columns. Keep the 100 ms case working. Recompile, run the five-sweep sequence again and complete the table from your measured CSV values.

Requested Before (ms) Fixed interval (ns) Cycles
100 ms
200 ms
300 ms
200 ms
100 ms

Do two separate checks on frame 3. First recover the 300 ms duration from its timestamps. Then use the measured separation of two rising edges to estimate the generator frequency. Ignore a gap marked −1 when selecting the edges. At 300 ms, a period can span 106 or 107 columns because the scope samples at discrete instants.

Drive the controls yourself

Use SCOPE_KEYS=- to read masks from your terminal. Type one selection and press Enter before each sweep. A mask of 1 represents KEY0, 2 represents KEY1 and 0 leaves the duration unchanged. The scope operates between 100 and 1000 ms. Simultaneous KEY0 and KEY1 presses leave the scale unchanged.

SCOPE_KEYS=- ./scope edges resources/generator-100.csv 0 3 4096 personal > personal.csv
python3 resources/read_sweep.py personal.csv

Try 2, 1, 3. Predict all three durations and check them. With SW0 down, what should the first sample of every sweep be? Submit your timer calculation, the table and your two frame-3 measurements. Explain why changing the scale should leave the independently measured input frequency unchanged.

FPGAcademy exercise · Exercise notice · LabsLand source license