The main problem with this route is that there is no easy long distance train or coach service that serves Carvoeiro. There is a local bus service that runs via Lagoa several times a day.
To drive would take:
Time: 03h41 including 03h16 on motorways
Distance: 372km including 354km on motorways
according to viamichelin.
Rail would be your best public transport option as it would be more comfortable.
Take a train to Portimão and then a taxi to Carvoeiro.
Schedule as follows:
12h52 São Martinho Do Porto
13h06 Caldas Da Rainha
13h39 Caldas Da Rainha
15h31 Mira Sintra-melecas
15h49 Mira Sintra-melecas
16h18 Lisboa - Entrecampos
17h30 Lisboa - Entrecampos
20h44 Tunes
20h58 Tunes
21h32 Portimão
Travel time: 8h40mins.
Taxi to Carvoeiro would take about 20 minutes at that time of night.