fast diode ?

Hi guys,

I tried to make magnetic levitation project from here :
http://www.reidb.net/MagLevitator.html

But it just does not work. the PID doesn't get stable, I suspect it is because of the following problem :

Make sure it's a fast switching diode like a Schottky. My standard N4007s were too slow and ended up causing instability that took weeks to track down

Unfortunatly I have only N4007s diode :frowning:

Can someone suggest a fast diode, I found this one which is Schottky but I can't find in the datasheets the speed:
https://www.aliexpress.com/item/10PCS-Lot-New-Original-1N5822-IN5822-Schottky-Diode-3A-40V-DIP-Wholesale-Electronic/32493170677.html?spm=2114.30010308.3.32.SSZCyw&ws_ab_test=searchweb0_0,searchweb201602_3_10065_10068_10000032_119_10000025_10000029_430_10000028_10060_10062_10056_10055_10000062_10054_10059_10099_10000022_10000012_10103_10000015_10102_10096_10000018_10000019_10000056_10000059_10052_10053_10107_10050_10106_10051_10000053_10000007_10000050_10084_10118_10083_10000047_10080_10082_10081_10110_10111_10112_10113_10114_10115_10037_10000041_10000044_10078_10079_10077_10000038_429_10073_10000035_10121,searchweb201603_2,afswitch_3_afChannel,single_sort_1_total_tranpro_desc&btsid=c38591c2-fbe2-4e37-a061-cd51a350fa61

Thanks

google schotty diodes... you'll get loads.

Allan

I googled, but there are so many. The link I gave points to one. but I don't know if it is good

but I don't know if it is good

So look at the data sheet for switching speed. Compare that with your 1N4007.

The diode is the last thing I would suspect.

More likely, you have not correctly chosen the PID parameters. Look up "PID tuning".

Grumpy_Mike:
So look at the data sheet for switching speed. Compare that with your 1N4007.

Did you read my question ? I specifically wrote :
I found this one which is Schottky but I can't find in the datasheets the speed

More over, I can't find the speed in any of the 5817-5822 diodes.
The datasheets does not contain speed data.

The datasheets does not contain speed data.

Then it is not a data sheet or you are not reading it correctly. Try posting a link to one.

D

jremington:
The diode is the last thing I would suspect.

From the page he linked:

D2 -- Make sure it's a fast switching diode like a Schottky. My standard N4007s were too slow and ended up causing instability that took weeks to track down. It looks pointless in this diagram, being wired in reverse, but it's actually used to short out back-EMF from the coil when turned off. Otherwise, you get very short high voltage spikes back into your circuit, potentially blowing the MOSFET or at least giving you false readings and crashes on the Arduino.

Look for diodes that specifically mention (in the datasheet) fast switching speed, or advertise their being suitable for switch mode power supplies or DC-DC converters (that's the dominant application for high speed schottky diodes).

jremington:
The diode is the last thing I would suspect.

More likely, you have not correctly chosen the PID parameters. Look up "PID tuning".

I did the PID tuning more then 10 hours, I did it after reading a lot about it.
Believe me, the last thing I want to blame is a diode, but I did all I could regarding the tuning, it just not stable.

As you can see in the post I've linked to, the guy that did the project had the same problem with my diode, so I guess it is my best shot.

Link to a datasheet :
http://www.st.com/resource/en/datasheet/1n5822.pdf

I looked over the code, and it is an absolute mess. Comments like the following suggest that it should just be thrown out completely and start over. On the web, you sometimes do get what you pay for!

//This seems pointless, but is used to deal with overflow in millis()'s output when downcast. If it overflows while in idle mode, it would stick in filter waiting for millis to go all the way back up to the last calculated point.
    //This slows down the change in the electromagnet, making the device substantially quieter but taking a lot longer to stabilize (on the order of 30 seconds)

If the code can take a second, (leave alone 30 seconds) to stabilize, I assure you that the diode is not the problem.

For PID to work properly, it is very important that the control loop timing is constant. That is not the case with this code, so it is hopeless.

I wrote my own code before even looking at his. It was not stable.
Then I tested his code and got the same result :frowning:

Lets assume for a second that my code is ok. and more over lets assume his code is ok because it does work for him.

The code changes the output 1000 times per second, maybe :

  1. The diode not fast enough - I used 4007N
  2. the mosfet is not fast enough - I used Mosfet transistors [IRF520],
  3. the coil does not respond fast enough. - i used the following : https://www.aliexpress.com/item/P20-15-Holding-Electric-Magnet-Lifting-2-5KG-Solenoid-Electromagnet-DC-6V-12V-24V/32443244508.html?spm=2114.13010608.0.0.W5TQax

Under the assumption that the guy is not lying, if he says he had problem with the diode, I believe him

The datasheets does not contain speed data.

It says:-

dV/dt
Critical rate of rise of reverse voltage
10000
V/μs

Hi,
If you are working at lower than 1MHz, I would say any SCHOTTKY diode with the appropriate V and I parameters will be better than the 1N4007.

Tom... :slight_smile:

jremington:
The diode is the last thing I would suspect.

I see no reference to how the circuit board is laid out

I see no reference to how the circuit board is laid out

My comment has nothing to do with the circuit board layout; rather the fault clearly lies in the essentially unworkable implementation of the PID algorithm.

The code changes the output 1000 times per second, maybe

In one millisecond, an object at rest falls D = (1/2)at^2 = 0.59.810^-6 = 4.9 micrometers (about .005 millimeters). Therefore it is not necessary for the loop to execute that rapidly, or to switch the magnet that rapidly.

See if you can find a copy of Circuit Cellar #18 (Dec. 1990). Jeff Bachiochi gave complete plans for a perfectly functional magnetic levitation apparatus that was programmed in about a dozen lines of BASIC.

How fast can a magnetic field capable of levitating whatever it's supposed to change? They don't collapse instantly.

The time constant for the collapse of the electromagnetic field associated with a shorted inductor is L/R = (coil inductance)/(coil resistance).

Hi guys,

Thank you for your answers.
jremington calculation about speed led me to believe that i can reduce the refresh rate drastically, even in a speed of 1cm per second.
A rate of 100 times per second should be enough because it will move roughly 0.1mm on every cycle.

How can I know the "L" of the magnet ?
I'm using the following :
https://www.aliexpress.com/item/P20-15-Holding-Electric-Magnet-Lifting-2-5KG-Solenoid-Electromagnet-DC-6V-12V-24V/32443244508.html?spm=2114.13010608.0.0.W5TQax

It is a 12V 0.25A magnet. (meaning the resistance is : 48ohms)

How can I know the "L" of the magnet ?

Measure it with an inductance meter. Some DVMs have one built in, but for best results you need to measure at the frequency you are using it at.

Update:
(Almost) Great success.

I had 2 major problems :

  1. The connection on the sensor weren't perfect. I still have problems with soldering, there are things that just don't stick to solder.

  2. I printed a serial output every half a second, That destroyed the PID totally and caused a lot of instability.

After fixing both problems and readjusting the PID values, the object floats for 1-2 minutes perfectly, but then it slowly starts to oscillate till it falls.

Any general suggestion regarding the PID ? I've set the
P to 4.7
D to 4.6
I to 0 - pretty useless, couldn't get any improvement by changing it, only increases the oscillation