I am designing a new soldering station which will use a 24 V ac soldering iron.
I started to make some research and I designed a few steps of the soldering station. I will use a 24Vac/100VA toroidal transformer. I will use a 24V/50W soldering iron with K type thermocouple. For the thermocouple I will use a LM358 amplifier. Please have a look at the attached schematic and code. The code is not ready yet and I need some help in making the connection between the PID library and output in the code. The voltage on the soldering iron looks like: https://ibb.co/CMF1gQ0 If I rotate the pot, nothing happens on the screen of the scope.
I wrote a few lines of code but I don't know how to make the connection between the PID library functions and the interruption function and the other variables in my code.
Please have a look at the code and at the schematic and tell me what you think... I am waiting for your help.
#include <PID_v1.h>
int AC_LOAD = 1; // Output to Opto Triac pin
double set_value = 0;
double input = 0;
double output = 0;
PID aaa_PID(&input, &output, &set_value, 1, 0.05, 0.25, DIRECT);
void setup()
{
aaa_PID.SetOutputLimits(0, 128);
aaa_PID.SetMode(AUTOMATIC);
pinMode(AC_LOAD, OUTPUT);// Set AC Load pin as output
attachInterrupt(0, zero_crosss_int, RISING); // Choose the zero cross interrupt # from the table above
}
//the interrupt function must take no parameters and return nothing
void zero_crosss_int() //function to be fired at the zero crossing to dim the light
{
// Firing angle calculation : 1 full 50Hz wave =1/50=20ms
// Every zerocrossing thus: (50Hz)-> 10ms (1/2 Cycle)
// For 60Hz => 8.33ms (10.000/120)
// 10ms=10000us
// (10000us - 10us) / 128 = 75 (Approx) For 60Hz =>65
int dimtime = (75*output); // For 60Hz =>65
delayMicroseconds(dimtime); // Wait till firing the TRIAC
digitalWrite(AC_LOAD, HIGH); // Fire the TRIAC
delayMicroseconds(10); // triac On propogation delay (for 60Hz use 8.33)
digitalWrite(AC_LOAD, LOW); // No longer trigger the TRIAC (the next zero crossing will swith it off) TRIAC
}
void loop() {
int set_point = analogRead(A1);
set_point = map(set_point, 0, 1023, 150, 400);
int in = analogRead(A0);
input = map(in, 0, 550, 25, 400);
set_value = set_point;
aaa_PID.Compute();
}
myPID.Compute()
, since you can get garbled data in your interrupt, when it happens while theOutput
variable gets assigned. What exactly is your problem with the code?Input
. The additional analogRead in the new code is meaningless (you don't use the value anywhere)