I use a Controllino to control a number of devices by providing them with 24V via the digital output.They have a low power usage, but high inrush current. To protect the power source against being overwhelmed by inrush current, the Controllino goes through an initialisation phase in which it turns on the connected devices one by one.
This works fine, as long as USB is not connected: When the power is cut, the Controllino turns off so that the initialisation is run every time the 24V comes on again. When USB is connected this do not work so great: as the Controllino does not shut of when the 24V power source is cut, it does not go through the initialisation phase when the power comes back on again. Consequently my device malfunctions as a result of the high inrush current.
Is there any way to force the Arduino to reset every time the 24V is connected?
wire a branch of the +24V to a digital input port (maybe even an analog one). This input port then changes to High, when the 24V becomes active, and goes Low again, when 24V is off, but power remains by USB.
Then define an event “Input switches Low->High” to run your init routine.
solution proposed by Michael seems to be the best. You will monitor this input and when input is low, you will switch OFF the peripherals and correctly switch ON again the the main power is back.
When you want to really do the hard reset, you can build some simple circuit with RC combination and transistor which will pull down the /RESET on pinheader to low for the “RC” time. But this is more tricky. I would use the solution from Michael.