LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help with arduino temperature control project.

Solved!
Go to solution

Hi guys,

 

I am looking for help regarding a temperature control circuit I made for controlling temperature within a chamber. Here is how i built the circuit: mains power comes into a 12v transformer. out of the dc side of the transformer the + goes to the com2 port of a 2 channel relay and the - goes to the - of the fan. the + of the fan goes to the NO2 port of the relay. the yellow of the fan goes to pin 2 of the arduino and the blue wire of the fan goes to pin 9 of the arduino. the mains L is looped from the trnsformer to COM1 port of the relay and the mains N is looped to the - of the heater. the plus of the heater is connected to the NO1 of the relay. the +5v of the arduino is connected to the + rail of a breadboard. the gnd of the arduino is connected to the - rail of the breadboard. connected to the + rail of the breadboard is the vcc of the relay, the + of the temp sensor and the + side of a 100uF capacitor. connected to - rail of the breadboard is the gnd of the relay, the gnd of the temp sensor and the - leg of the capacitor. the analogue output of the temp sensor is connected to A0 of the arduino. sig1 of the relay is connected to pin 7 of the arduino. sig2 of the relay is connected to pin 5 of the arduino.

 

I have the circuit running fine with the following arduino code:

const int relayHeaterPin = 5;
const int relayFanPin = 7;
const int fanPin = 9;
const int tempPin = A0;
int fanSpeed = 0;
float tempSetpointLow = 16.0; // Temperature setpoint for heater activation
float tempSetpointHigh = 30.0; // Temperature setpoint for fan speed increase

void setup() {
pinMode(relayHeaterPin, OUTPUT);
pinMode(relayFanPin, OUTPUT);
pinMode(fanPin, OUTPUT);
Serial.begin(9600);
}

void loop() {
float temperature = getTemperature();

Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" C");

if (temperature < tempSetpointLow) {
digitalWrite(relayHeaterPin, HIGH); // Turn on the heater
digitalWrite(relayFanPin, HIGH); // Turn on the fan relay
fanSpeed = 20; // Set fan speed to a lower value
Serial.println("Heater is ON");
Serial.println("Fan is ON (Low Speed)");
} else if (temperature >= tempSetpointLow && temperature <= tempSetpointHigh) {
digitalWrite(relayHeaterPin, HIGH); // Turn off the heater relay
digitalWrite(relayFanPin, HIGH); // Turn on the fan relay
fanSpeed = 20; // Set fan speed to a medium value
Serial.println("Heater is ON");
Serial.println("Fan is ON (Medium Speed)");
} else if (temperature > tempSetpointHigh) {
digitalWrite(relayHeaterPin, LOW); // Turn off the heater relay
digitalWrite(relayFanPin, HIGH); // Turn on the fan relay
fanSpeed = 50; // Set fan speed to a higher value
Serial.println("Heater is OFF");
Serial.println("Fan is ON (High Speed)");
}

analogWrite(fanPin, fanSpeed);

delay(1000); // Wait for 1 second
}

float getTemperature() {
int tempReading = analogRead(tempPin);
float tempVoltage = tempReading * 5.0 / 1023.0;
float temperature = (tempVoltage - 0.5) * 100.0;
return temperature;
}

 

I would like to:

 

A: Recreate the circuit using the linx toolkit that i have installed.

 

OR

 

B: Run the circuit using the arduino code and simply use labview as a visual for representing the current temperature and also the current heater and fan status. (I have attached an attempt i made at this)

 

I have tried both and have been completely unsuccessful. If any could help that would be great, thanks.

0 Kudos
Message 1 of 24
(1,500 Views)

I'm downloading LabVIEW on my new laptop. Once I'm done, I'd be glad to provide some help.

0 Kudos
Message 2 of 24
(1,481 Views)

That would be great, thank you!

0 Kudos
Message 3 of 24
(1,476 Views)

Sorry I misunderstood your question...

 

Did you install LINX on the Arduino?

 

In general there are three ways of using LabVIEW with an Arduino

 

  1. Program the Arduino in the native Arduino language.
    1. LabVIEW can communicate with an Arduino using VISA just like any other instrument on a serial port.
    2. IMHO: this is the best way as you have full control over the communications protocol and access to all of the of Arduino libraries and LabVIEW toolkits that are already out there.
    3. I highly recommend watching this video on serial communications: VIWeek 2020/Proper way to communicate over serial
  2. Use LINX (LIFA has long since been deprecated)
    1. Full LabVIEW integration, but limited amount of Arduino libraries and peripherals directly supported
    2. The Arduino basically becomes a tethered DAQ device that needs to be connected to a computer/LabVIEW to work
  3. TSXperts Arduino compiler for LabVIEW
    1. Actually turns LabVIEW into compiled Arduino code. (A real feat on its own)
      1. Limited subset of LabVIEW vi's and primitives
      2. Very limited support for Arduino libraries 
      3. Development seems to have stopped, so those annoying bugs are here to stay

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 4 of 24
(1,459 Views)

Sorry, I meant i have installed the linx toolkit on labview in an attempt to recreate my arduino code using labview. 

 

Tbh i think controlling the circuit via labview is a bit out of my depth (im fairly new to labview). Funnily enough I did try to get the labview program to just show the temperature and heater/fan status using the VISA method but i couldnt get that to work either.

 

I will watch the video you linked to try get a better understanding of what i'm doing wrong, thank you.

0 Kudos
Message 5 of 24
(1,446 Views)

Hi Zero,

 

I just have a question. What sensor are you using to measure the temperature? Are you using a thermocouple, RTD? Which one are you using?

0 Kudos
Message 6 of 24
(1,401 Views)

I amusing a tmp36 temperature sensor and it is connected to analogue pin A0 of the arduino.

0 Kudos
Message 7 of 24
(1,397 Views)

Thanks for replying. I am working on your code.

Can you answer my question below?

GRCK5000_0-1683917017144.png

 

 

0 Kudos
Message 8 of 24
(1,394 Views)

Thank you. Sorry that should say "on", my apologies.

 

Are you planning on controlling the circuit via labview or allowing the ardino code to run the circuit and simply using labview to display the data?

0 Kudos
Message 9 of 24
(1,366 Views)

I can try to do either, but I chose to control the circuit via LabVIEW. It's a lot quicker. I'm almost done though, stay tuned. 

0 Kudos
Message 10 of 24
(1,362 Views)