# AC, DC and PWM?

Hi, i've read that PWM function can fade a LED by turning from HIGH to LOW on very low cycles, but I have a question, DC is always 5 volt and linear, but PWM quickly switches between high and low, so..., what's the difference between AC and PWM?
thanks!

byleandroid:
Hi, i've read that PWM function can fade a LED by turning from HIGH to LOW on very low cycles, but I have a question, DC is always 5 volt and linear, but PWM quickly switches between high and low, so..., what's the difference between AC and PWM?
thanks!

http://www.arduino.cc/en/Tutorial/PWM

PWM is a square waveform that could be considered AC, if duty cicle is 50% it would be a symmetric waveform.
AC is not only sinousoidal, but also includes square or triangular waves.

AC alternates direction of current flow. PWM doesn't.

MarkT:
AC alternates direction of current flow. PWM doesn't.

You're right, PWM is Pulsating Current

I learned something new today.

Thank you!, so AC varies between positive and negative and PWM doesn't...
Can I use PWM with a relay or use it to power a 12v motor, i need to power some scalextric motors with arduino and vary their speeds, so what do i have to use for this?
Thank you =)

byleandroid:
Thank you!, so AC varies between positive and negative and PWM doesn't...
Can I use PWM with a relay or use it to power a 12v motor, i need to power some scalextric motors with arduino and vary their speeds, so what do i have to use for this?
Thank you =)

If it is a 12V DC motor you can use PWM and MOSFET transistor, relay is not going to work because it's switching speed is not enough.

You should not power any power hungry device directly from an Arduino pin. A DC motor falls into this category.

PWM is not good for relays. Aside from all the noise you would get and bouncy contacts, even the best relays have a limited number of actuations that they are designed to withstand in their lifetime. PWM will quickly go through those actuations and wear out the contacts.
For DC you can use a MOSFET, or an H bridge if you need two directional control over a DC motor.
There are motor shields available that have all the components already installed in an Arduino friendly packages. Check those out.

Thanks mart and Shpaget, I'll buy some mosfet, mart said they will do PWM so that's perfect for my project!
Thanks again!

Is there any important thing I must consider before buying one?

Look for logic level MOSFETs. You need them to open completely at less than 5V.
(Most common ones open at around 10V so those are not suitable).

ok, but logic level MOSFETs will vary their current?
I need that to vary my motor speeds.
I think that if they get 1v they open completely allowing all the current to pass through.

MOSFETs should be driven either on or off, never halfway between, so 0V or 5V for
a logic level MOSFET, 0V or 12V for a normal one. They are switching devices,
not linear. (Well most of them are specifically designed this way).

The speed control is accomplished by rapidly turning the motor on and off. That's what PWM is.

THANKS! Problem solved

PWM is a square waveform that could be considered AC, if duty cicle is 50% it would be a symmetric waveform.

Not to be too picky , but Pulse Width Modulation is really only a squarewave when the duty cycle is 50%. Otherwise it isn't "square" (since the definition of a square is H=W). You could say it is a TTL pulse signal or simply a TTL PWM single.

raschemmel:
Not to be too picky , but Pulse Width Modulation is really only a squarewave when the duty cycle is 50%. Otherwise it isn't "square" (since the definition of a square is H=W). You could say it is a TTL pulse signal or simply a TTL PWM single.

You're right, good observation.