A dynamical model for the stick-slip behaviour of faults