**5.4 Analog output [PWM]**

in this case we send a message to Arduino by serial port, remember that Arduino reads the message with a SerialEvent() function. Here we make a message with a

**Figure 22.** *Block diagram of msg read from ARDUINO.Vi.*

**99**

*LabView and Connections with Third-Party Hardware DOI: http://dx.doi.org/10.5772/intechopen.96056*

ASCII code (**Figure 23**).

**Figure 24.** *Pin2 & pin4 event.*

Digital Array.

configured.

**5.5 Pin2 state and Pin4 state**

SerialEvent() function **Figure 12**.

with the subvi "data extraction from Arduino message.vi".

having a 10 bit ADC and a dynamic of 5 volts we obtain:

the Waveform chart we multiply the output by the value 0.00488.

word PWM followed with "ANALOG OUTPUT [PWM]" control knob converted in

In this "case" (**Figure 24**) we build the message to send Arduino by serial port to change the digital pin state, remember that Arduino reads the message with a

Now we go back at **Figure 21** where we have to talk about the Consumer Loop. Through the enqueue function we read the data from the head of the queue with the FIFO method (first in first out). If we have not error the data read are processed

In **Figure 25** there is the screen code. The code scan the message, check if present special ID char (#) or (&) and collect the data by **indexing** it on the loop edge. With **Conditional indexing** we choose where collect the data: Analog Array or

The subvi "data extraction from Arduino message.vi" returns the status of the digital inputs and the numerical values of the analogue inputs, if

To convert the integer values reads from analog ports we need to perform a simple conversion. According to what we have studied in the previous paragraphs

[ ] [ ] <sup>10</sup>

At this point, in the consumer loop, before displaying the analogue signals on

<sup>5</sup> V = 0,00488 V <sup>2</sup> (8)

**Figure 23.** *Analog output [PWM] code.*

*LabView and Connections with Third-Party Hardware DOI: http://dx.doi.org/10.5772/intechopen.96056*

**Figure 24.** *Pin2 & pin4 event.*

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

Event-Driven statement is configurated with the following **events.**

**5.3 Timeout**

function.

**5.4 Analog output [PWM]**

message at maximum frequency and by consumer loop we process the data. The

The timeout terminal of "Event Structure" is connected, of course, at local variable"Ts (Sampling Rate)" in according with sample rate configurated in Arduino in node 1. In this "case" we read with "msg read from ARDUINO.vi" the Arduino's message from serial (**Figure 22**). It is very simple code. The data are available on serial port (hardware) and the code read it using a **Bytes at Port**

in this case we send a message to Arduino by serial port, remember that Arduino reads the message with a SerialEvent() function. Here we make a message with a

**98**

**Figure 23.**

*Analog output [PWM] code.*

**Figure 22.**

*Block diagram of msg read from ARDUINO.Vi.*

word PWM followed with "ANALOG OUTPUT [PWM]" control knob converted in ASCII code (**Figure 23**).

#### **5.5 Pin2 state and Pin4 state**

In this "case" (**Figure 24**) we build the message to send Arduino by serial port to change the digital pin state, remember that Arduino reads the message with a SerialEvent() function **Figure 12**.

Now we go back at **Figure 21** where we have to talk about the Consumer Loop. Through the enqueue function we read the data from the head of the queue with the FIFO method (first in first out). If we have not error the data read are processed with the subvi "data extraction from Arduino message.vi".

In **Figure 25** there is the screen code. The code scan the message, check if present special ID char (#) or (&) and collect the data by **indexing** it on the loop edge. With **Conditional indexing** we choose where collect the data: Analog Array or Digital Array.

The subvi "data extraction from Arduino message.vi" returns the status of the digital inputs and the numerical values of the analogue inputs, if configured.

To convert the integer values reads from analog ports we need to perform a simple conversion. According to what we have studied in the previous paragraphs having a 10 bit ADC and a dynamic of 5 volts we obtain:

$$\frac{\text{5[V]}}{\text{2}^{10}} = 0,00488 \,\text{[V]} \tag{8}$$

At this point, in the consumer loop, before displaying the analogue signals on the Waveform chart we multiply the output by the value 0.00488.

**101**

*LabView and Connections with Third-Party Hardware DOI: http://dx.doi.org/10.5772/intechopen.96056*

measurements of angles in uniform angular motion, etc.

The authors declare no conflict of interest.

In this chapter we have seen one of the many ways of how LabView can be used with third parties hardware. The idea is to have an inexpensive tool not for industrial use but for High School applications where it is possible with a few euros to set up a laboratory for the analysis of an RC/RLC circuit, voltage divider, diode/transistor characterization. With a cheap sensors, connected at Analogue inputs, you can prepare laboratory experiments such as the pendulum oscillation, spring characterization,

In the end you could organize LabView CORE I and CORE II training courses in e-learning where the DAQ board is very cheap and easily purchased on the web

Dedicated to My wife and my daughters for encouraging and supporting me. I would like to thank, my friend, the Director of the Department of Mathematics and Physics at my University, Prof. Lucio Gialanella, for supporting my initiative

University of Study Of Campania "Luigi Vanvitelli", Caserta, Italy

\*Address all correspondence to: giuseppe.porzio@unicampania.it

provided the original work is properly cited.

© 2021 The Author(s). Licensee IntechOpen. This chapter is distributed under the terms of the Creative Commons Attribution License (http://creativecommons.org/licenses/ by/3.0), which permits unrestricted use, distribution, and reproduction in any medium,

**6. Conclusions**

from the students.

**Thanks**

**Conflict of interest**

and for his precious advice.

**Author details**

Giuseppe Porzio

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

**Figure 25.** *Data extraction from Arduino message.vi.*
