DDSUnit
DDS is a signal source Unit. It uses the AD9833 programmable waveform generator + STM32F0 micro controller. Based on I2C communication interface (addr:0x31) It can easily control the signal source to output multiple waveforms (sine wave, triangle wave, square wave output, sawtooth wave, signal output amplitude 0-0.6V) and adjust the frequency and phase.
Support the following products:
Micropython Example:
import os, sys, io
import M5
from M5 import *
from hardware import *
from unit import DDSUnit
i2c = I2C(1, scl=33, sda=32)
dds = DDSUnit(i2c)
dds.quick_output(DDSUnit.WAVE_SINE, 1000, 0)
for x in i2c.readfrom_mem(0x31, 0x30, 6): print('%02X' %x);
UIFLOW2 Example:
class DDSUnit
Constructors
Methods
- DDSUnit.set_freq_phase(f_index: int = 0, freq: int = 1000, p_index: int = 0, phase: int = 0) None
Set the frequency and phase of the DDS.
- 参数:
UIFLOW2:
- DDSUnit.set_mode(mode) None
Set the output mode of the DDS.
- 参数:
mode (int) –
The output mode of the DDS.
- Options:
DDSUnit.WAVE_SINE: SineDDSUnit.WAVE_TRIANGLE: TriangleDDSUnit.WAVE_SQUARE: SquareDDSUnit.WAVE_SAWTOOTH: SawtoothDDSUnit.WAVE_DC: DC
UIFLOW2:
- DDSUnit.set_ctrl(f_index_sel: int = 0, p_index_sel: int = 0, disable_mclk=False, disable_dac=False, reset=False) None
Set the control bytes of the DDS.
- 参数:
UIFLOW2:
- DDSUnit.select_freq_reg(index: int = 0) None
Select the frequency register of the DDS.
- 参数:
index (int) – The index of the frequency register. range from 0 to 1
UIFLOW2:
- DDSUnit.select_phase_reg(index: int = 0) None
Select the phase register of the DDS.
- 参数:
index (int) – The index of the phase register. range from 0 to 1
UIFLOW2:
- DDSUnit.quick_output(mode: int = WAVE_SINE, freq: int = 1000, phase: int = 0) None
Quickly set the output mode, frequency and phase of the DDS.
- 参数:
UIFLOW2:
Constants
- DDSUnit.WAVE_SINE
Sine wave output.
- DDSUnit.WAVE_TRIANGLE
Triangle wave output.
- DDSUnit.WAVE_SQUARE
Square wave output.
- DDSUnit.WAVE_SAWTOOTH
Sawtooth wave output.
- DDSUnit.WAVE_DC
DC wave output.
- DDSUnit.SLEEP_MODE_NONE
No sleep mode.
- DDSUnit.SLEEP_MODE_1
Disable mclk but keep dac.
- DDSUnit.SLEEP_MODE_2
Disable mclk and dac.
