用尖端的波形发生器释放您的创造力。
A
A
硬件概览
它是如何工作的?
Waveform 4 Click基于AD9106,这是一款高性能的四通道数模转换器(DAC),集成了片上模式存储器,用于通过Analog Devices的直接数字合成器(DDS)生成复杂波形。DDS是一款12位输出、最高180 MHz主时钟的正弦波发生器,具有24位调谐字,允许10.8 Hz/LSB的频率分辨率。此Click board™默认使用板载125 MHz晶体振荡器作为时钟源,这也是该板的最大输出频率。AD9106生成的高速、高动态范围、多通道复杂波形适用于超声波换能器激励、医疗仪器、便携式仪器、信号发生器和任意波形发生器等应用。模式数据可以包括直接生成的SRAM存储波形、由SRAM调幅的DDS输出或由SRAM提供的DDS频率调谐字,提供啁啾或频移键控(FSK)调制。内部模式控制状态机允许用户为所有D/A转换器编程模式周期、每个D/A转换器通道上信号输出的模式周期内
的起始延迟以及模式的重复率。模式的生成可以通过mikroBUS™插座的PWM引脚连接的TRG来配置。TRG引脚上的下降沿开始生成模式,而上升沿表示请求终止模式生成。AD9106具有单一频率输出和每个集成DAC的独立可编程相移输出。此外,增益调整因子和偏移调整应用于进入四个DAC的数字信号。AD9106的两个DAC输出通过RC网络滤波,然后通过ADA4817-2放大,这是一个结合了Analog Devices新架构和eXFCB工艺的FET输入运算放大器,具有卓越的速度和低噪声组合。其他两个未放大的输出被路由到标记为I2和I4的板载头上。除了正电源要求外,ADA4817-2放大器还具有负电源,这是通过ADM8829实现的,ADM8829是一个电荷泵电压逆变器,用于从Analog Devices的正输入生成负电源。ADA4817-2的输出信号遵循两个路径。一条路径路由到标记为OUT1
的输出连接器,另一条路径路由到标记为OUT3的输出连接器。在这些连接器上,AD9106可以在其可编程模式生成器的控制下生成两种类型的信号模式:无限期重复的周期性脉冲串波形或重复有限次数的周期性脉冲串波形。此Click board™通过标准SPI接口与MCU通信,以编程内部寄存器来完全控制AD9106。此外,它还具有其他功能,如通过mikroBUS™插座的RST引脚实现和路由的复位功能,可以将AD9106的所有寄存器重置为默认状态。此Click board™只能在3.3V逻辑电压水平下运行。因此,在使用不同逻辑电平的MCU之前,必须进行适当的逻辑电压电平转换。不过,此Click board™配备了包含函数和示例代码的库,可用作进一步开发的参考。
功能概述
开发板
Flip&Click PIC32MZ 是一款紧凑型开发板,设计为一套完整的解决方案,它将 Click 板™的灵活性带给您喜爱的微控制器,使其成为实现您想法的完美入门套件。它配备了一款板载 32 位 PIC32MZ 微控制器,Microchip 的 PIC32MZ2048EFH100,四个 mikroBUS™ 插槽用于 Click 板™连接,两个 USB 连接器,LED 指示灯,按钮,调试器/程序员连接器,以及两个与 Arduino-UNO 引脚兼容的头部。得益于创
新的制造技术,它允许您快速构建具有独特功能和特性的小工具。Flip&Click PIC32MZ 开发套件的每个部分都包含了使同一板块运行最高效的必要组件。此外,还可以选择 Flip&Click PIC32MZ 的编程方式,使用 chipKIT 引导程序(Arduino 风格的开发环境)或我们的 USB HID 引导程序,使用 mikroC、mikroBasic 和 mikroPascal for PIC32。该套件包括一个通过 USB 类型-C(USB-C)连接器的干净且调
节过的电源供应模块。所有 mikroBUS™ 本身支持的 通信方法都在这块板上,包括已经建立良好的 mikroBUS™ 插槽、用户可配置的按钮和 LED 指示灯。Flip&Click PIC32MZ 开发套件允许您在几分钟内创建新的应用程序。它由 Mikroe 软件工具原生支持,得益于大量不同的 Click 板™(超过一千块板),其数量每天都在增长,它涵盖了原型制作的许多方面。
微控制器概述
MCU卡片 / MCU

