I have an electromagnet (turned off) with an iron core in front of a permanent magnet. At this stage they attract each other. Will any current do if I want them to repel each other, or is there a formula for calculating how much current is required to set the polarity of the electromagnet?
closed as unclear what you're asking by Bence Kaulics, PeterJ, rdtsc, uint128_t, Dmitry Grigoryev Jun 20 '16 at 9:19
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
Not just any current will do to make them repel. The current must be larger than a certain minimum.
As you have correctly noticed, the core and the permanent magnet (PM) are attracted when the current is zero. This means the field from the PM is creating a field in the iron core.
As you increase the current slightly above zero, in opposition to the PM, there will still be sufficient field strength from the PM to magnetise the iron core, just weaker than before. The core and PM will still be attracted.
As you increase the current further, at some point the magnetic field from the coils will exactly oppose that of the PM, and drive the core's field down to zero.
Further increases in the coil current will now magnetise the core in opposition to the PM, which will be repelled.
While there is a formula that is able to calculate how much current is needed to oppose the field of the PM, it not only involves the strength of the PM, but also the spacing to the core, and the geometry of the air space between the core and the PM. Calculating from first principles would be so intractable that the simplest route would be to hang the PM from a string, and measure its deflection as you change the current.