请更新您的浏览器。 为了获得最佳的 Liquid Instruments 使用体验,请将 Chrome、Edge、Firefox 或 Safari 更新到最新版本。 更新 Microsoft Edge.
液体仪器标志
产品
硬件平台
Moku:Delta
Moku:Delta
全新发布
用于高级设计和验证
Moku:Pro
Moku:Pro用于多种测试和测量
Moku:Lab
Moku:Lab用于实验研究实验室
Moku:Go
Moku:Go用于快速测试和调试
比较硬件
比较硬件横向比较所有 Moku 硬件
技术
GenInst Studio
全新发布
生成个性化工具
仪器功能高度集成触手可及的专业仪器设备
神经网络集成了 基于 FPGA 的神经网络仪器
多仪器并行模式组合仪器功能以创建自定义测试系统
Moku Compile编码、编译和部署到 Moku 的 FPGA 上
软件
MokuOS下载适用于 Windows、macOS、iPadOS 和 VisionOS 的 Moku 应用
APIsPython、MATLAB、LabVIEW
实用工具用于文件转换的命令行和图形工具
仪器功能
信号分析
示波器
频谱分析仪
频率响应分析仪
锁相放大器
相位表
逻辑分析仪/码型发生器
时间间隔与频率分析仪
数据记录器
信号生成
波形发生器
任意波形发生器
信号控制与调理
PID 控制器
数字滤波器
FIR 滤波器生成器
激光锁频/稳频器
自定义与其他功能
GenInst Studio
全新发布
高速信号采集记录回放仪(Gigabit Streamer)
Moku Compile
神经网络
多仪器并行模式
实时数学
全新发布
应用
光学与光子学
显微镜和光谱学
光子计数
量子光学
航空航天和国防
A&D仪器
器件测试
自动化测试
半导体测试
控制系统和伯德图分析
MEMS 系统测试
AI 和机器学习
生成式仪器
全新发布
神经网络
教育服务提供商
教育与研究
相关资源
应用笔记
博客
客户案例
相关课程
指南
产品文档
资讯观点
网络研讨会
白皮书
支持
关于我们
联系我们
关于我们
领导团队
合作伙伴
公司动态
媒体中心
活动日程表
加入我们
商店
0
获取报价 立即购买
MokuOS 4.4 版本现已发布。立即更新,体验人工智能生成的仪器界面、实时数学信号运算等更多功能。 了解更多
应用笔记

I2C testing with Moku:Go

In this application note, we show how to use Moku to generate and decode I2C protocols. We generate an I2C master bus using GenInst Studio, then configure a data transfer example using the Moku Logic Analyzer. The Logic Analyzer instrument is able to listen and decode protocols sent by the I2C master bus using its flexible open-drain DIO architecture. Finally, we add a microcontroller to serve as a receiver. We discuss the ability of Moku:Go to serve effectively as transmitter, receiver, or decoder for a wide variety of digital communication protocols.

杰森·鲍尔博士•2026 年 11 月 3 日

下载应用说明 将此应用说明保存为 PDF。
下载应用说明

