I am using an Arduino Mega 2560 to control 170 PIN diodes.
For that, I am using 22 shift registers type 74hc595n. Each DataPin of these 22 shift registers is connected to one output pin of the Arduino MEGA. The latchPin and ClockPin of all the Shift Registers are connected to Arduino Pins 9 and 8 respectively.
Each of the 8 Shift Register output pins needs to output 10 mA of current.
As you may already know, for the shift registers to work, they need to be fed with 5 Volts each.
Hence, my question is: Given that Arduino has a VCC output Pin that gives 5V, can I connect all 22 shift registers to this same VCC pin of the Arduino MEGA?
So that would be 80mA per shift register and you have 22 shift registers. If my maths are correct, then that's 1.76A not including the additional current requirements of the shift registers internal logic.
Looking at the schematic for the MEGA2560, it shows an LD1117S50CTR as the 5V regulator, which according to the ST datasheet, is limited to around 800mA.
You should definitely look for an alternate 5V supply as the onboard one can't supply that amount of current.
Maximum current through Vcc ir GND of the 74HC595 is 70 mA; so you can't use 8x10 mA at the same time.
The 800 mA mentioned above applies if one has proper cooling; on the Mega that's not the case. It's also only applicable when using an external power source on Vin or barrel; the USB current is limited to 500 mA. So you need a dedicated 5V power supply just for the 74HC595s.