Triac-based phase control of the mains power into resistive load.
According to this post,
RMS voltage can be calculated as:
Vrms = Vpeak * sqr((2*pi - 2*angle + sin(2*angle)) / 4*pi)
I need the inverse of this. I need to solve this for angle
.
I need to find the angle required to produce a required power level (specified as a fraction of 0.0 to 1.0 of full power).
While I can find the value of the angle by brute force, using the equation above, it would be better to have an equation that calculates the angle directly. My math is too rusty though.
Keywords: phase-fired controller, phase angle control.
--------------------------------------
C++ code, based on math done by Harry Svensson below.
#include <iostream>
#include <cmath>
#define pi 3.1415926535
using namespace std;
float f(float power, float alpha){
return 2 * pi - 2 * alpha + sin(2 * alpha) - 4 * pi*pow(sqrtf(power) / sqrtf(2), 2);
//calculate f
}
float df(float alpha){
return 2 * cos(2 * alpha) - 2;
//calculate the derivative of f
}
float calc_alpha(float power){
float alpha = 0.5;
//starting point = 0.5
float d, oldD = 1000.0
bool again = true;
while (again) {
for (int i = 0; i < 20; ++i){
d = f(power, alpha) / df(alpha);
if (abs(d) > abs(oldD)) {
// the equation is diverging; the starting point was bad;
alpha = (rand() % 3000) * 0.001 + 0.005;
oldD = 1000.0;
break;
}
oldD = d;
alpha = alpha - d;
if ((d<0.001) && (d>-0.001)){ return alpha; }
if (i == 19) again = false;
}
}
return alpha;
}
float calculatePower(float alpha){
return (2 * pi - 2 * alpha + sin(2 * alpha)) / (4 * pi) * 2;
}
int main(){
for (int i = 0; i < 180; i += 5){
float alpha = i / 180.0 * pi;
float power = calculatePower(alpha);
float calculatedAlpha = calc_alpha(power);
cout << alpha << "\t" << power << "\t" << calculatedAlpha << "\n";
}
cout << "Press any key to finish.";
cin.get();
return 0;
}