[solved] Stumped! External Power Supply Inconsistencies using Nano

I've been working on a levitating magnet project using a linear hall effect sensor for feedback to the nano to turn on and off an electromagnet.

The nano and hall effect sensor use 5v and the electromagnet and mosfet circuit uses 12v supplied by a wall-wart.

The levitation "works" when the nano is plugged into the PC's USB port or when connected (5v) and powered by a Heath or BK bench power supply. It is very fussy on the 5v power supply.

I soldered up a voltage regulator using a LM7805 (with in and out caps) to supply the nano circuit that measures 5.01v out using the 12v wall-wart for the power in. This way I don't need to be tethered to a PC or bench power supply. Also, I did not want to use the nano's built-in 5v regulator because it might not dissipate the heat since it's so small and the voltage difference is large 12v to 5v. (even though the current draw is very low, maybe 20-30 mAmps) I did not measure but looking at the current gauge on the bench power supply, it looks to be in that range.

After trying the levitation, magnet would oscillate increasingly over a short time and levitate for approx. 10 - 20 seconds.

Later-on:
I measured the actual voltage from the USB port (~4.78v) and dialed in my power supply to 4.58v to achieve the smoothest levitation.

Using the PC's USB port, the levitation is a little wobbly but will levitate indefinitely if not disturbed.

Using the bench power supply, the levitation is pretty smooth and will levitate indefinitely. You can even spin the levitating magnets.

Using the LM7805, as stated above, levitation for approx. 10 - 20 seconds.

I then soldered up an LM317 (with in and out caps) to put out 4.6v (4.59v measured) to try again.
Same thing: levitation for approx. 10 - 20 seconds. Starts to oscillate out of control.

Baffled, I looked at the LM317 output on an older analog oscilloscope. Voltage looked about right and no ripple at all. I checked the output on the range of time bases down to .1 uSec and flat. I then checked my bench power supply for comparison and it looked the same through the time base ranges.

At this point I'm baffled, what am I missing? Why does the bench and USB power supply work and the LM317 not "work". I forgot to mention, the grounds are all connected between the 12v and 5v.

Any feedback would be appreciated.

Thank you.

triode90:
I've been working on a levitating magnet project using a linear hall effect sensor for feedback to the nano to turn on and off an electromagnet.

I suspect it may be due to noise being picked up by the hall sensor, varying the 5V rail slightly may be altering the levels at which your program sees a certain signal.

Does it do different things if you move the hall sensor wires about ?

Can you post your circuit and describe how your program uses the hall signal (actually posting the code as well might be useful)

Yours,
TonyWilk

It is likely that your bench supply has better decoupling capacitors than your regulator. As well as the 0.1uF ceramic on both the in and out of the regulator you need a big bulk decoupling capacitor of at least 100uF possibly bigger.

Also is the regulator getting hot? Does it need a heatsink?

Are you sure the electromagnet only uses 20-30mA? Seems quite low. How much current does the wallwart put out?

Put you VM probes on the 12V output and ground and turn it on. See if the power stays up at 12V or if it starts dropping. Same for the 5V.

How close is the magnet to the regulator?

Do you have a flyback diode across that magnet?

Thanks for all the feedback!
Yes the hall effect sensor is definitely picking up "noise" but still works with a "good" 5v power supply.
Program is:
int sensPin = A0; //hall effect sensor (0-1023)
if (analogRead(sensPin) > 230)// turn on/off magnet. I tried an analogWrite with constraint and map to vary the magnetic force but it was too slow.

I think Mike is right, I don't believe I have enough decoupling capacitor value. I had 10uF in and 10uF + .1uF out on the LM7805 and .1uF in and 1uF (electrolytic) out on the LM317. Just do not understand why the oscilloscope didn't show anything. (I removed one of the 10uF on the LM7805 when I was experimenting, pictured) I will also try a .1uF mica cap instead of the 104 ceramic.

The regulators does not even get warm. Current is ~20 to 30mA.

Three AA in series works too.

A few pictures I took just now.

triode90:
Yes the hall effect sensor is definitely picking up "noise" but still works with a "good" 5v power supply.

If it's a ratiometric sensor, the output level depends on both the magnetic field and the supply voltage.
Do you have a decoupling capacitor close to the sensor on its GND-5V ?
You could also try a 0.1uF capacitor from GND to the A0 input.

In any case, it'd be worth putting the 'scope on the sensor output while it's working and not working to see if there's a difference.

Yours,
TonyWilk

Just do not understand why the oscilloscope didn't show anything.

It is very easy to miss a small dip on a D.C. line. You need to put the scope onto AC coupling and wind up the sensitivity and carefully adjust the trigger.

Even then they are sometimes hard to catch.

Hi,
Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Tom... :slight_smile:

Thanks guys for all the advice!

Levitation is working smoothly with only the wall-wart as the main power supply.

I assembled a new LM317 with larger value caps on the in and out. .1uF + 470uF in and .1uF + 470uF out.
This really helped and almost did the trick. I was getting 3 to 15 minutes but was still oscillating and could not recover. I used 470uF because that's all I had. My next smaller value was 47uF.

TonyWilk nailed the rest! I had a 203 cap (.02uF) laying on the bench and just inserted it from GND to the A0 input and boom. Very smooth! Just as good as the bench power supply maybe better. Your getting an extra Karma when it allows me.

I included three pictures for fun:

  1. the circuit, only part is soldered. See 203 cap from GND to A0.
  2. a close-up of the LM317 on a solderless breadboard.
  3. schematic of the LM317 and calculation/math for Newbies (make sure to check the LM317 datasheet too)