Google "PID tuning" for instructions on the general approach to choose parameters.
However the long term behavior suggests that internal heating is affecting the circuitry, which in turn suggests poor circuit design.
The original circuit you linked does not use a current limiting resistor between the output pin and the gate, which will eventually destroy the Arduino.
What are you using for the power transistor? I can't find any information on an "ST15N52U".
jremington:
Google "PID tuning" for instructions on the general approach to choose parameters.
However the long term behavior suggests that internal heating is affecting the circuitry, which in turn suggests poor circuit design.
The original circuit you linked does not use a current limiting resistor between the output pin and the gate, which will eventually destroy the Arduino.
What are you using for the power transistor? I can't find any information on an "ST15N52U".
I'm not sure it is a heat issue, it take something like 1-2 minutes for the levitating object to fall.
And then after it falls, I put it in place again, and again it holds for 1-2 minutes.
I've added 220ohm base resistor, (meaning the current is something like 20-25mA).
The transistor I'm using is the one I got with the official starter kit IRF520
I'll try to make a video of how it behaves and upload to youtube.
maybe someone more experienced (like you) we'll have an intuition of what might be the problem.
Grumpy_Mike:
I don't cair where it came from it is the wrong FET to use because it will not turn on fully with a 5V gate signal. You need a logic level FET.
jremington:
Definitely the wrong FET, and it is heating, guaranteed.
Thank you both for your answers. I'm not sure I understand the problem.
The current that my elctromagnet needs is 0.26A, the data sheet says that the transistor supports up to 9.7A, why would he heat ?
Can you explain the difference between my transistor and logic level ? "Grumpy_Mike" wrote that mine doesn't turn fully with 5V, where can I see in the data sheet what voltage he needs to turn fully ?
Because you are not turning the FET on fully. Therefore the resistance from drain to source is not as low as it could be. Therefore the current times the voltage across it gives you the heat generated and instead of this being small is large.
the data sheet says that the transistor supports up to 9.7A
You have to learn how to read data sheets. That is a headline figure that is only achieved when everything else is right, and that is not the case you have.
where can I see in the data sheet what voltage he needs to turn fully ?
It is the gate voltage quoted in the drain / source resistance - see it says 10V. The gate threshold is NOT what you want to look at. That is just the voltage when the FET starts to conduct.
Grumpy_Mike:
It is the gate voltage quoted in the drain / source resistance - see it says 10V. The gate threshold is NOT what you want to look at. That is just the voltage when the FET starts to conduct.
I have another NPN transistor, the 2N2222A.
I look at the datasheets and I can't find anywhere something the resembles this line.
Here is the datasheet:
I look at the datasheets and I can't find anywhere something the resembles this line.
That is because the 2N2222 is not a FET, it is a bipolar transistors. They work in a totally different way. A FET has a resistance between source and drain that drops to a very low level when it is turned on fully.
When a transistor is turned on fully or saturated as it is called there is a minimum voltage that can be achieved between the collector and emitter. This is known as the saturation voltage or VCE(sat). If you look at the data sheet you will see this is between 1V and 0.3V depending on the collector / emitter current. So the power dissipated by a transistor turned on is IC * Vsat or collector current times the saturation voltage. These days with modern FETs this is normally two to three orders of magnitude greater than a FET.
Do not use a transistor for switching anything over 500mA.
We're up to post 28 in this thread and I wonder if anyone else has looked at this "design". Holly crap Batman!
While the magnet appears to be less than an amp, it's is on the same supply as the Arduino! The only bypass caps are 2.2 and 470uf. These are useless for high frequency. The gate is directly connected to the Arduino output. No isolation, no series or pull down resistors.
All his hand wringing over PID and a diode. Heck, if the circuit was correct, why bother with PID? It doesn't need it, PWM would probably work for what this thing is supposed to do.