2013年12月18日 星期三

Matlab 2013a 外部程式語言介面(建構中)

                                                                                                    Author : 一心の流 (Alex Chung)
如果您尚未安裝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:
  1. The documentation for the External Interfaces capability included in MATLAB:
  2.  The documentation for Data Acquisition Toolbox : http://www.mathworks.com/help/toolbox/daq/
  3. The documentation for Instrument Control Toolbox: http://www.mathworks.com/help/toolbox/instrument/
  4. 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 !


 Let's make pin 13 an output
Code:
>> a.pin Mode(13,'output')


and turn on the led
Code:
>> a.digital Write(13, 1) ------>and there is light! Very Happy 

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 外部程式語言介面包含:

  1. Java Libraries : Work in MATLAB with Java® libraries
  2. .NET Libraries : Work in MATLAB with .NET libraries
  3. Call MEX-Files : Call MEX-file functions from MATLAB
  4. COM Interface : Interact with MATLAB through COM technology
  5. Web Services : Communicate with Web services from MATLAB over a network using SOAP and WSDL
  6. C Shared Libraries : Call C functions from MATLAB
  7. 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

沒有留言:

張貼留言

注意:只有此網誌的成員可以留言。