下载应用说明

    An introduction to I2C protocol

    There are many ways of packaging and transmitting digital data. Whereas some protocols, such as UART, work well for point-to-point communications, they are not designed to handle a bus containing multiple devices. By contrast, protocols such as Inter-Integrated Circuit (I2C) are designed for synchronous, multi-device communication. A typical I2C bus contains at least one “master” device (although there can be more than one), and at least one “slave” device. Each slave device has an “address” that the master device can use to initiate communication. An I2C bus contains only two lines, the data line (SDA) and clock line (SCL), which are shared by all devices. This makes I2C an ideal protocol for connecting multiple sensors, clocks, or chips to a microcontroller, as the number of required lines does not increase with each device. Figure 1 shows a typical sequence captured by the Moku Logic Analyzer. Bit 0 carries the SDA line, and Bit 1 carries the SCL line. The first byte of the transmission contains the slaves address and initiates a read/write operation. If the address matches and slave acknowledges, the rest of the message is sent. In this case, the message is a series of four 8-bit digits.

    Figure 1. I2C protocol capture by the Moku Logic Analyzer. Bit 0 carries the SDA line, and Bit 1 carries the SCL line. The protocol analyzer decodes the address (4) and data (13, 15, 11, 21).

    In this application note, we will use a Moku:Go as the master in an I2C protocol and make use of GenInst Studio to develop an instrument that can package and send I2C-encoded messages. We show how the open-drain architecture of Moku:Go allows its Logic Analyzer to listen to its own messages. Finally, we add an external microcontroller to act as the slave unit and confirm the data transmission.

    Push-pull vs open-drain pins

    I2C requires two digital lines, called SDA and SCL. SDA carries the digital data, and SCL carries a clock signal that lasts for the length of the message. As seen in Figure 1, the digital lines are held high when not transmitting and are pulled low during transmission.

    In order to ensure proper and safe data transmission, it is essential that the architecture of the digital pins matches the requirements of the protocol. There are two types of pins supported on Moku:Go: push-pull and open-drain. Push-pull lines can drive to zero or high voltage, making them useful for fast, responsive data transfer in protocols like UART. However, since I2C devices share the bus, using push-pull pins can result in a short circuit if one pin is pulled high while another on the same bus is pulled low. By contrast, open-drain outputs only drive the lines low and rely on a pull-up resistor to be able to return to high (Vcc) voltage after a device releases the line.

    Open-drain pins are required for I²C because they prevent short circuits when multiple devices share the same lines and enable the bidirectional communication necessary for the protocol to function. This configuration is seen in Figure 2, where the data lines are joined to Vcc by a pair of resistors. The value of the resistors should be chosen to gently guide the lines back to Vcc (either 3.3 V or 5 V depending on logic level). Too small a resistance exceeds the maximum sink current the devices and raises the low-level voltage, whereas too large a resistance slows the rising edges, since the rise time is set by the pull-up resistance and the bus capacitance.

    Figure 2. Example I²C configuration, showing connections between devices and placement of pull-up resistors.

    As of MokuOS 4.4.0, Moku:Go has the option to set its DIO ports as either input, output, or open-drain, allowing it to be used in a wide variety of protocol and logic analysis applications.

    Creating an I2C Bus Master with GenInst Studio

    In the next section we construct and test a I²C setup. In order to use the Moku Logic Analyzer to decode I2C sequences, we need to first create a Bus Master capable of packaging and encoding data bytes in an I2C format, such as those seen in Figure 1. The I²C bus master sends and receives data at configurable speeds, outputs the bus signals on selectable bits for use with the Moku:Go digital I/O, and reports transaction status and errors back to the user.

    To do so, we make use of GenInst Studio, an AI-enabled development tool which takes plain language prompts and creates verified instruments, ready to deploy on Moku, complete with custom UIs. While the exact prompt used in GenInst Studio can vary substantially, the module should perform the following core functions:

    • Generate complete I2C transactions (start, data bytes, acknowledge, stop) with correct bus timing
    • Support both write and read transactions, plus repeated start conditions
    • Send up to four data bytes to a target device at a user-specified 7-bit address
    • Run at an adjustable clock speed from 1 kHz to 1 MHz
    • Output the data and clock signals on user-selectable bits of a single 16-bit output, so they can be fed directly to the Moku:Go digital I/O pins
    • Read back the target acknowledge/not-acknowledge responses (and received data) through the input
    • Report status information, including whether a transaction is in progress, whether the target acknowledged, the last byte received, how many bytes were transferred, and any errors (such as lost arbitration or timeout)

    After creating and verifying the model through GenInst Studio’s automated testbench, we are ready to deploy it on the Moku:Go. First, we construct the physical setup, with the following materials:

    • Moku:Go device
    • 16-bit breakout cable for Digital I/O (included with Moku:Go)
    • Two 5.1 kΩ resistors
    • 面包板

    We choose 5.1 kΩ for the standard I2C data rate (100 kHz). For higher data rates, reduce the resistance. We arrange the configuration as shown in Figure 3. Four leads (5 V, Pin 1, Pin 2, and Ground) are used. The 5 V lead is attached to the power rail of the breadboard and the Ground lead is attached to the grounding rail. Each Pin is connected to the voltage rail through a pull-up resistor.

    Figure 3. Connection schematic, showing where each Moku:Go pin is connected, along with the pull-up resistors.

    With the I2C Bus Master and physical connections in place, we can now send an encoded message and view it with the Moku Logic Analyzer.

    Decoding I2C sequences with the Logic Analyzer

    We now connect to our Moku:Go and launch the Moku Logic Analyzer alongside the Bus Master to decode the protocols. From the instrument select screen, we choose Multi-Instrument Mode. We place the Logic Analyzer in Slot 1 and GenInst-created I2C Bus Master instrument in Slot 2, as seen in Figure 4. Internally, we connect the Bus Master output, Bus Master input, and Logic Analyzer input all to the DIO channel.

    Figure 4. Multi-Instrument Mode setup for I2C protocol decoding.

    On the screen, click the box above DIO to open the configuration screen. You can click on the circle corresponding to each pin to rotate between output, input, and open-drain. Set Pin 1 and Pin 2 to open-drain – the remainder of the pins are not used in this example. See Figure 5 for details. Once you have set the instruments, pins, and connections, click 在断裂前, 在右上角。

    Figure 5. Changing DIO pin settings in Multi-Instrument Mode.

    First we configure the Bus Master to output a single 8-bit (0-255) number encoded in I2C format. We click the arrow on the I2C Bus Master instrument to open the configuration screen.

    Note: the following UI was created alongside the instrument using GenInst Studio. The exact format, layout, and nature of the interface can vary depending on your exact prompt and/or requirements.

    Opening the custom UI, we first click over to the 交易 tab. We set “Command” to Idle for now, but we will use this option to send the message later. We set the “Target address” to 4, and “Read/write” to Write. On the 时间 tab, we set the Byte count to 1 and Tx data 0 to “60.” You can choose any arbitrary number between the values of 0 and 255 for the data value. On the Bus pins tab, we set the SDA bit to 0 and the SCL bit to 1. These values determine what pins of the DIO we use for the data lines. We also enable the “use readback setting” so the Bus Master can receive the ACK/NACK from the slave device.

    Note: Indexing on the Moku:Go DIO pins begins at 1. Indexing of the bit handling within the Moku instruments begins at zero. In this case, Bit 0 is carried on Pin 1 and Bit 1 is carried on Pin 2.

    最后,在 定时 tab, we set the SCL frequency to 100 kHz, which corresponds to the standard mode data transfer rate. All of these settings can be seen in Figure 6.

    Figure 6. I2C Bus Master settings and status registers using a custom UI with GenInst. The Bus idle light indicates that the Bus Master is ready to send.

    Moving over to the Logic Analyzer instrument, we monitor only Bits 0 and 1, which carry the SDA and SCL lines, respectively. We click the plus sign and add an I2C protocol decoder, which will appear below the traces for the two bits. On the 获得 tab, we set the correct bits for SCL and SDA, as seen in Figure 7. Before switching back to the Bus Master, ensure that the traces on Bit 0 and Bit 1 remain at high voltage – this is the default state when there is no data transfer. If the channels are not high, there may be an issue with the connections or pull-up resistors.

    最后,在 触发端口 tab, set the Mode to Normal, Channel to Bit 1, and the Edge to Falling. This will ensure that the Logic Analyzer captures a single data transfer sequence for analysis.

    Figure 7. Logic Analyzer with I2C protocol analyzer in place.

    Moving back over to the Bus Master, we first confirm that the “Bus idle” light is lit, as seen in Figure 8. We move to the 交易 tab and select Write from the drop-down menu to send a single trace. In the other window, the Logic Analyzer will acquire a trace.

    Figure 8. Sending a message with the Bus Master module.

    Note that the “NACK received” light is now lit. This is because there is no device with the address of 4 on the bus line, so no slave device acknowledges the message. The Logic Analyzer is totally passive and cannot act as a receiver – it is only for listening to data transfer between the master and slave device. We can confirm this by looking at the trace acquired by the Logic Analyzer. We see the SDA and SCL data captured, as well as the decoded message: NACK: 0x04-W, meaning a message was sent to address 4 and not acknowledged.

    Figure 9. The Moku Logic Analyzer reading a NACK, because no device is located at address four.

    To test the full sequence, we add a microcontroller unit (MCU) to the line, connecting its SDA and SCL to the breadboard so that they are joined to the respective lines from the Moku DIO. The MCU used in this case is an Arduini Uno R3. The MCU has dedicated SDA and SCL ports, and its internal logic is fully compatible with I2C protocol using 5 V TTL logic. The MCU does have “weak” (high resistance) internal pull-up resistors which can be supplemented by the external pull-up resistors to achieve higher transfer speed. The MCU also can be assigned a 7-bit address using a short script. The full configuration can be seen in Figure 10.

    Figure 10. Adding a microcontroller with address 4 as a slave device.

    With the slave device in place, we return to the Bus Master interface and confirm that the bus is idle and ready to send again. We click “Write” from the drop-down menu to resend the sequence. This time, the “ACK received” light should show. We confirm this successful send of the data by going once more to the Logic Analyzer and looking at the latest trace capture, which is seen in Figure 11. The sequence should be longer (since both the address and the message are sent in this instance), and the I2C protocol decoder should display both the correct address (4) and the correct data byte. Note that the Logic Analyzer will display the number 60 in hexadecimal as 3C, but regardless this confirms that the data has successfully transferred from the Moku master device to the MCU slave device.

    Figure 11. Successful transfer of the data, recorded by the Moku Logic Analyzer.

    结语

    In this app note, we have shown how the Moku’s flexible DIO pins, ready-to-deploy Logic Analyzer, and custom instrumentation through GenInst Studio make it a versatile option for I2C applications. The DIO pins support both push-pull and open-drain configurations, enabling its use in both multi-device and point-to-point digital communications. The Logic Analyzer features decoders for a wide variety of digital protocols, including I2C. Finally, GenInst Studio allows users to implement custom functions and instrumentation directly on the Moku FPGA without the need to code, debug, or validate HDL code themselves. This allows Moku:Go to serve effectively as transmitter, receiver, or decoder for an enormous array of digital communication protocols.

    在演示模式下试用 Moku 下载 Moku 应用 → 获取常见问题的答案 访问知识库 → 与全球的 Moku 用户建立联系 加入用户论坛 →

    其他推荐的应用笔记

    应用笔记
    使用 Moku:Delta 进行频率混合和检测

    在本应用笔记中,我们将介绍如何使用 Moku:Delta 生成和检测微波脉冲。首先,利用任意波形发生器对基带波形进行编程,然后使用外部微波源和双平衡 IQ 混频器进行上变频。最后,我们将展示 Moku:Delta 如何利用其 6 GHz 模拟带宽模式直接检测和解调微波脉冲。这无需模拟下变频,同时保留了脉冲中包含的相位信息,使其非常适合需要精确测量微波频率相位的应用。

    特点: Moku:Delta、锁相放大器、任意波形发生器

    应用笔记
    从设置到串流:Moku:Delta 千兆串流器指南

    本指南介绍如何通过 SFP/QSFP 端口在 Moku:Delta 和 Linux 主机之间传输确定性样本数据。内容涵盖设置、数据包结构以及发送/接收工作流程。

    特点: Moku:Delta,千兆流媒体播放器

    应用笔记
    使用 Moku:Delta 6 GHz 模式检测奈奎斯特频率以上的射频信号

    本应用笔记探讨了如何利用 Moku:Delta 的全模拟前端,采集和分析奈奎斯特频率以上的信号。我们回顾了奈奎斯特-香农采样定理的概念及其对数字采样的限制。我们解释了该方法的优势以及应用时需要考虑的重要因素。我们以 Moku:Delta 的 6 GHz 模式为例,展示了如何测量第一奈奎斯特区以上的信号。

    特点: Moku:Delta,频谱分析仪

    返回所有应用笔记

    站内导航

    • 产品
    • 仪器功能
    • 相关资源
    • 支持
    • 关于我们
    • 联系我们
    • 隐私政策
    • 使用条款

    办公室

    美国
    (619) 332-6230
    12526 High Bluff Dr.
    Suite 150
    San Diego, CA 92130

    澳大利亚
    +61 2 6171 9730
    243 Northbourne Avenue
    Suite 1, Level 1
    Lyneham, ACT 2602

    澳大利亚
    +61 3 7073 3594
    5C套房,5楼
    斯旺斯顿街700号
    维多利亚州卡尔顿 – 3058

     

     

    关注我们

    LinkedIn YouTube X Facebook Instagram

    官方微信

    © 2026 Liquid Instruments. 版权所有
    当自动完成结果可用时,使用向上和向下箭头查看并输入以转到所需页面。 触摸设备用户,通过触摸或滑动手势进行探索。

    建议

    • 页 Moku:Delta
    • 页 GenInst Studio
    • 博客 MokuOS 4.4 为 GenInst Studio 带来了自定义仪器接口、实时信号计算和精确 GNSS 时间戳功能。
    • 案例分析 利用Moku实现交错式光腔稳定技术
    • 联系我们 获取报价

    需要帮助吗? 访问支持