PWM Frequency | Arduino Compatible Compiler for LabVIEW Discussions | Forum

Avatar
Please consider registering
guest
sp_LogInOut Log In sp_Registration Register
Register | Lost password?
Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Feed Topic RSS sp_TopicIcon
PWM Frequency
March 9, 2016
6:59 pm
Avatar
krummelt1
New Member
Members
Forum Posts: 2
Member Since:
March 9, 2016
sp_UserOfflineSmall Offline

Is it possible to increase the PWM frequency using the LabVIEW compatible compiler.  I have seen some of the posts suggesting the use of interrupt, but wont that only decrease it?

 

I know it can be done with just Arduino code and some particular libraries but can I do it in LabVIEW?  If possible I need 25kHZ out of a YUN for speed control of a  Sanyo Denki fan.

 

Thanks

March 9, 2016
7:04 pm
Avatar
filipealtoe
Admin
Forum Posts: 98
Member Since:
March 12, 2015
sp_UserOfflineSmall Offline

In general terms, anything that can be done via Arduino API C-code can be done in the Compiler also. Maybe the shortest path to success on this will be for you to start with an example C-code that works for what you need, using the Arduino libraries and then port the needed functions from the library to be available in the compiler. You can follow the Porting an Arduino Library User Guide that is part of the User Manual that describes the steps one needs to follow to port a Library to work with the Compiler.

Filipe

Cheers
Filipe

March 9, 2016
10:00 pm
Avatar
Steffan
Admin
Forum Posts: 408
Member Since:
March 12, 2015
sp_UserOfflineSmall Offline

Typically changing PWM frequency involves changing timer registers and configurations, which may have other side affects.  But you can likely do this in the core Arduino libraries that the Arduino Compatible Compiler for LabVIEW uses.  Or you can do as Filipe suggested and look into changing those registers on an application layer through API C-code.

Refer here for some info on changing PWM frequency.

March 11, 2016
7:17 pm
Avatar
krummelt1
New Member
Members
Forum Posts: 2
Member Since:
March 9, 2016
sp_UserOfflineSmall Offline

Steffan/Filipe

Thanks for the help.  I am trying to "port" the timerone.h libraries available here: http://playground.arduino.cc/Code/Timer1 but quite honestly I am feeling a little over my head.  I am reading through the example but I start to get lost somewhere in step 2.  For my example I think my list of parameters I need are (my arduino code is at the bottom)

timer1::initialize(long microseconds)

timer1::pwm

timer1::attachinterrupt (call

timer1.setPwmDuty

 

Is the basic jist here that I am going to create my own vi for each of the above functions written in the library?  Forgive me if this is a case of just not reading the manual I suppose I just cannot recall enough from my C classes to efficiently do this.  I have become quite comfortable with LabVIEW and was hoping this compiler would let me deploy to some smaller targets.

The arduino sketch I have that works is below:

 

#include "TimerOne.h"

int speed = 100;

int fadeamount = 1;

int speedadjustment = 0;

void setup()

{

pinMode(10, OUTPUT);

Timer1.initialize(40); // initialize timer1, and set a 1/2 second period

Timer1.pwm(10, 128); // setup pwm on pin 9, 50% duty cycle

Timer1.attachInterrupt(callback); // attaches callback() as a timer overflow interrupt

}

 

void callback()

{

// digitalWrite(10, digitalRead(10) ^ 1);

}

 

void loop()

{

Timer1.setPwmDuty(10, speed);

speedadjustment = analogRead(A3);

speed = speedadjustment;

}

delay(10);

}

Forum Timezone: UTC 0
Most Users Ever Online: 100
Currently Online:
24
Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
miche91: 33
scottj: 28
scadao: 23
Member Stats:
Guest Posters: 5
Members: 202
Moderators: 0
Admins: 3
Forum Stats:
Groups: 1
Forums: 2
Topics: 266
Posts: 1222
Newest Members:
pujacontrol
Administrators: geadmin: 22, filipealtoe: 96, Steffan: 356