This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

multichanel RTDX reading in Matlab



Can anybody help to us with rebuilding this MATLAB script for twou channel rtdx monitoring.? Please because we can t move with that.

function varargout = Sensing_analog(varargin)
% SENSING_ANALOG MATLAB code for Sensing_analog.fig
%      SENSING_ANALOG, by itself, creates a new SENSING_ANALOG or raises the existing
%      singleton*.
%
%      H = SENSING_ANALOG returns the handle to a new SENSING_ANALOG or the handle to
%      the existing singleton*.
%
%      SENSING_ANALOG('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in SENSING_ANALOG.M with the given input arguments.
%
%      SENSING_ANALOG('Property','Value',...) creates a new SENSING_ANALOG or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before Sensing_analog_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to Sensing_analog_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help Sensing_analog
% Last Modified by GUIDE v2.5 06-Feb-2014 15:26:15
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @Sensing_analog_OpeningFcn, ...
                   'gui_OutputFcn',  @Sensing_analog_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before Sensing_analog is made visible.
function Sensing_analog_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to Sensing_analog (see VARARGIN)
% Choose default command line output for Sensing_analog
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes Sensing_analog wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% Initializing output plot settings %
set(handles.figure1,'visible','off')
axes(handles.axes1);
set(handles.axes1,'xlim',[0 100]);
set(handles.axes1,'ylim',[9206670 13812986]);
set(handles.axes1,'xlimmode','manual');
set(handles.axes1,'ylimmode','manual');
set(handles.axes1,'layer','bottom');
set(handles.axes1,'nextplot','add');
%%%%%%%%%%%%%%%%%%%%%%%%%
% Initializing output plot settings %
%%%%%%%%%%%
xlabel('X');
ylabel('Y');
% Plot some dummny data first to get axis handles %
allNaN = NaN*ones(1,100);
plot(allNaN);
handles.h1 = line('parent',handles.axes1);
% Initializing CCS settings %
global cc;
cc=ticcs;
configure(cc.rtdx,1024,4);
open(cc.rtdx,'ochan1','r');
open(cc.rtdx,'ochan2','r');
enable(cc.rtdx,'ochan1');
enable(cc.rtdx,'ochan2');
enable(cc.rtdx);
cc.rtdx 
% hObject handle to figure
% Read data from Target Board, and plot them on the axes1 %
frameSize = 1;
xlimit = 100;
NumOfFrames = xlimit/frameSize;
yLines = handles.h1;
set(handles.figure1,'visible','on');
r = cc.rtdx;
    
while(isenabled(cc.rtdx))
    set(yLines,'ydata', allNaN,'xdata', [1:xlimit]);
    pause(1e-2); % must be the same as sample time
    for k = 1:NumOfFrames
        if ~ishandle(yLines)
            return;
        end
        
        yAll = get(yLines,'ydata');
        x = (k-1)*frameSize+1;
        y = (k-1)*frameSize+frameSize;
        
        % Read Data from the Target through RTDX %
        numMsgs = r.msgcount('ochan1');
        if(numMsgs > 0),
            if(numMsgs > 1),
                r.flush('ochan1',numMsgs-1);
            end
            yAll(x:y) = readmsg(cc.rtdx,'ochan1','single');
            set(handles.edit1,'String',num2str(yAll(y)))
        end
        set(yLines,'ydata',yAll,'xdata',[1:xlimit]);
        pause(1e-2); % must be the same as sample time
    end
end
% --- Outputs from this function are returned to the command line.
function varargout = Sensing_analog_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
% --- Executes on button press in Run.
function Run_Callback(hObject, eventdata, handles)
% hObject    handle to Run (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global cc;
run(cc);
% --- Executes on button press in Halt.
function Halt_Callback(hObject, eventdata, handles)
% hObject    handle to Halt (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global cc;
halt(cc);
function edit1_Callback(hObject, eventdata, handles)
% hObject    handle to edit1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit1 as text
%        str2double(get(hObject,'String')) returns contents of edit1 as a double
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end