Close

Arduino IL9341 LCD MATLAB/Python/Serial interaction

A project log for Holoscope - Superresolution Holographic Microscope

Subpixel imaging using the Raspberry Pi and an Android Smarthpone. The lightsource is represented by an LCD.

beniroquaibeniroquai 08/02/2016 at 13:350 Comments

This is necessary for writing the illumination patterns/apertures.

A very cheap method to realize a spatial light modulator one can simply use an off-the-shelf LCD module driven by an Arduino. When removing the backlight and putting the LCD in the optical path, it acts as a very cheap mask. Controlling the device via MATLAB or PYTHON is an easy task to do!

Bild1

In my work I tried to implement a SERVER<-> Client interarction, where Matlab sends command and the Arduino executes them.

Writing an entire RGB image using the slow Serial protocol provided by the ARDUINO is not very efficient and takes up to 2 minutes .. Therefore one can define special patterns like rings, segments, etc. and send only the parameters to the arduino. This then selects the right shape and displays it using the parameters provided by the SERIAL connection as seen in the image bellow

Bild2

Calling a patter from MATLAB is as simple as this:

%% Declaration of Serial Port
com_port= ‚COM3‘;
serial_port=serial(com_port);
serial_port.BaudRate=57600;
warning(‚off‘,’MATLAB:serial:fscanf:unsuccessfulRead‘);
%Open Serial Port
fopen(serial_port);
pause(2)
% Set the global center/pixel of the LCD
setGlobalCentre( serial_port, x_centre, y_centre )
pause(2)
% Display Aperture on LCD for Fourier Ptychogrphy (just an example!)
setScanAperture( serial_port, round((X(i) + x_centre)), round(Y(i) + y_centre), dAperture, exposureTime ) % show centre dot (0,0)

the Arduino code as well as the MATLAB and PYTHON code can be found in my Github repository here:

https://github.com/beniroquai/MATLAB-ARDUINO-IL9341-LCD-Serial-Communication/tree/master

Discussions