I am using an Arduino Nano 33 iot, connected with a vl6180x sensor and a stepper motor. The nano is powered by external 5V power supply, while the stepper by external 12V power supply.
I want to transfer in real time data from arduino to the PC (matlab). However: 1. if I initially connect the usb to arduino and pc and then supply the board with external powers, the board does not work, and 2. if I supply the board with external power and then connect the usb to computer, there is a strange behaviour (like the board stalls etc.)
I am thinking of cutting the Voltage wire in my usb cable. Would this be a safe connection for the board and the computer?
A picture of a hand drawn wiring diagram would help a lot.
You can probably safely remove the external 5V PSU, the TOF sensor doesn't use that much power IIRC. In any case you are correct that having both is problematic. As you suggest your approach of removing the 4VDC from the USB is the best solution.
There is more to the 5V part of the circuit that you have not described? From what you have described to us so far, no problem using the USB as 5V supply. The Arduino, the sensor and logic circuit of the stepper motor driver will not need much power. The motor will continue to take its power from 12V supply when the rest is powered from USB.
normally the circuit should be able to work autonomously, without a pc. I am connecting the pc just when I want to collect data from the circuit to pc.
The circuit operates normally when powered via the external power supply (and disconnected usb). However, connecting the USB sometimes causes the system to stall or behave unpredictably. Once the USB is connected successfully without causing a fault, the circuit continues to function as expected.
searching in the net, I believe that the problem is the dual power supply and/or the common ground across the 2 power supplies.
In such cases I use a Serial connection to standalone USB-UART module with shared grounds, but without the power line.
You also can fully avoid unwanted connection to PC by using wireless UART modules like HC-12 or JDy-40.
As I said before, the problem comes with the order of connecting the PC and powering the board:
1. If I first power the board and then connect the USB, strange things happen (even sparks some times).
2. If I connect the USB first and then power the board, the board doesn’t start. This seems to be because the Arduino gets powered from the USB, but there’s no power supply for the motor at that time—so when I flip the board’s power switch to ON, the board fails to start properly.
That’s why I’m considering cutting the USB power line. This should prevent issue (1), and once the board is powered separately, it should start normally—avoiding issue (2) as well.
The 33 Iiot does not have a power switch.
There is obvioulsy more to your set-up then you are telling us.
Perhaps if you provide a wiring diagram we can help diagnose your problem.