Skip to content

Commit

Permalink
Add low frequency error to PWM (fix #213)
Browse files Browse the repository at this point in the history
  • Loading branch information
bessman authored Jan 20, 2023
1 parent 3ade2ef commit 1f03ae5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pslab/instrument/waveform_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ class PWMGenerator:
>>> pwmgen.set_states(sq2=True)
"""

_LOW_FREQUENCY_LIMIT = 4
_HIGH_FREQUENCY_LIMIT = 1e7

def __init__(self, device: SerialHandler = None):
Expand Down Expand Up @@ -404,8 +405,10 @@ def generate(
+ "Please use map_reference_clock for 16 & 32 MHz outputs."
)
raise ValueError(e)
elif frequency <= 0:
raise ValueError("Frequency must be positive.")
elif frequency < self._LOW_FREQUENCY_LIMIT:
raise ValueError(
f"Frequency must be at least {self._LOW_FREQUENCY_LIMIT} Hz."
)
else:
self._frequency = frequency
channels, duty_cycles = _listify(channels, 4, duty_cycles)
Expand Down

0 comments on commit 1f03ae5

Please sign in to comment.