建筑
PIC32
MCU 内存 (KB)
2048
硅供应商
Microchip
引脚数
100
RAM (字节)
524288
使用的MCU引脚
mikroBUS™映射器
“仔细看看!”
Click board™ 原理图

一步一步来
项目组装
实时跟踪您的结果
应用程序输出
1. 应用程序输出 - 在调试模式下,“应用程序输出”窗口支持实时数据监控,直接提供执行结果的可视化。请按照提供的教程正确配置环境,以确保数据正确显示。

2. UART 终端 - 使用UART Terminal通过USB to UART converter监视数据传输,实现Click board™与开发系统之间的直接通信。请根据项目需求配置波特率和其他串行设置,以确保正常运行。有关分步设置说明,请参考提供的教程。

3. Plot 输出 - Plot功能提供了一种强大的方式来可视化实时传感器数据,使趋势分析、调试和多个数据点的对比变得更加直观。要正确设置,请按照提供的教程,其中包含使用Plot功能显示Click board™读数的分步示例。在代码中使用Plot功能时,请使用以下函数:plot(insert_graph_name, variable_name);。这是一个通用格式,用户需要将“insert_graph_name”替换为实际图表名称,并将“variable_name”替换为要显示的参数。

软件支持
库描述
该库包含 Waveform 4 Click 驱动程序的 API。
关键功能:
waveform4_set_frequency
- 此功能设置正弦波和余弦波(DDS)输出频率。waveform4_set_gain
- 此功能设置所需通道的增益水平。waveform4_set_wave_output
- 此功能设置所选通道的所需输出信号波形。
开源
代码示例
完整的应用程序代码和一个现成的项目可以通过NECTO Studio包管理器直接安装到NECTO Studio。 应用程序代码也可以在MIKROE的GitHub账户中找到。
/*!
* @file main.c
* @brief Waveform4 Click example
*
* # Description
* This example demonstrates the use of Waveform 4 click board.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes the driver and performs the click default configuration which
* resets the registers and sets the sine wave output with default gain and
* default frequency for all channels. After that it displays the list of
* supported commands on the USB UART.
*
* ## Application Task
* Depending on the command character received from USB UART it changes the
* signal frequency, gain or wave of the selected channel.
*
* @author Stefan Filipovic
*
*/
#include "board.h"
#include "log.h"
#include "waveform4.h"
static waveform4_t waveform4;
static log_t logger;
#define GAIN_STEP 0.05 // Gain step, used for increase/decrease gain commands.
#define FREQ_STEP 100 // Frequency step, used for increase/decrease frequency commands.
uint32_t freq = WAVEFORM4_DEFAULT_FREQUENCY;
float gain = WAVEFORM4_DEFAULT_GAIN;
uint8_t channel = WAVEFORM4_CHANNEL_1;
uint8_t wave = WAVEFORM4_WAVE_SINE;
/**
* @brief Waveform 4 display commands function.
* @details This function displays the list of supported commands on the USB UART.
* @return None.
* @note None.
*/
void waveform4_display_commands ( void );
/**
* @brief Waveform 4 parse command function.
* @details This function checks if the input command is supported and executes it.
* @param[in] command : Command input, for more details refer to @b waveform4_display_commands function.
* @return @li @c 0 - Success,
* @li @c -1 - Wrong command or command is not executed properly.
*
* See #err_t definition for detailed explanation.
* @note None.
*/
err_t waveform4_parse_command ( uint8_t command );
void application_init ( void )
{
log_cfg_t log_cfg; /**< Logger config object. */
waveform4_cfg_t waveform4_cfg; /**< Click config object. */
/**
* Logger initialization.
* Default baud rate: 115200
* Default log level: LOG_LEVEL_DEBUG
* @note If USB_UART_RX and USB_UART_TX
* are defined as HAL_PIN_NC, you will
* need to define them manually for log to work.
* See @b LOG_MAP_USB_UART macro definition for detailed explanation.
*/
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
waveform4_cfg_setup( &waveform4_cfg );
WAVEFORM4_MAP_MIKROBUS( waveform4_cfg, MIKROBUS_1 );
if ( SPI_MASTER_ERROR == waveform4_init( &waveform4, &waveform4_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( WAVEFORM4_ERROR == waveform4_default_cfg ( &waveform4 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
waveform4_display_commands ( );
log_info( &logger, " Application Task " );
}
void application_task ( void )
{
uint8_t command = 0;
if ( log_read ( &logger, &command, 1 ) > 0 )
{
waveform4_parse_command ( command );
}
}
int main ( void )
{
/* Do not remove this line or clock might not be set correctly. */
#ifdef PREINIT_SUPPORTED
preinit();
#endif
application_init( );
for ( ; ; )
{
application_task( );
}
return 0;
}
void waveform4_display_commands ( void )
{
log_printf( &logger, "-------------------------------------------\r\n" );
log_info( &logger, "- UART commands list -\r\n" );
log_printf( &logger, "'+' - Increase frequency.\r\n" );
log_printf( &logger, "'-' - Decrease frequency.\r\n" );
log_printf( &logger, "'G' - Increase gain.\r\n" );
log_printf( &logger, "'g' - Decrease gain.\r\n" );
log_printf( &logger, "'S' or 's' - Select sine wave output.\r\n" );
log_printf( &logger, "'C' or 'c' - Select cosine wave output.\r\n" );
log_printf( &logger, "'T' or 't' - Select triangle wave output.\r\n" );
log_printf( &logger, "'P' or 'p' - Select positive sawtooth wave output.\r\n" );
log_printf( &logger, "'N' or 'n' - Select negative sawtooth wave output.\r\n" );
log_printf( &logger, "'1' - Select channel 1.\r\n" );
log_printf( &logger, "'2' - Select channel 2.\r\n" );
log_printf( &logger, "'3' - Select channel 3.\r\n" );
log_printf( &logger, "'4' - Select channel 4.\r\n" );
log_printf( &logger, "'L' or 'l' - Display commands list.\r\n" );
log_printf( &logger, "-------------------------------------------\r\n" );
}
err_t waveform4_parse_command ( uint8_t command )
{
switch( command )
{
case '+':
{
freq += FREQ_STEP;
if ( freq > WAVEFORM4_MASTER_CLOCK )
{
freq = WAVEFORM4_MASTER_CLOCK;
}
log_printf( &logger, "Frequency increased: %lu Hz\r\n", freq );
return waveform4_set_frequency ( &waveform4, freq );
}
case '-':
{
freq -= FREQ_STEP;
if ( freq > WAVEFORM4_MASTER_CLOCK )
{
freq = 0;
}
log_printf( &logger, "Frequency decreased: %lu Hz\r\n", freq );
return waveform4_set_frequency ( &waveform4, freq );
}
case 'G':
{
gain += GAIN_STEP;
if ( gain > WAVEFORM4_GAIN_MAX )
{
gain = WAVEFORM4_GAIN_MAX;
}
log_printf( &logger, "Gain increased: %.3f\r\n", gain );
return waveform4_set_gain ( &waveform4, channel, gain );
}
case 'g':
{
gain -= GAIN_STEP;
if ( gain < WAVEFORM4_GAIN_MIN )
{
gain = WAVEFORM4_GAIN_MIN;
}
log_printf( &logger, "Gain decreased: %.3f\r\n", gain );
return waveform4_set_gain ( &waveform4, channel, gain );
}
case 'S': case 's':
{
wave = WAVEFORM4_WAVE_SINE;
log_printf( &logger, "Sine wave selected.\r\n" );
return waveform4_set_wave_output ( &waveform4, channel, wave );
}
case 'C': case 'c':
{
wave = WAVEFORM4_WAVE_COSINE;
log_printf( &logger, "Cosine wave selected.\r\n" );
return waveform4_set_wave_output ( &waveform4, channel, wave );
}
case 'T': case 't':
{
wave = WAVEFORM4_WAVE_TRIANGLE;
log_printf( &logger, "Triangle wave selected.\r\n" );
return waveform4_set_wave_output ( &waveform4, channel, wave );
}
case 'P': case 'p':
{
wave = WAVEFORM4_WAVE_POSITIVE_SAWTOOTH;
log_printf( &logger, "Positive sawtooth wave selected.\r\n" );
return waveform4_set_wave_output ( &waveform4, channel, wave );
}
case 'N': case 'n':
{
wave = WAVEFORM4_WAVE_NEGATIVE_SAWTOOTH;
log_printf( &logger, "Negative sawtooth wave selected.\r\n" );
return waveform4_set_wave_output ( &waveform4, channel, wave );
}
case '1':
{
channel = WAVEFORM4_CHANNEL_1;
log_printf( &logger, "Channel 1 selected.\r\n" );
return waveform4_set_wave_output ( &waveform4, channel, wave );
}
case '2':
{
channel = WAVEFORM4_CHANNEL_2;
log_printf( &logger, "Channel 2 selected.\r\n" );
return waveform4_set_wave_output ( &waveform4, channel, wave );
}
case '3':
{
channel = WAVEFORM4_CHANNEL_3;
log_printf( &logger, "Channel 3 selected.\r\n" );
return waveform4_set_wave_output ( &waveform4, channel, wave );
}
case '4':
{
channel = WAVEFORM4_CHANNEL_4;
log_printf( &logger, "Channel 4 selected.\r\n" );
return waveform4_set_wave_output ( &waveform4, channel, wave );
}
case 'L': case 'l':
{
waveform4_display_commands ( );
return WAVEFORM4_OK;
}
default :
{
log_error( &logger, "Wrong command." );
return WAVEFORM4_ERROR;
}
}
}
// ------------------------------------------------------------------------ END
/*!
* @file main.c
* @brief Waveform4 Click example
*
* # Description
* This example demonstrates the use of Waveform 4 click board.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes the driver and performs the click default configuration which
* resets the registers and sets the sine wave output with default gain and
* default frequency for all channels. After that it displays the list of
* supported commands on the USB UART.
*
* ## Application Task
* Depending on the command character received from USB UART it changes the
* signal frequency, gain or wave of the selected channel.
*
* @author Stefan Filipovic
*
*/
#include "board.h"
#include "log.h"
#include "waveform4.h"
static waveform4_t waveform4;
static log_t logger;
#define GAIN_STEP 0.05 // Gain step, used for increase/decrease gain commands.
#define FREQ_STEP 100 // Frequency step, used for increase/decrease frequency commands.
uint32_t freq = WAVEFORM4_DEFAULT_FREQUENCY;
float gain = WAVEFORM4_DEFAULT_GAIN;
uint8_t channel = WAVEFORM4_CHANNEL_1;
uint8_t wave = WAVEFORM4_WAVE_SINE;
/**
* @brief Waveform 4 display commands function.
* @details This function displays the list of supported commands on the USB UART.
* @return None.
* @note None.
*/
void waveform4_display_commands ( void );
/**
* @brief Waveform 4 parse command function.
* @details This function checks if the input command is supported and executes it.
* @param[in] command : Command input, for more details refer to @b waveform4_display_commands function.
* @return @li @c 0 - Success,
* @li @c -1 - Wrong command or command is not executed properly.
*
* See #err_t definition for detailed explanation.
* @note None.
*/
err_t waveform4_parse_command ( uint8_t command );
void application_init ( void )
{
log_cfg_t log_cfg; /**< Logger config object. */
waveform4_cfg_t waveform4_cfg; /**< Click config object. */
/**
* Logger initialization.
* Default baud rate: 115200
* Default log level: LOG_LEVEL_DEBUG
* @note If USB_UART_RX and USB_UART_TX
* are defined as HAL_PIN_NC, you will
* need to define them manually for log to work.
* See @b LOG_MAP_USB_UART macro definition for detailed explanation.
*/
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
waveform4_cfg_setup( &waveform4_cfg );
WAVEFORM4_MAP_MIKROBUS( waveform4_cfg, MIKROBUS_1 );
if ( SPI_MASTER_ERROR == waveform4_init( &waveform4, &waveform4_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( WAVEFORM4_ERROR == waveform4_default_cfg ( &waveform4 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
waveform4_display_commands ( );
log_info( &logger, " Application Task " );
}
void application_task ( void )
{
uint8_t command = 0;
if ( log_read ( &logger, &command, 1 ) > 0 )
{
waveform4_parse_command ( command );
}
}
int main ( void )
{
/* Do not remove this line or clock might not be set correctly. */
#ifdef PREINIT_SUPPORTED
preinit();
#endif
application_init( );
for ( ; ; )
{
application_task( );
}
return 0;
}
void waveform4_display_commands ( void )
{
log_printf( &logger, "-------------------------------------------\r\n" );
log_info( &logger, "- UART commands list -\r\n" );
log_printf( &logger, "'+' - Increase frequency.\r\n" );
log_printf( &logger, "'-' - Decrease frequency.\r\n" );
log_printf( &logger, "'G' - Increase gain.\r\n" );
log_printf( &logger, "'g' - Decrease gain.\r\n" );
log_printf( &logger, "'S' or 's' - Select sine wave output.\r\n" );
log_printf( &logger, "'C' or 'c' - Select cosine wave output.\r\n" );
log_printf( &logger, "'T' or 't' - Select triangle wave output.\r\n" );
log_printf( &logger, "'P' or 'p' - Select positive sawtooth wave output.\r\n" );
log_printf( &logger, "'N' or 'n' - Select negative sawtooth wave output.\r\n" );
log_printf( &logger, "'1' - Select channel 1.\r\n" );
log_printf( &logger, "'2' - Select channel 2.\r\n" );
log_printf( &logger, "'3' - Select channel 3.\r\n" );
log_printf( &logger, "'4' - Select channel 4.\r\n" );
log_printf( &logger, "'L' or 'l' - Display commands list.\r\n" );
log_printf( &logger, "-------------------------------------------\r\n" );
}
err_t waveform4_parse_command ( uint8_t command )
{
switch( command )
{
case '+':
{
freq += FREQ_STEP;
if ( freq > WAVEFORM4_MASTER_CLOCK )
{
freq = WAVEFORM4_MASTER_CLOCK;
}
log_printf( &logger, "Frequency increased: %lu Hz\r\n", freq );
return waveform4_set_frequency ( &waveform4, freq );
}
case '-':
{
freq -= FREQ_STEP;
if ( freq > WAVEFORM4_MASTER_CLOCK )
{
freq = 0;
}
log_printf( &logger, "Frequency decreased: %lu Hz\r\n", freq );
return waveform4_set_frequency ( &waveform4, freq );
}
case 'G':
{
gain += GAIN_STEP;
if ( gain > WAVEFORM4_GAIN_MAX )
{
gain = WAVEFORM4_GAIN_MAX;
}
log_printf( &logger, "Gain increased: %.3f\r\n", gain );
return waveform4_set_gain ( &waveform4, channel, gain );
}
case 'g':
{
gain -= GAIN_STEP;
if ( gain < WAVEFORM4_GAIN_MIN )
{
gain = WAVEFORM4_GAIN_MIN;
}
log_printf( &logger, "Gain decreased: %.3f\r\n", gain );
return waveform4_set_gain ( &waveform4, channel, gain );
}
case 'S': case 's':
{
wave = WAVEFORM4_WAVE_SINE;
log_printf( &logger, "Sine wave selected.\r\n" );
return waveform4_set_wave_output ( &waveform4, channel, wave );
}
case 'C': case 'c':
{
wave = WAVEFORM4_WAVE_COSINE;
log_printf( &logger, "Cosine wave selected.\r\n" );
return waveform4_set_wave_output ( &waveform4, channel, wave );
}
case 'T': case 't':
{
wave = WAVEFORM4_WAVE_TRIANGLE;
log_printf( &logger, "Triangle wave selected.\r\n" );
return waveform4_set_wave_output ( &waveform4, channel, wave );
}
case 'P': case 'p':
{
wave = WAVEFORM4_WAVE_POSITIVE_SAWTOOTH;
log_printf( &logger, "Positive sawtooth wave selected.\r\n" );
return waveform4_set_wave_output ( &waveform4, channel, wave );
}
case 'N': case 'n':
{
wave = WAVEFORM4_WAVE_NEGATIVE_SAWTOOTH;
log_printf( &logger, "Negative sawtooth wave selected.\r\n" );
return waveform4_set_wave_output ( &waveform4, channel, wave );
}
case '1':
{
channel = WAVEFORM4_CHANNEL_1;
log_printf( &logger, "Channel 1 selected.\r\n" );
return waveform4_set_wave_output ( &waveform4, channel, wave );
}
case '2':
{
channel = WAVEFORM4_CHANNEL_2;
log_printf( &logger, "Channel 2 selected.\r\n" );
return waveform4_set_wave_output ( &waveform4, channel, wave );
}
case '3':
{
channel = WAVEFORM4_CHANNEL_3;
log_printf( &logger, "Channel 3 selected.\r\n" );
return waveform4_set_wave_output ( &waveform4, channel, wave );
}
case '4':
{
channel = WAVEFORM4_CHANNEL_4;
log_printf( &logger, "Channel 4 selected.\r\n" );
return waveform4_set_wave_output ( &waveform4, channel, wave );
}
case 'L': case 'l':
{
waveform4_display_commands ( );
return WAVEFORM4_OK;
}
default :
{
log_error( &logger, "Wrong command." );
return WAVEFORM4_ERROR;
}
}
}
// ------------------------------------------------------------------------ END