显示 更早的评论
Hello to all,
I am developing a project and i would like your thoughts and your opinion about this...
I want to design a fuzzy logic controller with real inputs and real outputs. I would like to run the controller outside Matlab environment (probably an .exe file...?) and along with a Visual Basic application.
Should i use - Matlab compiler, - Matlab Builder NE or - Simulink coder (Real Time Workshop) ??
The controller's input will be inserted from a .txt file but the output will be sent in a serial port for communication with a pic micro-controller.
What do you think?
Thank you in advance,
Tassos
采纳的回答
It depends what you mean by "real time". I/O on MS Windows is synonymous with "unbounded latency".
Average latency on any particular MS Windows system might be tolerable for your purposes, but you cannot count on it.
You mentioned serial ports for communication with the PIC micro-controller. If you are planning to use a virtual USB serial port, then unless you write your own drivers, the lower bound on your latency is 40 ms, equivalent to 125 Hz. That applies no matter which OS.
12 个评论
The maximum average latency for Windows XP cannot really be defined. Windows XP was supported on some pretty slow hardware... 120 ns DRAM, run from floppy... add virus scanners and Windows firewall.
I've seen the screen-saver kick in on an 2.4 GHz XP system while it was just processing a single keystroke typed in to an editor.
Average latency is something that really has to be measured for a specific configuration.
If 500 ms is affordable, then as long as you have a decent amount of memory and your system is not doing SETI@Home in the background, and your virus scanners are off while the program is running, you should be able to achieve that the great majority of the time.
However! If this system involves safety to a human or animal or endangered species, then you would probably not be able to get approval for it.
Safety-critical systems need a Real Time Operating System (RTOS), and have to be carefully designed. Even when a half-second response time is acceptable.
When your XP system goes BSOD because it detected a memory parity error (as it eventually will), what is going to happen to the system being controlled?
I use 1GHz processor, 2GB Ram, an SSD, no internet connection, no antivirus.
The system will have continuous human observation so if BSOD happened, human takes control!
With that configuration I would suggest that MATLAB Coder would probably be better. MATLAB Compiler generates objects that need MCR (MATLAB Component Runtime), which is somewhere close to 900 MB. You will want that in memory and you want the program memory itself and you will want VB and associated libraries to be in memory, and you will want any writable OS files to normally be in memory. The total of these things is going to strain the 2GB of RAM that you have. You do NOT want to be swapping on to the SSD as you would "wear out" the SSD (SSD have limited write cycles.)
With MATLAB Coder, with relatively simple tasks, your memory occupancy should be much smaller.
Thank you very much Walter!
I just realized that I have no information about whether something done in MATLAB Coder can control VB or vice versus. My suspicion would be that if it can happen it would not be via the COM interface.
I just want to send data from VB application to be the input for the fuzzy controller.
I know i can call .m file from VB and pass data to it.
If I use Simulink coder to make C/C++ code will be possible to have this functionality??
By saying COM interface you mean serial port communication??
COM is the Microsoft Component Object Model, http://en.wikipedia.org/wiki/Component_Object_Model
I do not know whether that could be incorporated in to Simulink Coder code. My suspicion is that it cannot be. Possibly the solution is to use MATLAB Builder NE -- I do not know.
When you call a .m file from VB, it is either going through the COM interface or else making calls to the equivalent of MCR (MATLAB Component Runtime.) I do not know which. Kaustubha knows a lot more about these matters than I do.
Ok, thank you very much for your time and for your answers.
I will try to communicate with Kaustubha.
The other way i had in mind is to make a DLL from the generated Simulink Coder's C code and call from VB application.
What do you think about this?
I think calling as a DLL is probably workable, but keep in mind that this work requires that there be a component monitoring the data transfer, and that component cannot sit around and wait for the next time that VB happens to make a call in to the DLL. So really you need at least 2 threads, one mainly dealing with the I/O.
If the VB is controlling, does that imply "live" controls, in the sense that the VB portion could change what was to be sent to the device? If so then you will also need some logic for data sharing between the threads. These sorts of things are common in real (or semi-real-) time programming, but problems in this area can be very difficult to track down even in well-written programs.
I think i am a little confused from your answer....
If i have a timer tick event in VB and the vb application reads data every second from pic and in the same tick event call the DLL???
So there is no need for a monitoring component for the data...
Sorry if i am wrong, but i am trying to understand...
Timers in VB that deliberately invoke the DLL would be feasible only if the timer will reliably fire and execute and complete the DLL task within your maximum latency period (which you indicated earlier is 1/2 second.)
If you have the VB reading from the PIC, then I am confused about which part will be doing what? What computation would the the MATLAB DLL do that you would not just execute in straight VB ? And is the MATLAB component responsible for controlling the PIC or is the VB part? (You wouldn't want to be sharing a single serial port between the two; MATLAB doesn't like sharing files or devices.)
Ok, i have a pic that communicates with the vb application via serial port. This work is already done. Its a data acquisition and data visualization application...
Now i want to develop a fuzzy logic cotroller that will control my system.
Fuzzy controller will use a different serial port to "speak" with a different pic controller. So, Matlab will be responsible for controlling the pic and there is no serial port sharing.
So, the vb part will read the data and the matlab part will do the control.
My problem is the interface between vb part and matlab part. I want to send two differnt data values(velocity, inclination) from vb part to matlab part. With these two values, fuzzy controller will make the control...
I dont know a way to develop a fuzzy logic controller in VB. Is there any?
I hope to made things more clear now...
更多回答(1 个)
Thank you for your answer Walter.
So until now we have 40 ms latency of virtual serial port adding the OS latency which is Windows XP.
What is the maximum average latency on Windows XP?
I think a latency of 500 ms is affordable. You think that something like that i want to do is a "waste of time"?
If no, which is the best Matlab product to develop the fuzzy controler?
类别
在 帮助中心 和 File Exchange 中查找有关 Deployment, Integration, and Supported Hardware 的更多信息
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
