Arduino current draw problem (when switched OFF)

Hello,

I am facing the following problem - I have an electric bike with 48V power source, which has 12V DC-DC converter to which the Arduino board is connected for power source (trough pins at the board - GND and Vin). It works OK.

When the bike is powered on there is a hall sensor signal that switches between 0V and 4.5V on wheel rotation. The motor rotates trough a push of the throttle.

The GND is common for all the devices (bike's, DC-DC converter, arduino).

The problem happens in the following case:

  • the signal of the hall sensor is connected to the A0 analog input for monitoring
  • the Arduino is switched OFF
    In this case for some reason the voltage of the hall sensor signal drops to 1.35V, and Arduino draws 1.5mA which makes the hall sensor unusable and the electric motor doesn't rotate.

Note, that everything is OK when the Arduino is switched ON (the voltage of the monitored wire doesn't drop)

Why this happens (I expected that when the Arduino board is OFF it will not draw electricity of the wires that are connected for monitoring). Can I prevent this somehow?

Thank you in advance.

You have voltages on the inputs while there is no supply voltage?

It is very bad thing to put voltages in the inputs or outputs while the power supply is off. That is, the chip could break. There are over voltage protectors on every pin usually, they start to conduct when your input has a larger voltage, 4.5V, than your power supply, 0V. That loads the input voltage. In a way you are trying to use the input voltage as a supply voltage.

Thank you for the answer!
I thought there is protection in the Arduino board so when it is switched off, the attached wires to the input pins are cut (so if there is current, it will not affect it in any way)...
As this is not the case, is there somewhere info on how to do it the right way. I guess by adding a transistor working as a switch before the input pin would do the job - i.e. if the the Arduino is powered, the transistor would pass the signal (w/o any change) to the input port; if there is no power in the Arduino, the transistor would cut the connection so the current at the signal wire (which can't be switched of while the Arduino board is off) wouldn't affect the Arduino board as well the current itself (as it drops now from 4.5 to 1.3Volts)...

Having power in one part of a system while one part does not have power, is a problem. Transistors as switches have a small voltage loss, fets may be better.
Arduino, like Arduino Mega, has solved this with two resistors between USB coprocessor and the main processor. You can try a resistor too. There will be some current leakage, but hopefully not too much. In my opinion the resistors are not an "elegant" solution, but I can't think anything better either.

MP3test:
I thought there is protection in the Arduino board so when it is switched off, the attached wires to the input pins are cut (so if there is current, it will not affect it in any way)…

Well, yes and no.

The problem is known as “back powering.” Current is finding a path through the I/O pin. Very common to see this on the Analog Inputs, not as much on the Digital.

Another common application I see this pop-up is when people use an analog input and a voltage divider to measure a battery’s voltage. The path allows back powering.

As you suggest, a transistor can be used to act as a switch, which is what I recommend in those battery monitoring applications as well. The downside is you lose another I/O pin to control the transistor’s state.

MP3test:
wouldn’t affect the Arduino board as well the current itself (as it drops now from 4.5 to 1.3Volts)…

I don’t understand this question. You ask if it will affect the current then refer to voltage. Current and Voltage are very different aspects of electricity.

In short, yes, you’ll see a small voltage drop across the transistor. However, certainly not enough to alter the readings coming from a device like a hall effect.

LMI:
Arduino, like Arduino Mega, has solved this with two resistors between USB coprocessor and the main processor.

Those resistors have nothing in common with this partial power. They are there to isolate the USB chip from the AVR, in case the user wants to use the TX/RX pins for something else.

Thank you for the answer. Yeas I mean "voltage" above, sorry.

Isn't it a good idea to use an optocoupler for this protection? The hall sensor's current will light the diode (which I guess consumes minimal power and so will not affect the hall's sensor circuity), and the internal transistor will work only if Arduino is powered - it will be connected to it's +5V. That way no additional pins will be used and Arduino will be safe.

And yes, I plan to monitor the voltage but I don't see how the above can help me in that case - the above idea can protect only discreet values (high-low). So for the voltmeter case the protection should cut the power with the transistor method.

P.S. As this seems to be a common problem, aren't there something prebuild for these needs?

P.S. As this seems to be a common problem, aren't there something prebuild for these needs?

analog switch.

There are analog optocouplers. Google “analog optocouplers” so you will see. Resistor works there too, it takes a little current but so does an optocouplers. What is the frequency of your hall voltage, you could use a capacitor?

When the hall sensor is with high level, actually it is 0-4.5V at 2550 Hz. May be this is needed by the motor controller who knows.

But I imagined I can do this at software level - I will just ignore the fast ticks that are quicker than 1/2000 seconds as the wheel can't rotate so fast and the hall sensor to pass from magnet to magnet for less than 1/2000 seconds.

So only the problem with back current has to be solved. Yes, I think i will use an optocoupler, just I have to chose the right one and to see what resistors will be needed around it for the specific voltages. As I have zero knowledge of electronics I'll try to find if someone else solved the problem already, or I will have to educate myself first in electronics :slight_smile:

I have fixed all the problems (the oscilating 4.5V siganl from the hall sensor) and the problem with back current going into arduino when arduino is switched off by adding a 100K resistor at the wire which goes to arduino.

Do you think this is sufficient? Should I increase the 100K resistor to assure that no current will go trough arduino's input port when arduino is switched off, but the hall sensor is sending 4.5 Volts?

Do you think this is sufficient? Should I increase the 100K resistor to assure that no current will go trough arduino’s input port when arduino is switched off, but the hall sensor is sending 4.5 Volts?

You could try using the 100K as a pullup or define your input(s) using INPUT_PULLUP, then use a diode connected like this:

[color=teal]
                                5v
                                 |
                               100k
                                 |
CONTROLLER OUT ---------[b]|[/b]<|------•------ A0/INT0 ARDUINO[/color]

OR with INPUT_PULLUP:

[color=teal]CONTROLLER OUT ---------[b]|[/b]<|------------- A0/INT0 ARDUINO[/color]

MP3test:
I have fixed all the problems (the oscilating 4.5V siganl from the hall sensor) and the problem with back current going into arduino when arduino is switched off by adding a 100K resistor at the wire which goes to arduino.

I think this is good. To be absolutely 100% sure you should see AVR data sheet. There should be something about latch up and inputs. But I think this 0-45uA is not harmful.