1

I have an xPC target application that talks to a device over RS-232. I am using the xPC serial block for this.
To talk to this device I first have to start at a default speed, say, 9600 bps, request a change of speed to, say 57600 bps, then change the speed on my side to match it.
The problem with the xPC block is that it forces you to choose a specific speed before running, and can't change it at run time. Is there a way/trick/hack to do this?

4

3 回答 3

1

Here is my take so far. I don't think it can be done using existing Simulink blocks. I think I am going to have to take the xpcserial C code that comes with Matlab, take the code that sets the RS-232 speed, and wrap it in my own S-function.

于 2008-09-04T05:24:08.380 回答
1

我同意你的观点:我认为这做不到,我很害怕。

进一步思考,我意识到在我的 xPC 系统中,我收到一个编译警告,告诉我我正在使用的块不支持运行期间的采样时间更改;这意味着一般来说这并非不可能……</p>

于 2008-09-04T06:16:16.770 回答
0

伊恩,

我之前对这些东西所做的只是修改 XPC 目标背后的寄存器。它很丑陋,但 xPCarget 首先是丑陋的。

尝试修改线路控制寄存器并直接设置除数——你只需要串口IO地址,你知道的。

无论如何,它值得一试,无论如何你都必须这样做。

于 2008-10-27T18:55:51.360 回答