Blockset described on this wiki is deprecated since 2012.

For Model Based Design (MBD), use the free MPLAB Device Blocks for Simulink, tool from Microchip.
Updated Rapid Control Prototyping (RCP) custom projects are published at: https://lubin.kerhuel.eu.

Difference between revisions of "DsPIC Block/Interface Tx-Matlab"

From http://www.kerhuel.eu/wiki - Simulink device driver Blockset for dsPIC / PIC24 / PIC32 Microcontrollers --[[User:LubinKerhuel|LubinKerhuel]] 12:40, 3 September 2009 (UTC)
Jump to navigation Jump to search
Line 11: Line 11:
 
The connexion and Reset button connect and release the COM port. Once the connexion is set, modification of port parameters has no influence. When connecting, some Windows crash if the dsPIC is sending data. If so, disconnect the PIC while pushing the connection button.
 
The connexion and Reset button connect and release the COM port. Once the connexion is set, modification of port parameters has no influence. When connecting, some Windows crash if the dsPIC is sending data. If so, disconnect the PIC while pushing the connection button.
  
The data received are decoded using the PIC - Matalb protocole created and stored into the R matrix. Each column of R correspond to one channel. R growth until its size reach the buffer size (here 50000). Then, oldest data are deleted so as to retain into R the last 50000 data received.
+
The data received are decoded using the PIC - Matalb protocole created and stored into the R matrix. Each column of R correspond to one channel. R growth until its size reach the buffer size (here 50000). Then, oldest data are deleted so as to retain into R the last 50000 data received. R, T_R, Rn, T_Rn are accessible from the workspace. R and Rn matrix contains NaN values. The function padr allow to remove NaN values.
  
The Rn matrix is a subset of the R matrix. Rn contain the last 10000 values of R. The size of R can be set. Rn is the matrix used for real time plotting.
+
The Rn matrix is a subset of the R matrix. Rn contain the last 10000 values of R. The size of R can be set. Rn is the matrix that should be used for real time plotting.
  
The large text box s to enter matlab command that are interpreted after the delay during which data are received (1s here). You can enter any valid Matlab command. It is also possible to call a matlab file you previously wrote. The four buttons Default, Dflt signe, Simulink, Emission are four example of pre-recorded script. Default is to plot unsigned data. Dflt signe allow to plot signed int16 data.
+
Write the command that are interpreted in the central large text box. After the delay during which data are being received (0.2s here). You can enter any valid Matlab command. It is also possible to call a matlab script file or function you previously wrote. The four buttons Default, Dflt signe, Simulink, Emission are four example of pre-recorded plotting script. Default is to plot unsigned data. Dflt signe allow to plot signed int16 data.
  
Start and Stop button is for start and stop the reception-execution of the script. Do not forget to release the COM port before leaving.
+
Watch out : When logging data for a long time usinga big buffer size, some data may be lost : As the matrix R is growing,Matlab reallocate memory when the matrix is growing. This memory allocation may take some time and for reason that are still unclear, Seral port lose some datas. Note that Matlab use Java to acces to the serail PORT. Thus, it is not optimal!
 +
 
 +
Start and Stop button is for start and stop the reception-execution of the script. Do not forget to release ("reset button") the COM port before leaving.
 +
 
 +
The Send1 and Send2 button allow to send the vector next to the button (respect Send1 and Send2) to the Serial PORT.

Revision as of 23:58, 30 June 2008

Block UART Interface Tx-Matlab

Open Graphical User Interface to receive data from the microcontrollers throw the PC serial port. Data can be plotted in real time.

Double click on this block open the GUI to log data from the dsPIC into matlab.


Interface PIC-Matlab

User Interface for logging data from UART with matlab

Set the connexion of the PC serial port. You can select the COM port used, the baudrate ( select the same used by the dsPIC) and the hardware control flow (usually, set to none if you are using a simple wire. if you use aerial module like bluetooth, you need perhaps the hardware control Flow).

The connexion and Reset button connect and release the COM port. Once the connexion is set, modification of port parameters has no influence. When connecting, some Windows crash if the dsPIC is sending data. If so, disconnect the PIC while pushing the connection button.

The data received are decoded using the PIC - Matalb protocole created and stored into the R matrix. Each column of R correspond to one channel. R growth until its size reach the buffer size (here 50000). Then, oldest data are deleted so as to retain into R the last 50000 data received. R, T_R, Rn, T_Rn are accessible from the workspace. R and Rn matrix contains NaN values. The function padr allow to remove NaN values.

The Rn matrix is a subset of the R matrix. Rn contain the last 10000 values of R. The size of R can be set. Rn is the matrix that should be used for real time plotting.

Write the command that are interpreted in the central large text box. After the delay during which data are being received (0.2s here). You can enter any valid Matlab command. It is also possible to call a matlab script file or function you previously wrote. The four buttons Default, Dflt signe, Simulink, Emission are four example of pre-recorded plotting script. Default is to plot unsigned data. Dflt signe allow to plot signed int16 data.

Watch out : When logging data for a long time usinga big buffer size, some data may be lost : As the matrix R is growing,Matlab reallocate memory when the matrix is growing. This memory allocation may take some time and for reason that are still unclear, Seral port lose some datas. Note that Matlab use Java to acces to the serail PORT. Thus, it is not optimal!

Start and Stop button is for start and stop the reception-execution of the script. Do not forget to release ("reset button") the COM port before leaving.

The Send1 and Send2 button allow to send the vector next to the button (respect Send1 and Send2) to the Serial PORT.