Assignments

 

Interface and Programming

 

For this week's assignment, I used "Test and Measurment Toolbox" of MATLAB for communicating with the microcontroller and GUIDE (GUI editor in matlab) for graphical user interface.

 

I also experimented with VISA interface implementation in MATLAB.

 

For assignment, I wrote a code for "VChat" Its a graphical user enviroment which allows user to communicate with microcontroller. Potential application could be in debugging. For the assignment, I gave more emphasis on GUI and PC side programing. The uC is programmed to look for certain input character and based on look-up table send back some strings.

 

Hello FTDI for MATLAB

 

@Microcontroller

 

1) Compile the c code (make file). Burn the code to the microcontroller

Note - While modifying the code, don't forget to put NULL character after every sending strings or character.

 

 

@MATLAB

 

1) Start "Test and Measurment Toolbox" by typing tmtool in command interface.

2) Go to "Serial" and COM# (you can see the COM port number in device manager)

3) Click on Configuration tab set the settings as -

- a) Boud rate - should match with the boud rate of interfacing uC (I used 112500),

- b) Termination Character - NULL (you can choose any character but it should match with what end character uC is sending)

4) Set the sending/recieving data as - Data Type as ASCII, %s\n

 

4) Click on connect. Inter some character in the input sending data field and click on Query. You should be able to recieve what you have sent.

 

 

Handshaking

 

Handshaking is implemented as follows -

a) uC is programmed to look for a character. Once recieved, it start sending the character back.

b) MATLAB program, first sends a character - its like saying "I need data send it to me" to uC.

c) Once that character is recieved by uC, it start sending back the new data to MATLAB program.

Note- In the attached code, only one way handshaking is implemented ie only MATLAB program can ask for data and the uC is tied up in infinite while(1) loop. A more afficient method could be to use interrrupts.

 

 

Serial Port programming in MATLAB

 

% Create the serial port object if it does not exist
% otherwise use the object that was found.
if isempty(handles.obj1)
handles.obj1 = serial('COM9');
else
fclose(handles.obj1);
handles.obj1 = handles.obj1(1)
end

% Connect to instrument object, handles.obj1.
fopen(handles.obj1);

% Configure instrument object, handles.obj1.
set(handles.obj1, 'BaudRate', 112500);
set(handles.obj1, 'Terminator', {0,0});

% Communicating with instrument object, handles.obj1.
data1 = query(handles.obj1, 'cba')

matlab .m file is here

 

 

 

Debuggin -

1) Random character recieved - Look for the boud rate

2) Connection time out - See if the termination character is set proparly in MATLAB and uC

 

 

Graphical User Interface

 

1) Type guide in command line interface.

2) GUIDE is drag n drop GUI layout editor. It has all components like push button, static text, bar, slider etc.

 

 

Below is the video of VChat in working -

 

 

VChat .c .make and matlab .m files

 

 

 

Wireless Communication

 

For my final project, I started working on wireless module for wireless communication. I designed a board which uses two of these module working at two different frequency (434MHz and 315MHz) for transmission and recieving at the same time.

 

 

Right now, its sending the data. Next step will be to implement serial port communication using this wireless Tx/Rx board. The vidoe of it working it below