How to get from Madrid airport to puerta del sol
There is no direct connection. You can take one of the express buses to some place near or to Atocha train station, but I prefer taking the Metro, it is two transfers, but depending where you are going, there may be simpler options.
I'll give you the least expensive: the metro if you don't have too much to look after or carry
Google maps has the directions:
https://goo.gl/maps/TCJerZAhLq52
If there are two or more of you and/or you have significant luggage Uber works well as do taxis. Expensive compared to the Metro but convenient.
The Cercanias (suburban trains) is better from the airport than the metro, not so crowded and fewer stops so it's faster, though the trains run less frequently. There are a couple transfer points (see this map), Charmatin is probably best. At Sol (the stop may be called Vodaphone Sol or just Sol), from the Cercanias platform there's an elevator up to street level. If you take the metro (one level higher), you'll have to walk up one flight of stairs.
If you do want to take a taxi, it has a fixed rate from the airport to Puerta del Sol of €30, for up to four passengers, and no tipping is needed beyond this.
If you want to see train or metro options, here's the airport's official website: http://www.aena.es/en/madrid-barajas-airport/public-transport.html