📜 ⬆️ ⬇️

The Bresenham algorithm in a soldering furnace - theory

The Bresenham algorithm is one of the oldest algorithms in computer graphics. It would seem, how can you apply the algorithm for constructing raster lines when creating a home soldering furnace? It turns out you can, and with a very decent result. Looking ahead, I will say that this algorithm is very well fed by a low-power 8-bit microcontroller. But first things first.

The Bresenham algorithm is an algorithm that determines which points of a two-dimensional raster need to be colored in order to get a close approximation of a straight line between two given points. The essence of the algorithm is to determine for each column X (see figure) which row Y is closest to the line and draw a point.

Now let's see how a similar algorithm will help us in the management of heating elements in an electric furnace.

TEN is powered from mains voltage 220V / 50Hz. Take a look at the chart.
')

When applying such a voltage in its pure form to the input of the electric heater, we get 100% of the heating power at the output. It's simple.


What will happen if you apply only a positive half-wave of the mains voltage to the TEN input? That's right, we get 50% of the heating output.


If you submit every third half-wave, we get 33% power.

As an example, take a 10% gradation of the output power and a time interval of 100ms, which is equivalent to 10 half-waves of the mains voltage. Draw a 10x10 grid and imagine that the Y axis is the axis of the output power values. Let's draw a straight line from 0 to the required power value.



Are you tracking addiction?
Increasing the time interval to 1 second, you can get a gradation of the output power of 1%. The result is a 100x100 grid with all the consequences.

And now about the pleasant:
The Bresenham algorithm can be built in a loop so that at each step along the X axis, it is easy to track the error value, which means the vertical distance between the current value of y and the exact value of y for the current x . Whenever we increase x , we increase the error value by the amount of slope. If the error has exceeded 0.5, the line is closer to the next y , so we increase y by one (read - we miss one half-wave of voltage), while reducing the error value by 1.

This approach can easily be reduced to cyclic integer addition (more on this later, when describing the algorithm of operation of the MC in the next article), which is a definite plus for microcontrollers.

I intentionally did not load you with formulas. The algorithm is elementary, easily googled. I just want to show its ability to use in circuitry. To control the load, a typical connection circuit of a MOC3063 triac optocoupler with a zero detector will be used.



With this approach, there are a number of advantages.


To be continued.

Source: https://habr.com/ru/post/254719/


All Articles