05-12-2023 09:02 AM
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.
Solved! Go to Solution.
05-12-2023 09:26 AM - edited 05-12-2023 09:26 AM
I'm downloading LabVIEW on my new laptop. Once I'm done, I'd be glad to provide some help.
05-12-2023 09:28 AM
That would be great, thank you!
05-12-2023 09:35 AM - edited 05-12-2023 09:39 AM
Sorry I misunderstood your question...
Did you install LINX on the Arduino?
In general there are three ways of using LabVIEW with an Arduino
05-12-2023 09:55 AM
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.
05-12-2023 01:14 PM
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?
05-12-2023 01:15 PM
I amusing a tmp36 temperature sensor and it is connected to analogue pin A0 of the arduino.
05-12-2023 01:22 PM - edited 05-12-2023 01:43 PM
Thanks for replying. I am working on your code.
Can you answer my question below?
05-12-2023 01:55 PM
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?
05-12-2023 01:58 PM
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.