![]() |
|
Tài trợ cho PIC Vietnam |
||||||||
| Giao tiếp cổng COM và LPT RS232, RS485 và LPT là những giao tiếp cơ bản và kinh điển khi mới học về vi điều khiển... |
|
|
Ðiều Chỉnh | Xếp Bài |
|
|
#11 |
|
Nhập môn đệ tử
Tham gia ngày: Aug 2006
Bài gửi: 4
: |
Anh Bắc cho em hỏi 1 tí:
Trong file Rs232 Comunication.m phần Code:
function RS232_Communication_OpeningFcn(hObject, eventdata, handles, varargin) handles.output = hObject; guidata(hObject, handles); Code:
handles.status_com = IsConnect; em đọc trong help có nói nếu khai báo s = serial('COM1'); thì s.status là tình trạng cổng Com open hay close , còn status_com này thì em chưa hiểu , nó là tag nào của phần tử nào trong file *.fig vậy anh? Code:
guidata(hObject,handles); Code:
function button_Send_Callback(hObject, eventdata, handles)
IsConnect = handles.status_com;
s = handles.com;
Code:
function button_Send_Callback(hObject, eventdata, handles)
strTX = get(handles.edit_TX,'String');
fprintf(s,strTX);
Code:
handles.com = s;
guidata(hObject,handles);
Code:
function button_Connect_Callback(hObject, eventdata, handles)
s = serial(get_stringPopup(handles.popup_ComPort));
Code:
s.BytesAvailableFcn = @BytesAvailable_Callback;
s.OutputEmptyFcn = @OutputEmpty_Callback;
s.BreakInterruptFcn = @BreakInterrupt_Callback;
s.ErrorFcn = @Error_Callback;
s.PinStatusFcn = @PinStatus_Callback;
s.BreakInterruptFcn = @BreakInterrupt_Callback;
s.TimerFcn = @Timer_Callback;
em chỉ thấy anh ghi code cho Code:
bytesAvailable_callback như sau:
global hand;
ind = fscanf(obj);
set(hand.edit_RX,'String',ind);
Code:
s.RecordName = get(handles.edit_RecordName,'String');s
s.RecordMode = 'index';
Code:
function figure1_DeleteFcn(hObject, eventdata, handles)
IsConnect = handles.status_com;
if (IsConnect == 1),
s = handles.com;
record(s,'off')
fclose(s);
delete(s);
clear s;
IsConnect = 0;
end
delete(hObject);
Code:
function figure1_CloseRequestFcn(hObject, eventdata, handles)
IsConnect = handles.status_com;
if (IsConnect == 1),
s = handles.com;
record(s,'off');
fclose(s);
delete(s);
clear s;
IsConnect = 0;
end
delete(hObject);
Code:
s.BytesAvailableFcnCount = 1;
s.BytesAvailableFcnMode = 'terminator';
Em thấy trong phần Simulink có hỗ trợ RS 232 luôn , sao lấy ở đó hỗ trợ được không anh? Em mới làm quen với Matlab và giao tiếp cồng Com , xin anh chỉ giáo ạ (^_^) À anh thay đổi nội dung bởi: Nguoi hieu hoc, 14-04-2007 lúc 12:19 AM. |
|
|
|
| Ðiều Chỉnh | |
| Xếp Bài | |
|
|
Similar Threads
|
||||
| Ðề tài | Người gửi | Chuyên mục | Trả lời | Bài mới |
| Giao tiếp RS232 trên PC | ngohaibac | Giao tiếp cổng COM và LPT | 193 | 18-02-2025 09:11 AM |
| giao tiep qua PCI de doc AD bằng Matlab | hanhluckyly | Matlab-Simulink & Labview & 20-Sim | 22 | 06-06-2011 09:55 PM |
| Communicate between PC and PIC via RS232 standard using Matlab (GUI, IO). | ngohaibac | English forum on PICs | 3 | 02-06-2011 06:46 PM |
| cần mua bộ thu GPS có giao tiếp RS232 | kienvq | Tìm mua sản phẩm | 15 | 17-03-2011 11:25 PM |
| Help! Dùng C để giao tiếp RS232 | dandiennang | Các ngôn ngữ lập trình khác (CCS C, HT PIC,...) | 6 | 15-03-2009 06:41 PM |