Académique Documents
Professionnel Documents
Culture Documents
PC to micro Communication
• Playing with PC side
1
1/26/2011
Serial Port on PC
• If you have a serial port use ‘COM1’
USB-to-Serial
Requires hardware to see it pop up. Good to know how to find it though.
2
1/26/2011
• Communication Settings
– Port: COM1
– BaudRate: 19200
– Terminator: 10
• Communication State
– Status: closed
3
1/26/2011
Writing data
pic = serial(‘COM1’, ‘BaudRate’,…
19200,'Terminator',10)
fopen(pic)
fclose(pic)
Reading data
pic = serial(‘COM1’, ‘BaudRate’,…
19200,'Terminator',10)
fopen(pic)
fscanf(pic);
fclose(pic)
4
1/26/2011
>>
end
5
1/26/2011
MATLAB GUIDE
Graphical User Interface Development Environment
Panels
• Group objects
• Tag
– uipanel_nameForPanel
– Handy to disable/enable whole panel
• Name
– Title on Panel
6
1/26/2011
Pushbuttons
• Tag
– pushbutton_nameForButton
– pushbutton_goLeft
• String
– Label on button
handles.uipanel_buzzer handles.edit_comPort
handles.uipanel_allMessages handles.pushbutton_connect
handles.uipanel_connect handles.pushbutton_disconnect
handles.pushbutton_getRA0 handles.figure1
handles.pushbutton_stopBuzzer
handles.pushbutton_startBuzzer handles.user.connected
handles.text_receivedMessages handles.user.pic
handles.edit_sendMessage
7
1/26/2011
Callbacks
• Functions that get called when an event
happens
– Much like an interrupt with a PIC
– Event driving programming!
– hObject is the object that was selected
8
1/26/2011
handles struct
• A struct variable with a reference to every
object in your GUI!
• Set functions
– set(handles.text_RA0value,'String',500);
• Get functions
– get(handles.edit_sendMessage,'String');
Static Text
• Tag
– text_nameForStaticText
– text_RA0value
– Sometimes renaming tag is not necessary
• String
– Setting string in the static text
• set(handles.tagName,'String',newStringValue);
– Example
• set(handles.text_RA0value,'String',500);