**3.4 Initialization and quitting routines**

The conceptual scheme of the experiment in **Figure 8** shows the optical, electrical and digital connections of the THYR setup. The TeraVision software controls 4 items: Delay Stage, Data Acquisition Card (DAQ ), Rotors and the monochromator. The first task of the software at startup is therefore to initialize all these devices.

**57**

**Figure 8.**

*Conceptual scheme of the experiment.*

*TeraVision: A LabVIEW Software for THz Hyper-Raman Spectroscopy*

The program creates all folders needed for data acquisition according to the system date and time; it opens all communication ports and cleans all buffers. In this phase, however, the software is not only performing the basic initialization in order to be able to communicate with each device, but it is also interacting with the user. Using pop-up messages the software asks the user about starting set parameters, which initial value is read in a setup file. For instance the user can choose to move the Delay Stage to find its physical edges or to set the "home position", i.e. the zero-step position. The user can choose to skip the initialization procedure of that specific device too. The same happens for all devices. This start-up phase is run only at the beginning, when the software is launched. Then the software is running in time-out mode, waiting for user commands. When the software is quit, a second one-timeonly routine is launched, which is saving all set parameters in the setup file in order to call them again at next startup. This method is very convenient as the parameters are many, and the user can not always remember which parameter was set last time. Beside this, the quit-routine is closing all open ports and flushing all memories of the devices in order to ensure a clean startup on the next call. A "smart-stop" VI ensures that the user cannot quit the program if one or more while/for loops are still running. The VI makes sure all loops are closed in the right order, from internal to external, and all queues are correctly flushed before moving to stop the next loop. This is the reason why it is not recommendable to quit the software in other ways.

**3.5 The block diagram: event structure/producer and consumer loops**

After initialization, the software goes in timeout mode and waits for user commands. The entire architecture of the software is therefore enclosed in a large event structure, shown in **Figure 9**, where every single button on screen is triggering a specific event. This choice of the basic architecture was perhaps not the wisest one, and it will be changed in the future (see the final section about future perspectives). In order to ensure that unjustified clicking on certain buttons by the user can harm the software execution, each event will disable all buttons which are not relevant during the performance of that event, and those buttons will be grayed, so that the user has an exact feeling of what can and cannot be done in that precise moment. The user can always stop the current task with a specific stop button, which drives

*DOI: http://dx.doi.org/10.5772/intechopen.96663*

#### **Figure 8.**

*LabVIEW - A Flexible Environment for Modeling and Daily Laboratory Use*

• The sixth Tab is the "2D Scan" Tab. This Tab is shown in **Figure 7**. This is the Tab for THYR measurement, where the signal is measured in 2D as a function of both wavelength (x-axis) and time (y-axis). The graphs in this Tab can be manipulated to be a color mesh in 2D or a full 3D graph. The figure shows a typical THz measurement, in which we can observe first and second order Stokes and anti-Stokes bands and their very different time relaxation. The oscillating behavior of the central peaks is evident as well. For a detailed explanation of the measurement shown in this figure, we would like to refer to Ref. [26].

• Finally, the last Tab is the "Rotors" Tab, in which the signal can be measured as a function of the incoming or outcoming optical polarization. This is of particular importance when studying the symmetry properties of the SHG signal generated by the sample. This is in turn important for obtaining a correct physical interpretation of the THYR signal. This is in fact the result of a complex nonlinear optical effect, and its relationship with the target material parameters of interest can be not easy or immediate to appreciate. One has to usually study the SHG symmetry and characteristics, with and without applying a THz pulse, in order to find the most convenient choice of the optical polarizations. This Tab can be also used as stand-alone acquisition software when a SHG measurement, rather than THYR or THz-TDS, is the real goal of

The conceptual scheme of the experiment in **Figure 8** shows the optical, electrical and digital connections of the THYR setup. The TeraVision software controls 4 items: Delay Stage, Data Acquisition Card (DAQ ), Rotors and the monochromator. The first task of the software at startup is therefore to initialize all these devices.

**56**

**Figure 7.**

*2D scan tab for THYR spectroscopy.*

the experiment.

**3.4 Initialization and quitting routines**

*Conceptual scheme of the experiment.*

The program creates all folders needed for data acquisition according to the system date and time; it opens all communication ports and cleans all buffers. In this phase, however, the software is not only performing the basic initialization in order to be able to communicate with each device, but it is also interacting with the user. Using pop-up messages the software asks the user about starting set parameters, which initial value is read in a setup file. For instance the user can choose to move the Delay Stage to find its physical edges or to set the "home position", i.e. the zero-step position. The user can choose to skip the initialization procedure of that specific device too. The same happens for all devices. This start-up phase is run only at the beginning, when the software is launched. Then the software is running in time-out mode, waiting for user commands. When the software is quit, a second one-timeonly routine is launched, which is saving all set parameters in the setup file in order to call them again at next startup. This method is very convenient as the parameters are many, and the user can not always remember which parameter was set last time. Beside this, the quit-routine is closing all open ports and flushing all memories of the devices in order to ensure a clean startup on the next call. A "smart-stop" VI ensures that the user cannot quit the program if one or more while/for loops are still running. The VI makes sure all loops are closed in the right order, from internal to external, and all queues are correctly flushed before moving to stop the next loop. This is the reason why it is not recommendable to quit the software in other ways.
