LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

CHANGING THE ARDUINO PWM FREQUENCY

Hi all,

this is the first time I am using the Labview-Arduino Interface and I have a basic (hopefully) question..

I am trying to setup a PWM using arduino via labview to control a proportional solenoid valve. I found the "PWM write pin" function in the Arduin toolbox in Labview and planning to use it.. However, I must also have control over the PWM frequency (set it at 300Hz). I had a quick google look and found this article that shows how to set the PWM frequency in the arduino..

http://www.arduino.cc/playground/Code/PwmFrequency

Therefore I have to create a new arduino sketch (code) to have control over my PWM frequency. Right?

Where do I add this code? Should I edit the LVIFA_Base sketch?

Thanks for your time,

Harry

0 Kudos
Message 1 of 3
(12,434 Views)

Just in case somebody has the same question...

I managed to set up the PWM frequency by adding the following line of hardware coding just below the "// Place your custom setup code here" in the LVIFA_Base arduino sketch:

TCCR2B = TCCR2B & 0b11111000 | 0x04;

where the 0x04 defines the PWM frequency dividor, explained in detail here:

http://www.arduino.cc/playground/Main/TimerPWMCheatsheet

Cheers,

Harry

Message 2 of 3
(5,422 Views)



0 Kudos
Message 3 of 3
(4,645 Views)