I wanted to help, but do not understand what your problem is. The explanation in your post is rather short. You say something about a rectangular signal, but then you show some code, and the result is not unexpected for me. So I am to really sure what it is you want and why you think there is a problem and what you have tried. It would also help to have some figures in the post.
Do you want something like this (modified from Mathworld):
Thank you for your answer.
In the attached file, you can find the code.
I want to plot this Fourier series expansion of a periodic rectangular signal (with plot like in the commands I do). I do not know why I can not obtain my signal.
I do it with an other softwar and I attached the curve in the attached code.
Thank you again.
you are plotting a function which is complex valued, so I was wondering why one sees a plot at all! Anyway, I think all you need to do is to make sure you see your complete plot; for this you need to plot it like so:
Plot[ ... you function ..., {n,1, NN}, PlotRange -> All]