Given a brane tiling on a torus, we provide a new way to prove and generalise the recent results of Szendroi, Mozgovoy and Reineke regarding the Donaldson-Thomas theory of the moduli space of framed cyclic representations of the associated algebra. Using only a natural cancellation-type consistency condition, we show that the algebras are 3-Calabi-Yau, and calculate Donaldson-Thomas type invariants of the moduli spaces. Two new ingredients to our proofs are a grading of the algebra by the path category of the associated quiver modulo relations, and a way of assigning winding numbers to pairs of paths in the lift of the brane tiling to R^2. These ideas allow us to generalise the above results to all consistent brane tilings on K(pi,1) surfaces. We also prove a converse: no consistent brane tiling on a sphere gives rise to a 3-Calabi-Yau algebra.