0-5v output from pwm

What are you trying to say? Diode? A simple low pass filter of a arduino pwm analog output pin would be a series resistor from the pin to the device being sent the filtered voltage, then a capacitor wired from resistor output to ground. I've used 5K ohm with 10 ufd cap with good results if I recall correctly. Lefty

If the arduino PWM pin connects to ground when in the low state, the capacitor will discharge back into the arduino ground instead of remaining charged with the voltage. Think of the diode as a check valve in a fluid system that prevents fluid back flow. In the below circuit the diode on the output of the 7805 regulator chip performs two functions 1)reducing voltage back to 5v, and 2) as an electrical check valve preventing the 10uf capacitor from discharging into the supply when the servos operating pull the supply voltage low. A low voltage drop diode would be best, but I don't think my radio shack has them.

So here is what I found ... I hooked up the motor driver (12v power supply and 12 v motor) and using the pot that comes with it, everything works as expected. So then I: - unplugged the pot (3 pins, gnd +5 and signal) - tied the arduino gnd to the driver gnd - hooked up an arduino PWM pin to the driver signal pin I then loaded a sketch that used the standard PWM frequency of 490Hz. The sketch just cycled through from full speed to stop and back. The motor driver worked exactly like when I was using the pot to sweep back and forth. Nothing got hot, no smoke, all seems good. I still have not been able to figure out how to change the frequency of the PWM to the recommended 13~15KHz. So if it works with the lower frequency, is it necessary to change it?

Thanks!

The 490Hz may make the motor "sing", which I don't mind, so if you're good with that then leave it.

Hi, just getting started with Arduino myself and I am hoping to do a similar thing, controlling a DC motor with its own controller. The Controlled DC motor dives a ballscrew for a relatively simple positioning robot. The Motor controller uses 5V signals so I'm planning on supplying those (as directly as possible) from the board. At the moment I'm stuck not being able to download the IDE on the download page ... Anyway thats another story ... I am patient ...

Regarding changing the frequency I came across this on youtube ... https://www.youtube.com/watch?v=iP_f0KY7lx8 ... Not sure if it will help as I put it in the 'when I need it basket' before watching right through

bryanb334: Thanks Sonnyyu! I will test the direct PWM input this afternoon and let everyone know the results but I have another question. And according to GrumpyMike's tutorial on PWM, the arduino PWM output is at 490Hz. How do I change the frequency of the arduino PWM?

Thanks again all!

 / For Arduino Uno, Nano, Micro Magician, Mini Driver, Lilly Pad and any other board using ATmega 8, 168 or 328**

//---------------------------------------------- Set PWM frequency for D5 & D6 -------------------------------

//TCCR0B = TCCR0B & B11111000 | B00000001;    // set timer 0 divisor to     1 for PWM frequency of 62500.00 Hz
//TCCR0B = TCCR0B & B11111000 | B00000010;    // set timer 0 divisor to     8 for PWM frequency of  7812.50 Hz
  TCCR0B = TCCR0B & B11111000 | B00000011;    // set timer 0 divisor to    64 for PWM frequency of   976.56 Hz (The DEFAULT)
//TCCR0B = TCCR0B & B11111000 | B00000100;    // set timer 0 divisor to   256 for PWM frequency of   244.14 Hz
//TCCR0B = TCCR0B & B11111000 | B00000101;    // set timer 0 divisor to  1024 for PWM frequency of    61.04 Hz


//---------------------------------------------- Set PWM frequency for D9 & D10 ------------------------------

//TCCR1B = TCCR1B & B11111000 | B00000001;    // set timer 1 divisor to     1 for PWM frequency of 31372.55 Hz
//TCCR1B = TCCR1B & B11111000 | B00000010;    // set timer 1 divisor to     8 for PWM frequency of  3921.16 Hz
  TCCR1B = TCCR1B & B11111000 | B00000011;    // set timer 1 divisor to    64 for PWM frequency of   490.20 Hz (The DEFAULT)
//TCCR1B = TCCR1B & B11111000 | B00000100;    // set timer 1 divisor to   256 for PWM frequency of   122.55 Hz
//TCCR1B = TCCR1B & B11111000 | B00000101;    // set timer 1 divisor to  1024 for PWM frequency of    30.64 Hz

//---------------------------------------------- Set PWM frequency for D3 & D11 ------------------------------

//TCCR2B = TCCR2B & B11111000 | B00000001;    // set timer 2 divisor to     1 for PWM frequency of 31372.55 Hz
//TCCR2B = TCCR2B & B11111000 | B00000010;    // set timer 2 divisor to     8 for PWM frequency of  3921.16 Hz
//TCCR2B = TCCR2B & B11111000 | B00000011;    // set timer 2 divisor to    32 for PWM frequency of   980.39 Hz
  TCCR2B = TCCR2B & B11111000 | B00000100;    // set timer 2 divisor to    64 for PWM frequency of   490.20 Hz (The DEFAULT)
//TCCR2B = TCCR2B & B11111000 | B00000101;    // set timer 2 divisor to   128 for PWM frequency of   245.10 Hz
//TCCR2B = TCCR2B & B11111000 | B00000110;    // set timer 2 divisor to   256 for PWM frequency of   122.55 Hz
//TCCR2B = TCCR2B & B11111000 | B00000111;    // set timer 2 divisor to  1024 for PWM frequency of    30.64 Hz

This is the easy way as found in the PWM information page. Try to avoid changing timer 0 if you are using any time based functions. If you do have to change it, make sure to read up on how to correct for it.

If you need to set a specific PWM frequency, that is also achievable, but I haven't done it personally. There are some great guides in these forums on it though.