필터 지우기
필터 지우기

Problem with xPC target parameter

조회 수: 1 (최근 30일)
Steve Burck
Steve Burck 2012년 3월 4일
I'm writing this for another one of our programmers whose English isn't up to writing this; my understanding of Simulink is minimal (I use the resulting C-code which he is making). I hope the explanation is enough to find the problem.
He is using an xPC FIFO bin read block (RS232) to read data from a UART. This seems to work well with one exception.
When he sets up the bin read, the parameters are:
Header - a few headers for possible inputs from a proprietary protocol.
Message Lengths - the appropriate lengths for the given headers
Output behavior - Zero output if no new data - this is the problem, more anon.
...
Sample Time 0.001
Now he hooks to the block a block which selects the 7th byte from the received data, and checks its value. If the value is 75 (part of the protocol), then the block returns 1, and if not, it returns 0.
At this point, when he runs the simulation, the output of the block is 0 at the beginning, until a switch is hit, and then the block goes to 1. After this, no data will be sent - but the block, which he expects to go back to 0 (no data is arriving) to go to zero - and it is staying high. In other words the behavior of the FIFO bin read is seemingly "Send previous data" instead of "zero output if no new data", despite the definition otherwise.
Any help would be appreciated. Any new data needed from him or me will be given as soon as I see this.
Thanks in advance.

채택된 답변

Shiva Arun Kumar
Shiva Arun Kumar 2012년 3월 5일
Hi,
Only the count is zeroed out for 16 and 32 bit reads. For 8 bit reads, the first element is zeroed since the first 0 marks the end of string.
Since the count is also the first element in the structure for 16 and 32 bit reads, it is always true that a non-zero first element indicates a new message. A zero first element indicates that there was no new message.
The whole message isn't cleared.
HTH Shiva
  댓글 수: 3
Steve Burck
Steve Burck 2012년 3월 12일
But at first glance, this is a binary read block, not an ASCII one. Null terminiation doesn't look right for a binary read.
Steve Burck
Steve Burck 2012년 3월 14일
That solved it. Thanks very much

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Target Computer Setup에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by