Problem with xPC target parameter
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
0 commentaires
Réponse acceptée
Shiva Arun Kumar
le 5 Mar 2012
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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Target Computer Setup dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!