Serial rs232/422 500K baud in simulink real time
15 次查看(过去 30 天)
显示 更早的评论
Hello
For some time now i have been exploring the possibilities of streaming serial data in real time into matlab. I have a specific device that can be set to output data at 500k baud on a continuous stream. I have written many scripts that create serial port objects and poll the hardware for its data. However you are really limited at that point by the time it takes to read the buffer and the slower baud rates of the non continuous output mode of this particular hardware
The max baud for non continuous mode is 38400 Pretty slow obviously When in continuous mode it can continuously stream its data into the serial port of a machine at 500k baud.
I have contacted matlab with little success. They indicated i should look into simulink real time desktop
The end result would be to stream the data in real time, parse the data through some parsing scripts i have already written to acquire the correct data and then store it all in a matrix
Im just looking for a brain storming session here with you other matlab gurus I have never attempted real time work before and have barley scratched the surface of simulink I was looking through the different DAQ boards supported by simulink but don't see anything that handled rs232 or 422 directly. In the documentation matlab says it supports several communication protocols but i can't seem to find any info on which ones and no examples anywhere unless you are using one of their real time target machines which i know nothing about
Any thoughts on this greatly appreciated.
0 个评论
回答(1 个)
Walter Roberson
2016-11-6
编辑:Walter Roberson
2016-11-6
No, you can't do this in Simulink itself. You might be able to do it in Simulink Real Time, possibly, for which you would create a Simulink model and put it through a code generation stage. But then you encounter problems with storing the data quickly enough.
A dual stage might work, in which you had dedicated hardware to receive and parse the data and send it by tcp to something that stores into files.
5 个评论
Walter Roberson
2016-11-6
Your question has multiple parts:
- collecting the data fast enough, and parsing it
- storing the parsed data
- accessing the stored data afterwards
With respect to storing parsed data, I see that Simulink Real-Time can store to local disk, under with restrictions described at https://www.mathworks.com/help/xpc/ug/file-systems.html. Briefly:
- SATA or IDE
- FAT-12, FAT-16, or FAT-32
- 8.3 file name convention only (but folders are supported)
in which case the "access afterwards" is described as
- If running the target computer standalone, you can access a file by restarting the target computer under an operating system such as DOS and accessing the file through the operating system utilities.
- If running the target computer linked to a development computer, you can access the target computer file system from the development computer using a SimulinkRealTime.fileSystem function.
These are not the most fun of restrictions, but they are workable under the premise that the data collection can be stopped periodically for file access and then re-started. That is not always workable -- for example if there is a requirement to monitor when-ever an activity is detected then even if the activity is far from constant, the activity might not be predictable enough to allow the monitoring to be stopped to allow file access.
A significant alternative is to transmit the data while it is being connected. Using a 1 megabit/second link could be a bit tight for data that arrives at 4 megabit/second (asynch serial is 10 bits transmitted for 8 bytes of data.) 10 megabit/second ethernet or higher should be fine.
I do not know enough at the moment about Simulink Real-Time Desktop to know whether it is plausible to use it for this situation; it it is, then it would have the advantage of the files already being on the desktop... but on the other hand; that kind of setup would not be suitable for the "activity could occur at any time" scenario.
For Simulink Real-Time, supported serial ports can be found by filtering on Serial Port in https://www.mathworks.com/programs/products/simulink-real-time/supported/hardware-drivers.html The first one on the list, Quatec DSCP 200/300 looks like it should be more than capable if you have a PXI slot; see http://embedded-computing.com/products/id/?10556. Their PCI cards should do as well; see http://www.bb-elec.com/Products/Serial-Connectivity/PC-Cards/Quatech-PCI-Serial-Boards.aspx and click on "Specs" (I see blank space on parts of their site; I don't think it is fully working.)
Walter Roberson
2016-11-6
"Answer a Question" only shows Questions that have no Answers. The full list shows up at http://www.mathworks.com/matlabcentral/answers/
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Event Functions 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!