# How to calculate the SNR from the data collected by ADC?

I want to design a filter to deal with periodic signals according to the actual collected data. In practice, I would like to use the SNR as the criterion to judge the performance of the filter. However, I meet a probelm about how to calculate the SNR according to a data set containing noise collected by the ADC. For example, here is a MATLAB demo to simulate the square signal with nosie collected using a 12-bit ADC:

t = 1:10000;    % length of collected data
fre = 50;       % signal frequency
fs = 20000;     % Sampling frequency
square_signal = square(2*pi*fre*t/fs);
figure(1)
plot(square_signal)
noise = randn(length(square_signal),1);    % noise
figure(2)


In practice, I only could get ad_data using the ADC, while the noise and square_signal are unknown. Besides, the ad_da are in the range of [0,4095] instead of [-1,1]. The data I actually collected using ADC is within the range of [400,1700], which is the same as as_data.

Now, what I want to do is to design the filter based on this collected data (ad_data), mainly the filter order. I use SNR to judge the filter's performance. I know how to use the noise and square_signal to calculate the SNR. However, this is not possible in what I am about to do since there is no way to get pure noise and square_signal.

So, my problem is how to calculate the SNR using the ad_data? Fox example, I'm designing a FIR filter using fir1(order,0.06). How to calculate the SNR of FIR output signal with different filter order? Besides, I also wonder whether the raw data ad_data needs to be normalized to [-1,1]? I find that the SNR calculated with the original data ad_data is much smaller from the SNR calculated with the data normalized to the range [-1, 1]. Which one is right?

You could directly use the above MATLAB demo signal as the original data to answer my questions. Thanks!