The fast AVE trains run hourly or less from Barcelona Sants to Madrid Puerta de Atocha. The ones that take 2.5 hours have NO stops. The ones that take a bit longer have a few stops.
In either case, I can't imagine the advantage to an overnight train that has at least 9 stops. You will not get any sleep with all the bumping and screeching. From the DB BAHN website, it looks like there are only couchettes. Renfe only shows pictures of seats, however it does list prices for Turista, Litera and Preferente class. From what I could find online a “litera” is a sleeping berth or bunk bed in a 4-bed compartment.
This is info on overnight train accommodations from the Man in Seat 61: http://www.seat61.com/sleepers.htm#.UzO4gvldUtE. If you are dead set on a night train, be sure to read it completely, paying particular attention to the different classes and how much they vary as to what you get regardless of price. And no, Preferente class does not automatically equal a private cabin so far as I can tell.
Like most others, I would recommend a short trip on a fast train during the day. I've taken the nonstop journey from Barcelona to Madrid and it's just plain cool to ride on a train that's going 300 kph most of the time, seeing the scenery fly by along the way.