Go Down

Topic: Smoothing PWM for electromagnet (Read 816 times) previous topic - next topic

tlhsglm

Oct 22, 2019, 12:59 am Last Edit: Oct 22, 2019, 11:36 am by tlhsglm
Hi fellows,

I'm using an 12 volts and 35 ohms electomagnet.Using Gammon's circuit below.I've set pwm 30Hz to get a precise control(To make big duty cycle control).Because of the PWM's On/Off cycle electromagnet vibrating so much and its very noisy.I want to smooth PWM to analog so there will be no vibration.But not just for the vibration i think it will be stronger with analogue voltage.

I've searched the PWM to analog ways and i saw 3 ways;
1-With a DAC chip.I dont want this because of its low resolutions comparing to other two.
2-Rc filter
3-Lc filter

I want a good control and dont want to make it wrong.I havent an oscilloscope so im afraid to make something that works in the naked eye but actually it's wrong and will make problems by time.You know electromagnet have an impedance and resistance and they are confusing me.


My questions:

1-Which filter i have to use?Does it much matter?
2-How to determine the values of filter?For a quick reponse like 30hz?I just want to calculations
3-I will apply this filter between +12volts and electromagnet am i right?
 


My power supply for 12volt is an 1A adapter(like phone charger).And mosfet is FDS9926A Datasheet Electromagnet is 25 kg sucktion 35 ohms, maximum 12volts.



MarkT

Any reason to use such a low frequency of PWM?  The common fix for vibration is to use ultrasonic frequency.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

MorganS

The electromagnet is a giant inductor. So to make an LC circuit, you only need a C (capacitor.)

The Arduino can get "precise" 8-bit control at very high PWM frequencies. (The definition of "very" depends on which Arduino you have. Whoops, you didn't tell us which Arduino you have.) And what do you mean "precise"?

For smoothing 30Hz, you are going to need extremely large capacitors. Like 10,000uF just to get started with.
"The problem is in the code you didn't post."

Paul_KD7HB

If the problem is noise from the electromagnet, then the quickest and cheapest solution is to stop the vibration.

What is vibrating? The winding around the magnet core? The wires themselves in the electromagnet? Any of those can be solved by potting the magnet and the iron core in epoxy.

Paul

Wawa

#4
Oct 22, 2019, 05:27 am Last Edit: Oct 22, 2019, 05:28 am by Wawa
What was wrong with the default PWM frequency (pin dependent) of the Arduino.
If it squeals, then you pick a higher frequency, not a lower one.

Analogue/voltage is usually not an option, because that heats up the mosfet.
Leo..

TomGeorge

Hi,
Are you using the PWM duty cycle to adjust the electromagnet position or strength?

Can you tell us the application please?

Thanks... Tom..... :)
Everything runs on smoke, let the smoke out, it stops running....

tlhsglm

#6
Oct 22, 2019, 11:33 am Last Edit: Oct 22, 2019, 12:16 pm by tlhsglm
Kindly please dont stick to my PWM, i didnt mentioned but i want analog voltage to my electromagnet.

I have arduino uno, thus basic pwm precise is 8 bit so one voltage step is 12/256=0,046875 volts.But at lower frequencies it is much better, at 30 hz it is 12/330000=0.36x10^(-3) volts in one step.It is very huge i know and looks unnecessray but its nice for my project.i will increase voltage in future.
@Paul it is vibrating because PWM makes electromagnet on and off very quickly and thus it is sucking and stopping so it is vibrating.

@Morgans I will apply this caps + leg to +12volts and - nleg to ground am i right?Or parallel to electromagnet as diode?

@Wawa Will the heat at lethal degrees for Mosfet?Are you know a way to make this?

TomGeorge

Hi,
Can you explain how you came to these calculated results?

Quote
I have arduino uno, thus basic pwm precise is 8 bit so one voltage step is 12/256=0,046875 volts.But at lower frequencies it is much better, at 30 hz it is 12/330000=0.36x10^(-3) volts in one step.
The 30Hz calc, how many duty cycle steps do you have?

Tom... :)
Everything runs on smoke, let the smoke out, it stops running....

tlhsglm

Hi,
Can you explain how you came to these calculated results?
The 30Hz calc, how many duty cycle steps do you have?

Tom... :)
Hi Tom,

Timer1 on arduino is 30 hz intterrupt.So interrupting in every 1/30=0.033^ seconds in other words every 33333 micro seconds i have an interrupt.In interrupt i making pin high and in the loop i making pin low.A PID math adjusting the high time.like
interrupt{
 hightime=pid
pin HIGH
time=micros();
}

loop(){

if(time<hightime){
pin LOW
}

TomGeorge

Hi,
Haven't seen your code.

Tom... :)
Everything runs on smoke, let the smoke out, it stops running....

tlhsglm

Hi,
Haven't seen your code.

Tom... :)
Kindly why do you want to see it the topic not related to my code and sample is at my previous message about your question of voltage step.
Tom can you please just share your ideas about PWM smooting?

Paul__B

The electromagnet is a giant inductor. So to make an LC circuit, you only need a C (capacitor.)
Sorry, this is total rubbish.

You cannot use a capacitor to filter PWM in this application.  :smiley-eek:

In fact, the whole thread is rubbish.  The premise appears to be that by using a very slow PWM, you can make the timing increments small in proportion to the whole cycle.  Averaged over a second or so, this is quite true, but now you want it to be averaged and controllable over a smaller period which you cannot have.  The two are mutually exclusive.  Look up "Nyquist".

There is a distinct XY problem here.

tlhsglm

Sorry, this is total rubbish.

You cannot use a capacitor to filter PWM in this application.  :smiley-eek:

In fact, the whole thread is rubbish.  The premise appears to be that by using a very slow PWM, you can make the timing increments small in proportion to the whole cycle.  Averaged over a second or so, this is quite true, but now you want it to be averaged and controllable over a smaller period which you cannot have.  The two are mutually exclusive.  Look up "Nyquist".

There is a distinct XY problem here.
Sir thank you very much you hit the bullseye i was expacting an answer like this scentific clearity.
My pwm is at 30 Hz now.My limit for making it faster 250Hz pwm so will be an interrupt in every 4000 microseconds.Is it enough?

MorganS

#13
Oct 22, 2019, 06:58 pm Last Edit: Oct 23, 2019, 04:15 am by MorganS
This is like using a chainsaw to cut wood but you didn't put fuel in it. Yes it can cut, but extremely badly.

If you need better PWM resolution than 8 bit then you should be using one of the 16-bit timers to produce the PWM.  Your don't need to write any code at all in loop() or an interrupt. The hardware does this for you. Just pull the trigger on the chainsaw instead of pushing it backwards and forwards yourself.

A quick Google search finds this article on 16-bit PWM which seems to rapidly address your problem for you.

Official Arduino Secrets of PWM seems to be an older article but has good background information.

This blog post about a 16-bit PWM library seems to be pretty good too as it discusses the choice of frequencies and then links to another article on the associated filter to create an analog voltage.

If you really, truly want an analog voltage for your electromagnet then you need an analog amplifier. Something like an audio amplifier than has a DC response. This will be big and heavy and much less than 50% efficient, so this option is rarely used in Arduino projects.

Edit: fix broken url tag.
"The problem is in the code you didn't post."

tlhsglm

@MorganS Thank you very much, i really appreciated

Go Up