如果您尚未安裝matlab2013a 請參考 Matlab 2013a 搶先下載
進入主題
MY Question :
I've written my MATLAB code and I'm working on an AVR ATXMEGA 128 A1 chip.
My question is: Is it possible to create a communication between my MATLAB code and my AVR chip simultaneously??
Matlab Answer :
I suggest taking a look at one or more of the following:
- The documentation for the External Interfaces capability included in MATLAB:
- http://www.mathworks.com/help/techdoc/matlab_external/bp_kqh7.html
- If you access the chip via the serial port or via a C/C++/Fortran/Java/.NET library one of the sections in this documentation will show how to access the port or library.
- The documentation for Data Acquisition Toolbox : http://www.mathworks.com/help/toolbox/daq/
- The documentation for Instrument Control Toolbox: http://www.mathworks.com/help/toolbox/instrument/
- This is one of the video for simulink for AVR : A new approach to embedded design for Automotive
5. The easiest is if you use an Arduino compatible AVR, otherwise it is a simple ascii based serial protocol, look at the source. It should be easy to port the basic IO-stuff to any MCU. The servo and motor control requires some more work.
I have to try it
Code:
>> a = arduino('/dev/ttyUSB1');
Attempting connection ........
General Script detected !
Arduino successfully connected !
Attempting connection ........
General Script detected !
Arduino successfully connected !
Code:
>> a.pin Mode(13,'output')
Code:
>> a.digital Write(13, 1) ------>and there is light!
What's actually sent to the Arduino is (115200 baud)
0n1 0 for pin mode, n is pin 13 ('n' - 'a' = 13), 1 for output
2n1 2 for digital write, n is pin 13, 1 for high
Matlab 2013a 外部程式語言介面包含:
- Java Libraries : Work in MATLAB with Java® libraries
- .NET Libraries : Work in MATLAB with .NET libraries
- Call MEX-Files : Call MEX-file functions from MATLAB
- COM Interface : Interact with MATLAB through COM technology
- Web Services : Communicate with Web services from MATLAB over a network using SOAP and WSDL
- C Shared Libraries : Call C functions from MATLAB
- API to MATLAB :Write programs in other languages, for example C/C++ and Fortran, to interface with MATLAB functionality
Referenc Link:
Simulink Video 與範例, 初級 Simulink 用法
Embedded Coder : Generate C and C++ code optimized for embedded systems
MATLAB Coder : Generate C and C++ code from MATLAB code
Simulink Coder : Generate C and C++ code from Simulink and Stateflow models
Embedded Coder : Generate C and C++ code optimized for embedded systems
MATLAB Coder : Generate C and C++ code from MATLAB code
沒有留言:
張貼留言
注意:只有此網誌的成員可以留言。