P6 Transducers
P6 Transducers
Transducers Laboratory
Nombre:
Build a simple interface for a working calorimeter using Arduino and LabVIEW.Instead of
using a speaker, the values will now be shown on the screen.
Introduction
LabVIEW is a powerful simulation tool for developing a data acquisition system. It supports
serial communication with other devices. In this report, we have used the LabVIEW 2013
version with the support of NI-Visa version 5.1. for serial communication with the Arduino
board.
The name LabVIEW is a shortened form of its description: Laboratory Virtual Instrument
Engineering Workbench. LabVIEW is a visual programming language: it is a system-design
platform and development environment that was aimed at enabling all forms of system to
be developed. LabVIEW was developed by National Instruments as a workbench for
controlling test instrumentation. However its applications have spread well beyond just test
instrumentation to the whole field of system design and operation.
In this project, we will be building an Arduino-based calorimeter that can measure the
amount of heat produced. We will be using LabVIEW, a graphical programming language
that is widely used in scientific and engineering applications, to interface with the Arduino
and collect data.
The LabVIEW software will be used to control the Arduino-based calorimeter and collect
data from the temperature sensor. We will be able to monitor the temperature changes
during the reaction and calculate the heat produced or absorbed using the data collected.
Physical Circuit
Circuit diagram
Program sketch
#include<math.h>
const int Rc= 1000;
const int Vcc=5;
const int SensorPIN=A0 float A= 1.11492089e-3; float B= 2.372075385e-4; float C=
6.954079529e-8; float K=2.5;
void setup()
{
Serial.begin (9600);
}
void loop()
{
float raw= analogRead(SensorPIN)
float V=raw/1024*Vcc;
float R=(Rc*V)/(Vcc-V);
float logR=log(R);
float R_th=1.0/(A+B*logR+C*logR*logR*logR); float kelvin= R_th-V*V/(K*R)*1000;
float celsius= kelvin-273.15;
Serial.print(“T=”);
Serial.print(celsius);
Serial.print(“C\n”);
delay(1000);
}
Code explanation
Certainly! Let's break down the code step by step to understand what it does.
#include <math.h>
This line includes the math.h library, which provides mathematical functions like logarithm,
exponentiation, and trigonometric functions. It allows you to use these functions in your
code.
This line declares a constant integer variable `SensorPIN` and assigns it the value `A0`. In
Arduino, `A0` represents the analog pin 0. It is likely used to connect a temperature sensor
to the Arduino board.
float A = 1.11492089e-3;
float B = 2.372075385e-4;
float C = 6.954079529e-8;
float K = 2.5;
These lines declare four float variables, `A`, `B`, `C`, and `K`, and assign them specific
floating-point values. These variables are likely constants used in the calculations later in the
code.
void setup()
{
Serial.begin(9600);
}
This is the setup function, which is called once when the Arduino board is powered on or
reset. Inside the setup function, `Serial.begin(9600)` initializes the serial communication at a
baud rate of 9600 bits per second. This allows you to communicate with the Arduino board
via a serial connection.
void loop()
{
float raw = analogRead(SensorPIN);
float V = raw / 1024 * Vcc;
float R = (Rc * V) / (Vcc - V);
float logR = log(R);
float R_th = 1.0 / (A + B * logR + C * logR * logR * logR);
float kelvin = R_th - V * V / (K * R) * 1000;
float celsius = kelvin - 273.15;
Serial.print("T=");
Serial.print(celsius);
Serial.print("C\n");
delay(1000);
}
This is the main `loop` function, which runs repeatedly after the `setup` function. It contains
the actual code that performs temperature conversion calculations and outputs the result to
the serial monitor.
1. `float raw = analogRead(SensorPIN);` reads the analog value from the pin specified by
`SensorPIN` (A0 in this case) and assigns it to the variable `raw`. This value represents the
analog voltage from a connected temperature sensor.
2. `float V = raw / 1024 * Vcc;` calculates the voltage `V` based on the raw analog value. It
divides the raw value by 1024 (the resolution of the ADC on Arduino) to obtain a value
between 0 and 1, and then multiplies it by `Vcc` (5V in this case) to get the actual voltage
value.
3. `float R = (Rc * V) / (Vcc - V);` calculates the resistance `R` using the voltage `V` and the
constant `Rc`. It uses the voltage divider formula to calculate the resistance.
4. `float logR = log(R);` calculates the natural logarithm of the resistance `R` and assigns it to
the variable `logR`.
5. `float R_th = 1.0 / (A + B * logR + C * logR * logR * logR);` calculates the resistance of the
thermistor `R_th` using the Steinhart-Hart equation. It uses the constants `A`, `B`, and `C`
defined earlier.
6. `float kelvin = R_th - V * V / (K * R) * 1000;` calculates the temperature in Kelvin using the
Steinhart-Hart equation and the voltage `V`. It uses the constant `K` defined earlier.
7. `float celsius = kelvin - 273.15;` converts the temperature from Kelvin to Celsius by
subtracting 273.15.
8. `Serial.print("T=");` prints the string "T=" to the serial monitor.
9. `Serial.print(celsius);` prints the temperature value in Celsius to the serial monitor.
10. `Serial.print("C\n");` prints the string "C\n" (indicating the end of the temperature value) to
the serial monitor.
11. `delay(1000);` adds a delay of 1000 milliseconds (1 second) before the next iteration of
the loop.
Conclusions
References
Flowers, P., Theopold, K., Langley, R., & Robinson, W. R. (2019). 5.2 Calorimetry.
OpenStax. Recuperado 2 de mayo de 2023, de
https://openstax.org/books/chemistry-2e/pages/1-introduction
J. Zhang, X. Liu, Y. Cheng, L. Shi, & M. Zhang. (2016). A simple and low-cost
Arduino-based educational calorimeter. Journal of Chemical Education, 93(5),
916-920. doi: 10.1021/acs.jchemed.5b0075.