The anchor for the gerundio is the tense of the verb in the main clause. If the verb of the main clause is in present the gerundio passato is an imperfetto / passato remoto / passato prossimo. If the verb of the main clause is in imperfetto / passato remoto / passato prossimo, the gerundio passato is to be considered a trapassato prossimo.
examples
Avendo risparmiato, poteva comprarsi una macchina.
Having spared money, he could buy a car.
(Because he had spared money, he could buy a car.)
Avendo risparmiato, può comprarsi una macchina.
Having spared money, he could buy a car.
(Because he had spared money, he could buy a car.)
If the verb is conjugated normally with essere the gerundio passato is to be formed with essere as well. The past participle must match in this case in gender and number with the subject of the gerundio, which is normally the subject of the sentence.
examples
Essendo arrivata in ritardo, non è potuta entrare.
Because she arrived to late, she couldn' t get in.
(Having arrived to late, she couldn' t get in.)
Ecco dove si può arrivare pur essendo partiti dal nulla.
That could had be attained although one started from zero.
(That could be attained having started from zero.)
examples
temporal clause
Avendo letto la lettera, l' ha chiamata.
After having read the letter, he called her.
(After he had read the letter, he called her.)
if clause
Avendo riparato la macchina, possiamo andare in vacanza.
Having repaired the car, we can go on holidays.
(If we repaire the car, we can go on holidays.)
causal clause
Essendo arrivati in ritardo, non ci lasciarono entrare.
Having arrived to late, they didn' t let us get in.
concessive clause
Pur conoscendo abbastanza bene l' Italiano non era capace di scrivere questa lettera.
Although he spoke Italian quiete well, he was not able to write a letter.