You need to first calculate all your updates as if the wieghts weren't shared, but just store them, don't actually do any updating yet. 

Let $w_k$ be some weight that appears at locations $I_k = \{(i,j) \colon w_{i,j} = w_k\}$ in your network and $\Delta w_{i,j} = -\eta \frac{\partial J}{\partial w_{i,j}} $ where $\eta$ is the learning rate and $J$ is your objective function. Note that at this point if you didn't have weight sharing you would just upade $w_{i,j}$ as 
$$
    w_{i,j} = w_{i,j} + \Delta w_{i,j}.
$$
To deal with the shared weights you need to sum up all the individual updates. So set 
$$
    \Delta w_k = \sum_{(i,j) \in I_k} \Delta w_{i,j}
$$
and then update 
$$
    w_k = w_k + \Delta w_k.
$$