# Generating a sine wave from FFT bin

I have signal containing a large amount of mains noise. I'm trying to feed this back into my signal to actively cancel it from future measurements, but I'm having trouble getting it to work. I have tried taking the fft bin with the maximum mains noise, generating a sin wave of the function:

bin.real * Sin ( bin.frequency * 2 * PI * T + bin.phase)


where bin.frequency is calculated to be the mains noise at the time of measurement (~$50\textrm{ Hz}$).

When I subtract this from my original signal it still looks very noisy, albeit a different kind of noisy. If my sample rate is $250\textrm{ Hz}$, I'm thinking I need to increment T by $1/250$ to correctly generate the signal.