What does the ं diacritic do?
I'm a bit confused as to what this actually does. I've read that it's used to show an 'n' sound, like in हिंदी , but I've also read that it can make the vowel nasal or be pronounced like 'm' or 'ng'. How do you know when it does what?
There are three similar diacritics in hindi that are easy to confuse: ं, ँ and ॅ.
ं is usually just a short 'n', and you often see it used interchangeably as such: हिंदी/हिन्दी are both acceptable, or ज़िंदगी/ज़िन्दगी. It doesn't necessarily have to be nasal, but it will sometimes happen naturally after certain vowels (like बैंक, हैं or थीं, it's hard to say them without the ं getting a little nasal). Sometimes it can also be a short m, as vinay92 pointed out (लम्बा, लंबा).
ँ is a nasal 'm' sound, and can be found in ॐ (Om, which is a stylized ऊँ). But it gets a little fuzzy, and sometimes you hear it switched for ं in spoken hindi.
ॅ is the rarest, but does show up sometimes in words like कॉफ़ी (coffee). It's a nasal 'aw' sound from what I gather.
Anyway, the three are often interchanged, and especially with transliterated hindi the rules seem to be pretty arbitrary. I wouldn't get too hung up on it. It's really quite minor and if you're not sure how to pronounce it just go for a nasal 'n' as that's the safest bet and will be understood. Hope that helps :)
The pronunciation of this diacritic comes with a lot of rules and many exceptions. So, I'll try to keep this simple. Of course, the best way to familiarise yourself with the pronunciation is just to listen to a lot of words.
Refer to this image of Devanagari consonants (http://rahulvats.info/blogs/media/blogs/sanskrit/sanskrit_cons.gif) Notice how the letters are arranged in a table such that the last consonant in the first five rows end has a nasal sound. Think of each row forming a family of letters. (You can forget about the very last letter because it is not used in Hindi and include 'ha' with the previous row).
Now, in cases where ं(anusvaar) appears in the middle of the word, the pronunciation is guided by the consonant that follows it. If that consonant belongs to the first five rows, pronounce it like the nasal consonant of that family. For example in हिंदी, the anusvaar is followed by द. Since the nasal in द's family is न, you would pronounce it with an 'n' sound. Similarly, in लंबा(tall), you would pronounce it with an 'm' sound because म is the nasal in ब's family. You will sometimes see the above two words written as हिन्दी and लम्बा to reflect the pronunciation.
It is a little more tricky if the consonant after the anusvaar belongs to the next two rows, but you can take it to indicate nasalisation of the vowel.
If the anusvaar is at the end of the word, it can either be pronounced with an 'm' sound or nasalisation depending on the word. In Hindi, in many instances where nasalisation is required, the ं is replaced with the ँ diacritic- the 'anunaasika' but they are sometimes used interchangably.
ं (Anuswaar) is used for writing consonant clusters of the form "NC" where "N" is a nasal consonant, represented by ं, and "C" is a (non-nasal) consonant.
But Hindi has five* nasal consonants, so how would you know how to pronounce the diacritic? Well, that's where knowing the articulation of "C" becomes helpful. If C is one of the velar consonants (क, ख, ग, घ), the diacritic is pronounced as the corresponding, velar nasal: ङ; if C is a palato-alveolar consonant (च, छ, ज, झ), you pronounce the diacritic as a palato-alveolar nasal: ञ, and so on.
Another way of looking at it is that the anuswaar is pronounced in such a way that there is minimal tongue movement during the pronunciation of it and the next consonant.
Let me know if that helped.
*There are indeed five symbols representing nasal consonants: ङ (velar), ञ (palato-alveolar), ण (retroflex), न, and म (bilabial), but the fourth one is pronounced as a dental nasal ([n̪]) when occurring in consonant clusters and as an alveolar nasal ([n]) otherwise i.e. the two sounds follow complementary distribution.
हिंदी/हिन्दी ~ /hin̪d̪i:/
नदी ~ /nʌd̪i:/
वन ~ /ʋʌn/