In my project, I am connecting motor controller(connected with 2 9v DC motor) and Arduino Uno (connected through Vin) in parallel with a 12v DC source. As my motor spins, I want to capture the encoder information via the Serial port using the USB cable.
I know that I can power Arduino using the USB cable as well - so I am wondering if my approach would result in connecting two power supply to my circuit - and is it safe?
Also, I know that the interconnected components in a circuit need to share a common ground - wouldn't power via Vin and attaching USB - simultaneously - means having two grounds in a same circuit? That does not sound safe.
Please let me know if you need to see how I am connecting my components.
On a UNO (bad choice of Arduino for a practical project, Nano is more versatile), it is safe to power via Vin and USB. The switching circuit in the UNO will use the supply from the regulator instead of USB to power the 5 V line.
Note however that the internal regulator is not adequate to power anything else with 5 V so I do not know about that motor controller. Also that the regulator may not be rated for input voltages exceeding 12 V.
Having the grounds of two alternate power sources connected together is not a problem unless there is any reason for there to be a voltage difference between those two grounds such as if one "ground" is actually connected to the non-ground output of another power supply.
Paul__B:
Note however that the internal regulator is not adequate to power anything else with 5 V so I do not know about that motor controller.
I am sorry - I am not sure if I understood it right. Motor Driver and Arduino Uno are connected in parallel with 12v DC source. I am powering Arduino Uno through Vin. The only loads connected on Arduino are - two encoders connected in parallel on 3.3v pin(one encoder from each motor) and one MPU 6050 IMU device on the 5v pin. Does my setup still work?
Did you mean, if I am trying to power anything that requires > 5v or over >25mA of current - the internal voltage regulator would heat up?
Also, I was wondering why you said Nano is a better choice? From a quick glimpse Uno and Nano appear to be very similar and the pin in terms of their capability and features are not very different. I was leaning towards Mega since it has larger number of interrupts which I need - 4 interrupts for 2 hall effect sensors from 2 motors. So, what makes Nano more versatile?
The Nano is a more useful form factor. The UNO and Mega 2560 have sockets which mate with "shields" but are difficult to connect individual wires. If you are connecting wires, you need to insert pin headers into the sockets and solder to the pin headers.
quazirfan:
Did you mean, if I am trying to power anything that requires > 5v or over >25mA of current - the internal voltage regulator would heat up?
Always a concern.
I cannot comment precisely on the suitability of the internal regulator without having full details of the motor driver and all other parts, but I advise using a separate switchmode "buck" regulator to provide 5 V.