gpt4 book ai didi

c++ - Agilent E4426B 信号发生器在多个 GPIB *SAV 操作期间锁定

转载 作者:太空狗 更新时间:2023-10-29 23:09:58 25 4
gpt4 key购买 nike

我有一个带有 Agilent E4426B RF 信号发生器的测试夹具,通过 National Instrument 以太网到 GPIB 桥接器连接到 PC。我的软件试图通过预设来净化仪器,然后将当前状态保存到所有可通过标准 SCPI 命令“*SAV x,y”写入的内存位置。

循环工作到一定程度,但最终仪器以错误响应并在前显示屏上持续显示“L”图标,并在底部显示“远程预设”消息。那时它不会再响应任何远程命令,我必须循环电源或按 LOCAL,然后按 PRESET,这时大约需要 3 分钟才能完成预设。此时“L”图标仍然存在,下一个发送到仪器的 GPIB 命令导致它在仪器错误队列中报告 -113 错误(未定义的 header )。

我启动 NI spy 查看发生了什么,发现错误发生在循环中的同一点 - 在本例中为“*SAV 6,2”。来自 NI spy :

Send (0, 0x0017, "*SAV 6,2", 8 (0x8), NLend (0,0x01))
Process ID: 0x00000520 Thread ID: 0x00000518
ibsta:0xc168 iberr: 6 ibcntl: 2(0x2)

这是来自仪器驱动程序的代码:

int CHP_E4426b::Erase()
{
if ((m_StatusCode = Initialize()) != GPIB_SUCCESS) // basically just sends "*RST"
return m_StatusCode;

m_SaveState = "*SAV %d, %d";

for (int i=0; i < 10; i++)
for (int j=0; j < 100; j++) {
sprintf(m_CmdString, m_SaveState, j, i);
if ((m_StatusCode = Send(m_CmdString, strlen(m_CmdString))) != GPIB_SUCCESS)
return m_StatusCode;
}

return GPIB_SUCCESS;
}

我尝试在内部循环的末尾放置一个小的 Sleep() 延迟(10-20 毫秒),令我惊讶的是它导致错误出现得更早而不是更晚。 10 毫秒导致循环在 44,1 处出错,而 20 毫秒甚至更快。我已经排除了错误的布线或仪器是罪魁祸首。这种相同类型的序列在高端信号发生器上运行时没有任何错误,因此我很想将其归因于仪器固件中的错误。

最佳答案

尝试将 OPC?; 添加到字符串中,然后进行读取以等待 OPC 命令完成。这样您的程序就不会“重载”仪器。

int CHP_E4426b::Erase()
{
if ((m_StatusCode = Initialize()) != GPIB_SUCCESS) // basically just sends "*RST"
return m_StatusCode;

m_SaveState = "*SAV %d, %d;OPC?;";

for (int i=0; i < 10; i++)
for (int j=0; j < 100; j++) {
sprintf(m_CmdString, m_SaveState, j, i);
if ((m_StatusCode = Send(m_CmdString, strlen(m_CmdString))) != GPIB_SUCCESS)
return m_StatusCode;
Receive(m_CmdString, sizeof(m_CmdString));
}

return GPIB_SUCCESS;
}

关于c++ - Agilent E4426B 信号发生器在多个 GPIB *SAV 操作期间锁定,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3031012/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com