• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Change value with linear pot

Thread starter #1
Hi all

The project I'm working on requires me to use two linear 20k potentiometers to change two values, time and temperature.

What I'm doing is running a heating element for a certain period of time. The user selects the time(Range 5-9 min) and temperature (100-150C) and pushes a button, then the program reads the time and temp selected by the user,and starts until it reaches the time selected by the user. The heating element is controlled via PWM using a MOSFET to control the temperature by changing the duty cycle. Temperature input is taken from a thermistor.

This project has several milestones but I'm starting with the potentiometers.

My questions are:

How do I change a value on the program with the potentiometer?
I'm assuming that when the user pushes the button the program picks up a value of resistance and turns it into a desired value (temperature or time)

How do I convert a resistance into a value of time and a value of temperature? I'm guessing I could assign to a certain range of resistance a value of time or temp. I wonder if there is a better way.

I'm not a programmer so please keep it as plain as possible. THANKS A BUNCH!!!!

Matienzo

EDIT: I forgot to mention I'm using an arduino.
 
Last edited:

Les Jones

Well-Known Member
#2
Just connect a known voltage between the ends of the potentiometer tracks with the negative of the supply connected to the micro ground. (Just using the Vcc supply is the simplest solution. Then connect the sliders each to an ADC input. Use the reading from the ADC to control your parameters.

Les.
 

MikeMl

Well-Known Member
Most Helpful Member
#3
I would connect the wiper of one linear 20KΩ pot to one AD input of an Arduino, and then write a program that makes a delay that is proportional to the ADC reading.

I would connect a temperature sensor to a conditioning circuit that creates a linear voltage proportional to temperature. I would connect that voltage to a second ADC input of the Arduino, and then compare the temperature reading to a voltage determined the setting of a second 20KΩ linear pot. The Arduino program would subtract the temperature reading from the pot setting to come up with an error signal which would in-turn determine the PWM duty cycle used to heat the resistive heater.

The Arduino is a much easier approach than building a circuit that is hardwired.
 
Thread starter #4
Thanks for the all the help. Here is what I put together (some help from online tutorials)
Code:
void setup()
{
  Serial.begin(9600);
}

void loop()

{
  int Res = analogRead(A0);
  int temp = Res * (50 / 1023);   //converts to temp value between 0 and 50
 
  Serial.print("Resistance is ");
  Serial.print(Res);
  Serial.print("\t");

  Serial.print("Temperature is ");
  Serial.println(temp);
}
However, for some reason the output for temperature is always 0. Any idea why?

Code:
Resistance is 616    Temperature is 0
Resistance is 618    Temperature is 0
Resistance is 613    Temperature is 0
Resistance is 620    Temperature is 0
Resistance is 622    Temperature is 0
Resistance is 615    Temperature is 0
Resistance is 618    Temperature is 0
Resistance is 616    Temperature is 0
 
Last edited:
Thread starter #6
thank you jjw,

I was just writing that I found my newbie mistake as I saw your post.
 
Last edited:
Thread starter #7
Here is the final working code. I wanted the temperature range to be between 100 and 150c and the time between 5 and 10 min.
Thank you for the guidance!

Code:
void setup()
{ 
  Serial.begin(9600);
}

void loop()
{ 
  int Res1 = analogRead(A0);
  float temp1 = 100 + Res1 * (50.0 / 1023.0);  //gives a range between 100 and 150 C

  int Res2 = analogRead(A1);
  float Time = 3600000 * 5 + (Res2 * ((3600000 * 5)/1024)) ; //gives a range between 5 and 10 min
 
 // Serial.print("Resistance 1 = ");
 // Serial.print(Res1);
 // Serial.print("\t");

 // Serial.print("Resistance 2 = ");
 // Serial.print(Res2);
 // Serial.print("\t");
 
  Serial.print("Temperature = ");
  Serial.print(temp1);
  Serial.print(" C\t");

  Serial.print("Time = ");
  Serial.print(Time/3600000);
  Serial.println(" min ");
}
 

crutschow

Well-Known Member
Most Helpful Member
#8
The user selects the time(Range 5-9 min) and temperature (100-150C) and pushes a button, then the program reads the time and temp selected by the user,and starts until it reaches the time selected by the user.
If it stops after a fixed length of time then what does the temperature select do? :confused:
 
Thread starter #9
Hi crutschow,

After the time is over everything shuts off. If user wants same settings, it simply pushes the button again and it goes through the same cycle. If the user wants the same time but different temperature then it changes the temperature.

Is that what you asked?

BTW that is obviously sill not in the code :)
 
Last edited:

crutschow

Well-Known Member
Most Helpful Member
#10
After the time is over everything shuts off. If user wants same settings, it simply pushes the button again and it goes through the same cycle. If the user wants the same time but different temperature then it changes the temperature.
So it somehow determines how much heat to apply to reach the desired temperature in the desired time?
How would it do that? :confused:
 
Thread starter #11
The temperature selects a target. Once the user pushes the button the program adjusts the duty cycle of a mosfet until it reaches the target temperature. Then it maintains a duty cycle that keeps the temperature within a small range of the target temperature. I honestly don't know yet how to code it, but some guys here coincide on this being the best way to go about it. No doubts they articulated it much better than I just did. I'll post the link to that thread in a bit.
 

crutschow

Well-Known Member
Most Helpful Member
#12
The temperature selects a target. Once the user pushes the button the program adjusts the duty cycle of a mosfet until it reaches the target temperature. Then it maintains a duty cycle that keeps the temperature within a small range of the target temperature.
That's all fine.
But were does setting the time come into play?
Does it have to reach the set temperature within the set time?
If so, how will that be done?
 
Thread starter #13
oh I see.
I would like the heating element to reach the desired temperature quickly and then remain close to the target temperature until it runs out of time. I don't know how to code it yet.
 

crutschow

Well-Known Member
Most Helpful Member
#14
oh I see.
I would like the heating element to reach the desired temperature quickly and then remain close to the target temperature until it runs out of time. I don't know how to code it yet.
But you still haven't said what the time setting will then do?
 

crutschow

Well-Known Member
Most Helpful Member
#16
It will determine the time a loop with the temperature control runs.
(This is like pulling teeth :rolleyes:).
So what will happen when you reach the end of the time?
Is this time always longer then it takes to reach the desired temperature?
 
Thread starter #17
(This is like pulling teeth :rolleyes:).
Hahaha I knew a comment like this was coming. Sorry.

So what will happen when you reach the end of the time?
The heating elements shut off and cool down on their own. I know I answered this before but I'm not quite sure what else is there that you are trying to find out.

Is this time always longer then it takes to reach the desired temperature?
Always, the heating element reach its temperature probably in 30 sec. The minimum amount of time the user can choose is 5 minutes.

Am I missing something?
 

crutschow

Well-Known Member
Most Helpful Member
#18
Am I missing something?
No.
That was what I was missing.
I was wondering what would happen if the timer had a shorter period then it takes to warm up, but that obviously can't occur.
Sorry for the digression.

So do you still have questions about doing the design?
I can't help much with the code, but I can with any circuit design you may need.
 
Thread starter #19
You are right, I didnt clarify that. Glad is clear now.

I can't help much with the code, but I can with any circuit design you may need.
The arduino makes it super easy to wire things up and most of my connections have voltage through it and go straight to a pin. The next steps are the thermistors, button and MOSFET being the last one the hardest since I've never done it (the code I mean) Thank you for your offer to help!
 

Latest threads

EE World Online Articles

Loading

 
Top