6:59 pm
March 9, 2016
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
7:04 pm
March 12, 2015
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
10:00 pm
March 12, 2015
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.
7:17 pm
March 9, 2016
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);
}
10
1 Guest(s)