Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

associate handels in matlab GUI

Status
Not open for further replies.

itmr

Member level 3
Member level 3
Joined
Nov 5, 2010
Messages
55
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,750
Hi I am Itamar and i have some problem while using MATLAB GUIDE.

I need to update multiple text boxes from UART Received data.
i created 'ByteAvailabeFcn' that interrupt when getting the configured num of bytes from the UART.
When i created the interrupted function that suppose to read the data and parse it to the text boxes i had a problem to set the handles of each text box.

does somebody know how to associate text box handles.

here is my example :

% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
serial_port = serial('COM10','baudrate',115200);
set (serial_port,'DataBits',8);
set (serial_port,'ReadAsyncMode','continuous');
set (serial_port,'InputBufferSize',1);
set (serial_port,'BytesAvailableFcnMode','byte');
set (serial_port,'BytesAvailableFcnCount',1);
set(serial_port,'ByteOrder','littleEndian');%bigEndian
set (serial_port,'BytesAvailableFcn',@getData_4_gui_update2);
fopen(serial_port);

function getData_4_gui_update2(obj,event);
global serial_port;
ReceivedPacket = fread(serial_port,1);% read one byte from serial port
set(handles.edit1,'string',ReceivedPacket)
fclose (serial_port);
return
%fclose(instrfind);

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
guidata(hObject, handles);

% --- 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

and the error i got:

??? Undefined variable "handles" or class "handles.edit1".


Thanks
Itamar
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top