You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: book/manuals/week2/2.2_Timed_acquisitions.ipynb
+7-157Lines changed: 7 additions & 157 deletions
Original file line number
Diff line number
Diff line change
@@ -171,92 +171,17 @@
171
171
{
172
172
"cell_type": "markdown",
173
173
"metadata": {},
174
-
"source": [
175
-
"(Task_I2_2_2)=\n",
176
-
"#### Task I2: Investigating timing accuracy\n",
177
-
"\n",
178
-
"Modify your program to analyze timing precision:\n",
179
-
"\n",
180
-
"1. Calculate the time difference between consecutive measurements.\n",
181
-
"2. Find the minimum, maximum, and average time intervals.\n",
182
-
"3. Plot the time intervals over the course of your 100 measurements. Is there any pattern (e.g., intervals getting longer or shorter)?\n",
183
-
"\n",
184
-
"In your notepad, describe:\n",
185
-
"- How consistent the time intervals are\n",
186
-
"- What fraction of intervals differ from the expected 50 ms\n",
187
-
"- Possible explanations for any irregularities\n",
188
-
"- How this timing jitter affects your ability to measure signals"
189
-
]
174
+
"source": "(Task_I2_2_2)=\n#### Task I2: Measuring a slowly changing signal\n\nSlowly turn the potentiometer while your acquisition program is running (Task I1 measurement).\n\n1. Plot voltage vs. time from your measurement.\n2. Describe the pattern you observe as the potentiometer position changed.\n3. Estimate the rate of voltage change (V/s) during your measurement.\n4. Was your sampling rate sufficient to capture this slow change smoothly? Why or why not?\n\nRecord your plot and observations in your notepad."
190
175
},
191
176
{
192
177
"cell_type": "markdown",
193
178
"metadata": {},
194
-
"source": [
195
-
"(Task_I3_2_2)=\n",
196
-
"#### Task I3: Measuring a slowly changing signal\n",
197
-
"\n",
198
-
"Slowly turn the potentiometer while your acquisition program is running (Task I1 measurement).\n",
199
-
"\n",
200
-
"1. Plot voltage vs. time from your measurement.\n",
201
-
"2. Describe the pattern you observe as the potentiometer position changed.\n",
202
-
"3. Estimate the rate of voltage change (V/s) during your measurement.\n",
203
-
"4. Was your sampling rate sufficient to capture this slow change smoothly? Why or why not?\n",
204
-
"\n",
205
-
"Record your plot and observations in your notepad."
206
-
]
179
+
"source": "(Task_I3_2_2)=\n#### Task I3: Frequency response sweep\n\nConnect the function generator to **Ain1** on the ALPACA (via the voltmeter first to verify safe levels). From the introductory manual, program the ALPACA to generate a sine wave with 1.5 V offset and 1.5 V peak-to-peak amplitude.\n\nFirst, measure the response at a single frequency (50 Hz) as a reference:\n\n1. Set the function generator to 50 Hz.\n2. Wait 0.5 seconds for settling.\n3. Collect 200 samples with 10 ms spacing (2 seconds of data).\n4. Record the peak voltage and plot the time-domain signal.\n\nThen, extend your program to sweep across multiple frequencies:\n\n| Frequency [Hz] |\n|:-----|\n| 10 |\n| 50 |\n| 100 |\n| 200 |\n| 300 |\n\nFor each frequency:\n1. Set the generator to that frequency.\n2. Wait 0.5 seconds for settling.\n3. Collect 200 samples with 10 ms spacing.\n4. Record the measured peak voltage.\n\n**Record in your notepad:**\n- The measured peak voltage at each frequency (expected: ~2.25 V at all frequencies)\n- Complete plot of measured peak voltage vs. frequency\n- Whether peak voltage stays constant across the frequency range\n- Any frequencies with significant deviations from expected\n"
207
180
},
208
181
{
209
182
"cell_type": "markdown",
210
183
"metadata": {},
211
-
"source": [
212
-
"(Task_I4_2_2)=\n",
213
-
"#### Task I4: Multi-frequency measurement\n",
214
-
"\n",
215
-
"Connect the function generator to **Ain1** on the ALPACA (via the voltmeter first to verify safe levels). Set the function generator to output a sine wave.\n",
216
-
"\n",
217
-
"From the introductory manual, program the ALPACA to generate a sine wave at a test frequency of 50 Hz with 1.5 V offset and 1.5 V peak-to-peak amplitude.\n",
218
-
"\n",
219
-
"For this frequency, write a program that:\n",
220
-
"1. Generates the sine wave for 0.5 seconds to allow settling.\n",
221
-
"2. Collects 200 samples of the output signal with 10 ms spacing between samples.\n",
222
-
"3. Stores both voltage and time.\n",
223
-
"4. Calculates and records the peak (maximum) voltage in the measurement.\n",
224
-
"\n",
225
-
"Record in your notepad:\n",
226
-
"- The measured peak voltage at 50 Hz\n",
227
-
"- The expected voltage (1.5 V offset + 0.75 V amplitude = 2.25 V peak)\n",
228
-
"- Any difference between expected and measured\n",
229
-
"- A plot of the time-domain signal"
230
-
]
231
-
},
232
-
{
233
-
"cell_type": "markdown",
234
-
"metadata": {},
235
-
"source": [
236
-
"(Task_I5_2_2)=\n",
237
-
"#### Task I5: Frequency response sweep\n",
238
-
"\n",
239
-
"Extend your program from Task I4 to sweep across multiple frequencies. Measure at:\n",
240
-
"\n",
241
-
"| Frequency [Hz] | Expected Peak Voltage [V] |\n",
"1. Set the generator to output the sine at that frequency.\n",
251
-
"2. Wait 0.5 seconds for settling.\n",
252
-
"3. Collect 200 samples with 10 ms spacing (or adjust spacing if needed at higher frequencies).\n",
253
-
"4. Record the measured peak voltage and store it.\n",
254
-
"\n",
255
-
"Plot measured peak voltage vs. frequency. Record in your notepad:\n",
256
-
"- The complete plot\n",
257
-
"- Whether peak voltage stays constant across frequency (as expected for a sine with fixed amplitude)\n",
258
-
"- Any frequencies where the measurement differs significantly from expected"
259
-
]
184
+
"source": "```{admonition} Deep dive (optional)\n:class: deep-dive dropdown\n## Task I4: Investigating timing accuracy\nThis is optional enrichment content and is not mandatory for completing the base tasks.\n\nModify your program from Task I1 to analyze timing precision:\n\n- Calculate the time difference between consecutive measurements.\n- Find the minimum, maximum, and average time intervals.\n- Plot the time intervals over the course of your 100 measurements.\n\nDescribe in your notepad:\n- How consistent the time intervals are\n- What fraction of intervals differ from the expected 50 ms\n- Possible explanations for any irregularities\n- How this timing jitter affects your ability to measure signals\n```"
260
185
},
261
186
{
262
187
"cell_type": "markdown",
@@ -268,92 +193,17 @@
268
193
{
269
194
"cell_type": "markdown",
270
195
"metadata": {},
271
-
"source": [
272
-
"Use your notes, simulations, and measurements from the earlier parts of this manual. Draw the tables below in your notepad, fill them in using your earlier work, and use them to support your conclusions. These completed tables should be included in your onepager report for this lab.\n",
273
-
"\n",
274
-
"(Task_C1_2_2)=\n",
275
-
"#### Task C1: Timing accuracy analysis\n",
276
-
"\n",
277
-
"```{admonition} Consider Tasks [A1](Task_A1_2_2), [I1](Task_I1_2_2), and [I2](Task_I2_2_2).\n",
278
-
":class: note no-content\n",
279
-
"```\n",
280
-
"\n",
281
-
"Fill the following table in your notepad:\n",
282
-
"\n",
283
-
"| Parameter | Predicted | Measured | Unit |\n",
284
-
"|:----------|:----------|:---------|:----:|\n",
285
-
"| Total measurement duration | 5 | | s |\n",
286
-
"| Sampling interval (target) | 50 | | ms |\n",
287
-
"| Minimum measured interval | | | ms |\n",
288
-
"| Maximum measured interval | | | ms |\n",
289
-
"| Average measured interval | | | ms |\n",
290
-
"| Jitter (max - min interval) | | | ms |\n",
291
-
"\n",
292
-
"**Questions**:\n",
293
-
"1. How close was your measured average interval to the predicted 50 ms?\n",
294
-
"2. What is the maximum timing error as a percentage of your 50 ms target interval?\n",
295
-
"3. Which factors in the ALPACA software or hardware could explain timing jitter?\n",
296
-
"4. For what types of signals would this timing jitter be a problem?"
297
-
]
196
+
"source": "(Task_C1_2_2)=\n#### Task C1: Timing accuracy analysis\n\n```{admonition} Consider Tasks [A1](Task_A1_2_2) and [I1](Task_I1_2_2).\n:class: note no-content\n```\n\nFill the following table in your notepad:\n\n| Parameter | Predicted | Measured | Unit |\n|:----------|:----------|:---------|:----:|\n| Total measurement duration | 5 | | s |\n| Sampling interval (target) | 50 | | ms |\n| Minimum measured interval | | | ms |\n| Maximum measured interval | | | ms |\n| Average measured interval | | | ms |\n| Jitter (max - min interval) | | | ms |\n\n**Questions**:\n1. How close was your measured average interval to the predicted 50 ms?\n2. What is the maximum timing error as a percentage of your 50 ms target interval?\n3. Which factors in the ALPACA software or hardware could explain timing jitter?\n4. For what types of signals would this timing jitter be a problem?"
298
197
},
299
198
{
300
199
"cell_type": "markdown",
301
200
"metadata": {},
302
-
"source": [
303
-
"(Task_C2_2_2)=\n",
304
-
"#### Task C2: Sampling rate limitations\n",
305
-
"\n",
306
-
"```{admonition} Consider Tasks [A2](Task_A2_2_2), [I3](Task_I3_2_2), and [I4](Task_I4_2_2).\n",
307
-
":class: note no-content\n",
308
-
"```\n",
309
-
"\n",
310
-
"Fill the following table in your notepad:\n",
311
-
"\n",
312
-
"| Signal Type | Test Frequency [Hz] | Minimum Required Sampling Rate [Hz] | Achieved Sampling Rate [Hz] | Sufficient? |\n",
"1. At which frequency do you start to lose the fine details of the sine wave?\n",
321
-
"2. How does the loop execution time (Task I2) relate to your maximum sampling rate?\n",
322
-
"3. What is the highest signal frequency you can measure with confidence using the ALPACA?\n",
323
-
"4. How would you modify your program if you wanted to measure frequencies above 500 Hz?"
324
-
]
201
+
"source": "(Task_C2_2_2)=\n#### Task C2: Sampling rate limitations\n\n```{admonition} Consider Tasks [A2](Task_A2_2_2), [I2](Task_I2_2_2), and [I3](Task_I3_2_2).\n:class: note no-content\n```\n\nFill the following table in your notepad:\n\n| Signal Type | Test Frequency [Hz] | Minimum Required Sampling Rate [Hz] | Achieved Sampling Rate [Hz] | Sufficient? |\n|:------------|:------------------:|:-----------------------------------:|:---------------------------:|:-----------:|\n| Potentiometer (slow) | < 1 | | | Yes/No |\n| Sine wave | 50 | | | Yes/No |\n| Sine wave | 100 | | | Yes/No |\n| Sine wave | 300 | | | Yes/No |\n\n**Questions**:\n1. At which frequency do you start to lose the fine details of the sine wave?\n2. What is the highest signal frequency you can measure with confidence using the ALPACA?\n3. How does the measurement interval relate to your maximum sampling rate?\n4. How would you modify your program if you wanted to measure frequencies above 500 Hz?"
325
202
},
326
203
{
327
204
"cell_type": "markdown",
328
205
"metadata": {},
329
-
"source": [
330
-
"(Task_C3_2_2)=\n",
331
-
"#### Task C3: Frequency sweep and signal consistency\n",
332
-
"\n",
333
-
"```{admonition} Consider Tasks [A4](Task_A4_2_2), [I4](Task_I4_2_2), and [I5](Task_I5_2_2).\n",
334
-
":class: note no-content\n",
335
-
"```\n",
336
-
"\n",
337
-
"1. Did the measured peak voltage remain constant across the frequency sweep (as expected for a simple sine generator with fixed amplitude)?\n",
338
-
"2. If variations occurred, which frequencies showed the largest deviations and why?\n",
339
-
"3. Was the 0.5 s settling time sufficient at each frequency change?\n",
340
-
"4. How would you optimize the frequency sweep to measure from 1 Hz to 500 Hz more efficiently while maintaining data quality?"
341
-
]
342
-
},
343
-
{
344
-
"cell_type": "markdown",
345
-
"metadata": {},
346
-
"source": [
347
-
"## Notes and troubleshooting\n",
348
-
"\n",
349
-
"| Problem | Possible cause | Solution |\n",
350
-
"|:--------|:---------------|:-----------:|\n",
351
-
"| Time intervals are highly irregular | Interrupt handling, memory allocation during loop | Use pre-allocated arrays, minimize operations in loop |\n",
352
-
"| Measured voltage is always 0 or very noisy | ADC pin not connected or wrong pin number | Check connections, verify pin 26 is Ain0, 27 is Ain1 |\n",
353
-
"| Sine wave looks distorted at high frequencies | Sampling rate too low (aliasing) | Increase sampling rate or reduce signal frequency |\n",
354
-
"| Settling time seems insufficient | Function generator needs more time to stabilize | Increase settling delay to 1 second |\n",
355
-
"| Program crashes or freezes | Memory overflow from large arrays | Reduce number of samples or measurement duration |"
356
-
]
206
+
"source": "(Task_C3_2_2)=\n#### Task C3: Frequency sweep and signal consistency\n\n```{admonition} Consider Tasks [A4](Task_A4_2_2) and [I3](Task_I3_2_2).\n:class: note no-content\n```\n\n1. Did the measured peak voltage remain constant across the frequency sweep (as expected for a simple sine generator with fixed amplitude)?\n2. If variations occurred, which frequencies showed the largest deviations and why?\n3. Was the 0.5 s settling time sufficient at each frequency change?\n4. How would you optimize the frequency sweep to measure from 1 Hz to 500 Hz more efficiently while maintaining data quality?"
0 commit comments