I want to use an ATmega32 ADC in its 4 channel single-ended mode to convert four analog signals into digital (one at a time). I have written the C code but what I cannot figure out is what I should do with the ground pins of those four analog signals. Should I common them and connect to the controller ground? Also why are there two ground pins in the ATmega32 (11 and 31) - is one of them an analog signal ground?
The ground side of the incoming analog signals needs to be connected to the ground of the microcontroller.
Multiple ground pins on a microcontroller very conveniently allow greater current load to reach ground with reduced pin impedance (by paralleling): For instance, if a microcontroller can sink 40 mA per GPIO pin, and has a total current limit of say 200 mA, then if 4 or 5 of those GPIOs are sinking current at any given time, that amount of current would necessarily have to reach circuit ground through a single ground pin of the microcontroller.
Adding a second, sometimes third or fourth ground pin allows this cumulative current load to reach ground distributed through multiple pins. No one pin gets overloaded or heated up, the load gets distributed.
An added benefit of multiple ground pins is convenience in routing on tightly packed boards - ground traces do not need to wriggle between other pins to "get to the other side". While this practice of having disconnected ground traces is frowned upon, sometimes it is just the way it's done, for convenience or out of necessity.
Some microcontrollers and other ICs also have different types of ground, such as Analog Ground and Digital Ground, explicitly named as such. There the purpose is different: The Digital ground is used as the "common" pin(s) for all digital signals, while the Analog ground is the common pin(s) for all analog signals.