Skip to content

Commit 7514259

Browse files
committed
Update integration test connections
1 parent ad7c7e9 commit 7514259

File tree

2 files changed

+24
-17
lines changed

2 files changed

+24
-17
lines changed

tests/test_logic_analyzer.py

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
33
When integration testing, the PSLab's PWM output is used to generate a signal
44
which is analyzed by the logic analyzer. Before running the integration tests,
5-
connect SQ1->LA1->LA2->LA3->LA4.
5+
connect:
6+
SQ1 -> LA1
7+
SQ2 -> LA2
8+
SQ3 -> LA3
9+
SQ4 -> LA4
610
"""
711

812
import time
@@ -21,7 +25,7 @@
2125
LOW_FREQUENCY = 100
2226
LOWER_FREQUENCY = 10
2327
MICROSECONDS = 1e6
24-
ONE_CLOCK_CYCLE = logic_analyzer.CLOCK_RATE ** -1 * MICROSECONDS
28+
TWO_CLOCK_CYCLES = 2 * logic_analyzer.CLOCK_RATE ** -1 * MICROSECONDS
2529

2630

2731
@pytest.fixture
@@ -81,17 +85,17 @@ def test_capture_four_low_frequency(la):
8185
t1 = la.capture(4, 10, e2e_time=e2e_time)[0]
8286
# When capturing every edge, the accuracy seems to depend on
8387
# the PWM prescaler as well as the logic analyzer prescaler.
84-
pwm_abstol = ONE_CLOCK_CYCLE * logic_analyzer.PRESCALERS[2]
88+
pwm_abstol = TWO_CLOCK_CYCLES * logic_analyzer.PRESCALERS[2]
8589
assert np.array(9 * [e2e_time * MICROSECONDS]) == pytest.approx(
86-
np.diff(t1), abs=ONE_CLOCK_CYCLE * logic_analyzer.PRESCALERS[1] + pwm_abstol
90+
np.diff(t1), abs=TWO_CLOCK_CYCLES * logic_analyzer.PRESCALERS[1] + pwm_abstol
8791
)
8892

8993

9094
def test_capture_four_lower_frequency(la):
9195
e2e_time = LOW_FREQUENCY ** -1
9296
t1 = la.capture(4, 10, modes=4 * ["rising"], e2e_time=e2e_time)[0]
9397
assert np.array(9 * [e2e_time * MICROSECONDS]) == pytest.approx(
94-
np.diff(t1), abs=ONE_CLOCK_CYCLE * logic_analyzer.PRESCALERS[2]
98+
np.diff(t1), abs=TWO_CLOCK_CYCLES * logic_analyzer.PRESCALERS[2]
9599
)
96100

97101

@@ -101,7 +105,7 @@ def test_capture_four_lowest_frequency(la):
101105
0
102106
]
103107
assert np.array(9 * [e2e_time * MICROSECONDS]) == pytest.approx(
104-
np.diff(t1), abs=ONE_CLOCK_CYCLE * logic_analyzer.PRESCALERS[3]
108+
np.diff(t1), abs=TWO_CLOCK_CYCLES * logic_analyzer.PRESCALERS[3]
105109
)
106110

107111

@@ -124,7 +128,7 @@ def test_capture_rising_edges(la):
124128
expected = FREQUENCY ** -1 * MICROSECONDS / 2
125129
result = t2 - t1 - (t2 - t1)[0]
126130
assert np.arange(0, expected * events, expected) == pytest.approx(
127-
result, abs=ONE_CLOCK_CYCLE
131+
result, abs=TWO_CLOCK_CYCLES
128132
)
129133

130134

@@ -134,7 +138,7 @@ def test_capture_four_rising_edges(la):
134138
expected = FREQUENCY ** -1 * MICROSECONDS * 3
135139
result = t2 - t1 - (t2 - t1)[0]
136140
assert np.arange(0, expected * events, expected) == pytest.approx(
137-
result, abs=ONE_CLOCK_CYCLE
141+
result, abs=TWO_CLOCK_CYCLES
138142
)
139143

140144

@@ -144,7 +148,7 @@ def test_capture_sixteen_rising_edges(la):
144148
expected = FREQUENCY ** -1 * MICROSECONDS * 12
145149
result = t2 - t1 - (t2 - t1)[0]
146150
assert np.arange(0, expected * events, expected) == pytest.approx(
147-
result, abs=ONE_CLOCK_CYCLE
151+
result, abs=TWO_CLOCK_CYCLES
148152
)
149153

150154

@@ -174,7 +178,7 @@ def test_measure_interval(la):
174178
channels=["LA1", "LA2"], modes=["rising", "falling"], timeout=0.1
175179
)
176180
expected_interval = FREQUENCY ** -1 * MICROSECONDS * 0.5
177-
assert expected_interval == pytest.approx(interval, abs=ONE_CLOCK_CYCLE)
181+
assert expected_interval == pytest.approx(interval, abs=TWO_CLOCK_CYCLES)
178182

179183

180184
def test_measure_interval_same_channel(la):
@@ -183,7 +187,7 @@ def test_measure_interval_same_channel(la):
183187
channels=["LA1", "LA1"], modes=["rising", "falling"], timeout=0.1
184188
)
185189
expected_interval = FREQUENCY ** -1 * DUTY_CYCLE * MICROSECONDS
186-
assert expected_interval == pytest.approx(interval, abs=ONE_CLOCK_CYCLE)
190+
assert expected_interval == pytest.approx(interval, abs=TWO_CLOCK_CYCLES)
187191

188192

189193
def test_measure_interval_same_channel_any(la):
@@ -192,7 +196,7 @@ def test_measure_interval_same_channel_any(la):
192196
channels=["LA1", "LA1"], modes=["any", "any"], timeout=0.1
193197
)
194198
expected_interval = FREQUENCY ** -1 * DUTY_CYCLE * MICROSECONDS
195-
assert expected_interval == pytest.approx(interval, abs=ONE_CLOCK_CYCLE)
199+
assert expected_interval == pytest.approx(interval, abs=TWO_CLOCK_CYCLES)
196200

197201

198202
def test_measure_interval_same_channel_four_rising(la):
@@ -201,7 +205,7 @@ def test_measure_interval_same_channel_four_rising(la):
201205
channels=["LA1", "LA1"], modes=["rising", "four rising"], timeout=0.1
202206
)
203207
expected_interval = FREQUENCY ** -1 * 3 * MICROSECONDS
204-
assert expected_interval == pytest.approx(interval, abs=ONE_CLOCK_CYCLE)
208+
assert expected_interval == pytest.approx(interval, abs=TWO_CLOCK_CYCLES)
205209

206210

207211
def test_measure_interval_same_channel_sixteen_rising(la):
@@ -210,7 +214,7 @@ def test_measure_interval_same_channel_sixteen_rising(la):
210214
channels=["LA1", "LA1"], modes=["rising", "sixteen rising"], timeout=0.1
211215
)
212216
expected_interval = FREQUENCY ** -1 * 15 * MICROSECONDS
213-
assert expected_interval == pytest.approx(interval, abs=ONE_CLOCK_CYCLE)
217+
assert expected_interval == pytest.approx(interval, abs=TWO_CLOCK_CYCLES)
214218

215219

216220
def test_measure_interval_same_channel_same_event(la):
@@ -219,14 +223,14 @@ def test_measure_interval_same_channel_same_event(la):
219223
channels=["LA3", "LA3"], modes=["rising", "rising"], timeout=0.1
220224
)
221225
expected_interval = FREQUENCY ** -1 * MICROSECONDS
222-
assert expected_interval == pytest.approx(interval, abs=ONE_CLOCK_CYCLE)
226+
assert expected_interval == pytest.approx(interval, abs=TWO_CLOCK_CYCLES)
223227

224228

225229
def test_measure_duty_cycle(la):
226230
period, duty_cycle = la.measure_duty_cycle("LA4", timeout=0.1)
227231
expected_period = FREQUENCY ** -1 * MICROSECONDS
228232
assert (expected_period, DUTY_CYCLE) == pytest.approx(
229-
(period, duty_cycle), abs=ONE_CLOCK_CYCLE
233+
(period, duty_cycle), abs=TWO_CLOCK_CYCLES
230234
)
231235

232236

tests/test_oscilloscope.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
33
When integration testing, the PSLab's analog output is used to generate a
44
signal which is sampled by the oscilloscope. Before running the integration
5-
tests, connect SI1->CH1->CH2->CH3.
5+
tests, connect:
6+
SI1 -> CH1
7+
SI2 -> CH2
8+
SI1 -> CH3
69
"""
710

811
import numpy as np

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy