 # PID Soldering Station - display related problem

I found another problem: while rotating the potentiometer I found that at the beginning and at the end of the course, there is a dead zone. How can I solve this "dead zone" problem ?
I mean dead because when the potentiometer cursor is in that zone, the display does not show the temperature set by the potentiometer...

Hi,
You can't , it is the ends of the potentiometer tracks that have the connections to the potentiometer terminals.
Why does it bother you, unless you want to put a physical scale on it.
You are displaying the setpoint you get from the pot, so it shouldn't matter, you are still getting 0 to 1023 at the input.

Tom.. Hello, I have another problem with this soldering station. I have set the temperature by rotating the pot to 312 C. The iron started to heat, but when it was at about 60 C then on the display (7 segment, 3 digit) appeared 312 (the temperature that I have set) and then appeared about 70 C. I did not rotate the pot, the 312 appeared from nowhere.

I powered on again the soldering station and it showed 35 C - then 312 C - and then 52 C and then the temperature rise normally.

I set the pot randomly at 244 C and the problem did not appeared. It looks like it appeared only at 312 C for now.

Edit: The problem also appeared at 344 C set temperature.
Is there a solution for this problem ?

``````//Soldering station Software using PID
//Thank you Alex from https://geektimes.ru/ for help with led array function
//epilepsynerd.wordpress.com

#include <PID_v1.h>

//This array contains what segments need to be turned on to display numbers 0-9
byte const digits[] = {
B00111111, B00000110, B01011011, B01001111, B01100110, B01101101, B01111101, B00000111, B01111111, B01101111
};

int digit_common_pins[] = {8, 9, 10}; //Common pins for the triple 7-Segment LED display
int max_digits = 3;
int current_digit = max_digits - 1;

unsigned long updaterate = 1200; //Change how fast the display updates. No lower than 500
unsigned long lastupdate;

int temperature = 0;

//Define Variables we'll be connecting to
double Setpoint, Input, Output;

//Define the aggressive and conservative Tuning Parameters
double aggKp = 4, aggKi = 0.2, aggKd = 1;
double consKp = 1, consKi = 0.05, consKd = 0.25;

//Specify the links and initial tuning parameters
PID myPID(&Input, &Output, &Setpoint, consKp, consKi, consKd, DIRECT);

void setup()
{
DDRD = B11111111;  // sets Arduino pins 0 to 7 as outputs
for (int y = 0; y < max_digits; y++)
{
pinMode(digit_common_pins[y], OUTPUT);
}
//We do not want to drive the soldering iron at 100% because it may burn, so we set it to about 85% (220/255)
myPID.SetOutputLimits(0, 220);
myPID.SetMode(AUTOMATIC);
lastupdate = millis();
Setpoint = 0;
}

void loop() {
Input = 0;
for(int i=0;i<50;i++)
Input /= 50;
//Transform the 10bit reading into degrees celsius
Input = map(Input, 0, 550, 25, 400);
//Display temperature
if (millis() - lastupdate > updaterate) {
lastupdate = millis();
temperature = Input;
}
//Read setpoint and transform it into degrees celsius(minimum 150, maximum 350)
newSetpoint = map(newSetpoint, 0, 1023, 150, 400);
//Display setpoint
if (abs(newSetpoint - Setpoint) > 3) {
Setpoint = newSetpoint;
temperature = newSetpoint;
lastupdate = millis();
}

double gap = abs(Setpoint - Input); //distance away from setpoint

if (gap < 10)
{ //we're close to setpoint, use conservative tuning parameters
myPID.SetTunings(consKp, consKi, consKd);
}
else
{
//we're far from setpoint, use aggressive tuning parameters
myPID.SetTunings(aggKp, aggKi, aggKd);
}

myPID.Compute();
//Drive the output
analogWrite(11, Output);
//Display the temperature
show(temperature);
}

void show(int value) {
int digits_array[] = {};
boolean empty_most_significant = true;
for (int z = max_digits - 1; z >= 0; z--) //Cycle through each digit
{
digits_array[z] = value / pow(10, z); //We now take each digit from the number
if (digits_array[z] != 0 ) empty_most_significant = false; //Do not display leading zeros
value = value - digits_array[z] * pow(10, z);
if (z == current_digit)
{
if (!empty_most_significant || z == 0) { //Check to see that we do not have leading zeros and display the current digit
PORTD = ~digits[digits_array[z]]; //Remove ~ for common cathode
}
else
{
PORTD = B11111111;
}
digitalWrite(digit_common_pins[z], LOW);//Change to LOW for common cathode
} else {
digitalWrite(digit_common_pins[z], HIGH);//Change to HIGH for common cathode
}

}
current_digit--;
if (current_digit < 0)
{
current_digit = max_digits; //Start over
}
}
``````
``````#include <PID_v1.h>

//This array contains what segments need to be turned on to display numbers 0-9
byte const digits[] = {
B00111111, B00000110, B01011011, B01001111, B01100110, B01101101, B01111101, B00000111, B01111111, B01101111
};

int digit_common_pins[] = {A3, A4, A5}; //Common pins for the triple 7-Segment LED display
int max_digits = 3;
int current_digit = max_digits - 1;

unsigned long updaterate = 1200; //Change how fast the display updates. No lower than 500
unsigned long lastupdate;

int temperature = 0;

//Define Variables we'll be connecting to
double Setpoint, Input, Output;

//Define the aggressive and conservative Tuning Parameters
double aggKp = 11, aggKi = 0.5, aggKd = 1;
double consKp = 11, consKi = 3, consKd = 5;

//Specify the links and initial tuning parameters
PID myPID(&Input, &Output, &Setpoint, consKp, consKi, consKd, DIRECT);

void setup()
{
DDRD = B11111111;  // sets Arduino pins 0 to 7 as outputs
for (int y = 0; y < max_digits; y++)
{
pinMode(digit_common_pins[y], OUTPUT);
}
//We do not want to drive the soldering iron at 100% because it may burn, so we set it to about 85% (220/255)
myPID.SetOutputLimits(0, 220);
myPID.SetMode(AUTOMATIC);
lastupdate = millis();
Setpoint = 0;
}

void loop() {
Input = 0;
for(int i=0;i<29;i++)
Input /= 29;
//Transform the 10bit reading into degrees celsius
Input = map(Input, 0, 590, 25, 450);
//Display temperature
if (millis() - lastupdate > updaterate) {
lastupdate = millis();
temperature = Input;
}
//Read setpoint and transform it into degrees celsius(minimum 150, maximum 350)
newSetpoint = map(newSetpoint, 0, 1023, 150, 450);
//Display setpoint
if (abs(newSetpoint - Setpoint) > 3) {
Setpoint = newSetpoint;
temperature = newSetpoint;
lastupdate = millis();
}

double gap = abs(Setpoint - Input); //distance away from setpoint

if (gap < 10)
{ //we're close to setpoint, use conservative tuning parameters
myPID.SetTunings(consKp, consKi, consKd);
}
else
{
//we're far from setpoint, use aggressive tuning parameters
myPID.SetTunings(aggKp, aggKi, aggKd);
}

myPID.Compute();
//Drive the output
analogWrite(11, Output);
//Display the temperature
show(temperature);
}

void show(int value) {
int digits_array[] = {};
boolean empty_most_significant = true;
for (int z = max_digits - 1; z >= 0; z--) //Cycle through each digit
{
digits_array[z] = value / pow(10, z); //We now take each digit from the number
if (digits_array[z] != 0 ) empty_most_significant = false; //Do not display leading zeros
value = value - digits_array[z] * pow(10, z);
if (z == current_digit)
{
if (!empty_most_significant || z == 0) { //Check to see that we do not have leading zeros and display the current digit
PORTD = ~digits[digits_array[z]]; //Remove ~ for common cathode
}
else
{
PORTD = B11111111;
}
digitalWrite(digit_common_pins[z], HIGH);//Change to LOW for common cathode
} else {
digitalWrite(digit_common_pins[z], LOW);//Change to HIGH for common cathode
}
}
current_digit--;
if (current_digit < 0)
{
current_digit = max_digits; //Start over
}
}
``````

Hi,
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".
OR
http://forum.arduino.cc/index.php/topic,148850.0.html.
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Thanks... Tom.. Modified and following the rules.
Thank you for the warning
The modified code posted above is working perfectly without errors, has a stable temperature and no flick on the display.
It has been tested in the bord bord for several days, it is very good.
I'm just not able to change from common anode to common cathode.
Can you help ?. I have several display in common model, if I can't change, I will have to buy common anode
I'm new to Arduino programming, I'm just starting.
Thank you