我一直在尝试使用 scilab 中的串行通信工具箱从 arduino 获取超声波数据,以将其引入 xcos 模拟。为此,我按照在 xcos/scicos 中包含一个 Scilab 函数/脚本作为块并创建了我自己的函数。有没有办法在 xcos 范围内绘制 serialread 数据?或者我认为我在 scilab 函数中的实现是错误的。我正在使用 Windows 10 64 位
SCILAB 功能
function y = serialREAD(a)
h = openserial(7, "9600,n,8,1") // open COM7
for ii = 1:a
y = strtod(part(readserialline(h), [1,2,3])) * (a/a)
end
closeserial(h)
endfunction
结束功能
XCOS 框图
错误 [已解决此错误,已使用 strtod 将字符串转换为双精度]
CMscope 中的数据,但不是实时的,只有在模拟后我的最终积分时间是 100。