I connected a small magnet (5V, 0,7A) to the Motor 1 control port on my Baby O.
Here’s the code I’m using:
#define F_CPU 20000000
int motorSpeed = 255; // Voltage on max.
set_m1_speed(motorSpeed); // Set voltage on M1
_delay_ms(1000); // Wait 1 sec.
motorSpeed = 0; // Voltage 0
set_m1_speed(motorSpeed); // Set voltage on M1
_delay_ms(4000); // Wait 4 sec.
This is working, but the problem is that the magnet gets quickly very hot.
I guess this is because of the (high) frequency this motor port uses.
How can I change the frequency of this motor port?
When you call set_m1_speed with an argument of 255 you are just turning the motor driver on at 100% duty cycle, so that magnet will just see a steady voltage. The PWM frequency should have no effect on the magnet.
The Baby O is powered by a LiPo batterie of 7.2V, that freshly loaded can have up to 7.8V. I know that the batterie’s voltage is going directly to this M1 port. I have used this batterie with the same magnet before, but I was sure that the magnet did’nt get so hot so quickly. That is offcourse just an observation, I haven’t measured temperatures or times.
I use this to high voltage to make the magnet just a littlebit stronger. This overload is possible in my application because the magnet is on average a few seconds on and more then 10 seconds of.
If the frequency has no influence then I guess that it is what it is…
I think the PWM duty cycle should impact how strongly the magnet is on. The PWM rate, however, should not do much, unless you crank it way up to where the inductance of the magnet is a real problem – 30 kHz, say. (Guessing about the magnet inductance here – you can do the math yourself if you can look up the data sheet for it.)
I don’t know the PWM rate of this M1 motordriver, can’t find it anywhere in the documentation.
I call 255 to get the strongest possible pull of the magnet, as the voltage of the batterie drops, the force of the magnet drops as well. If the voltage drops to much the magnet force gets to weak and it’s function fails.
The strength of the magnetic field produced by an electromagnet is determined by the current passing through the wire and number of turns of wire in the winding. If the magnet is overheating, then the current is exceeding the design limitations of the magnet, due to the applied voltage being too high. This limitation is a result of the wire size (small wire diameter = high ohmic resistance = high heat generation) used in the magnet winding.
If you cannot find suitable operating conditions for this particular magnet, then you have no choice but to get a magnet that uses larger wire diameter. It may also need more turns of wire to generate the required magnetic field.
The PWM rate comes from the microcontroller, not the motor controller. If it uses Arduino standard timers, then the PWM rate is about 490 Hz AFAICT – a totally safe frequency for most controllers, coils, motors and inductors.
I copy what’s said above: Run the magnet as hard as you can without exceeding rated temperatures. If that’s not enough, get a bigger magnet (and battery.)
I’ve been using this magnet for a while under the circumstances I mentioned before and it’s still alive… So I guess I have to agree with David.
The magnet is running in a constant oil flow, which offcourse helps to cool the magnet down.
I understand that in a perfect situation this magnet should not be overloaded, but there is no space for a bigger magnet, so I have to work with what I have and try to get the maximum out of it.
So this takes me back to my original question…, this 10 kHz has no influence on heating up the magnet in any way? It wouldn’t change a thing if this pwm rate was lowered?
First, as David already said, the PWM frequency is irrelevant if you are using a speed of 255 (100% duty cycle) as in the code from your original post.
Second, there aren’t going to be any switching-related losses within the magnet, so using a higher frequency isn’t going to generate any extra heat that way. All of the heat is coming from resistive losses:
Power dissipated = I²R
where I is the current and R is the resistance of the magnet coil.
Using a different PWM frequency might affect I (it’s potentially a complicated system with inductance, capacitance, and resistance all playing a role), which in turn would affect the heat produced, but at the same time you should note that the magnetic field is directly proportional to I. Therefore, if you do manage to get the magnet to run cooler, it’s because you are effectively lowering the current, which in turn is making the magnet weaker. The good news is that the heat drops off much faster than the magnet strength does since heat is proportional to the square of the current while the magnet strength is proportional to the current itself, so you might be able to make it a lot cooler by making it a little weaker.
10khz would matter to a limited extent in certain situations. With a motor especially, which is a big inductor, it matters very little.
“I was using the motor before in same situation and it was not getting hot.”
The situation was not the same, if it it is acting different. I advise you try to determine what has changed in your system.
Is your motor doing something different? For example, if the motor was connected to a wheel, if the new wheel is bigger, then the motor does more work with the same code. There are a number of small variables, like this. If you are switching direction more frequently now, the motor is also under more load.
One more big variable. Do you have an axial load on the micromotor? If you do, the gears could be binding, and your motor would have trouble moving.