successive approximation Algorithm

The Successive Approximation Algorithm, also known as the Successive Approximation Register (SAR) Algorithm, is a widely used method for analog-to-digital conversion (ADC). This algorithm offers an efficient and accurate way to convert continuous analog signals into discrete digital values, which are essential for various applications in digital signal processing, communications, and control systems. The SAR algorithm relies on a binary search approach to determine the digital representation of the input analog signal, iteratively narrowing down the range of possible values until the desired resolution is achieved. In the successive approximation process, the algorithm starts with the most significant bit (MSB) and compares the input analog signal to the midpoint of the full-scale range. If the input signal is greater than the midpoint, the MSB is set to 1, and if it is lower, the MSB is set to 0. The algorithm then moves on to the next significant bit and repeats the comparison process, updating the range based on the determined value of the previous bit. This iterative process continues for all the bits in the digital representation. Once the least significant bit (LSB) has been determined, the algorithm converges to the final digital value that best approximates the input analog signal. The SAR algorithm is known for its simplicity, speed, and relatively low power consumption, making it an attractive choice for various ADC applications.
#include <conio.h>
#include <iostream.h>
#include <math.h>
float eq(float y)
{
	return ((3 * y) - (cos(y)) - 2);
}
float eqd(float y)
{
	return ((0.5) * ((cos(y)) + 2));
}

void main()
{
	float y, x1, x2, x3, sum, s, a, f1, f2, gd;
	int i, n;

	clrscr();
	for (i = 0; i < 10; i++)
	{
		sum = eq(y);
		cout << "value of equation at " << i << " " << sum << "\n";
		y++;
	}
	cout << "enter the x1->";
	cin >> x1;
	cout << "enter the no iteration to perform->\n";
	cin >> n;

	for (i = 0; i <= n; i++)
	{
		x2 = eqd(x1);
		cout << "\nenter the x2->" << x2;
		x1 = x2;
	}
	getch();
}

LANGUAGE:

DARK MODE: