Skip to content

changing frequency #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
michaelproino opened this issue Dec 6, 2016 · 3 comments
Closed

changing frequency #2

michaelproino opened this issue Dec 6, 2016 · 3 comments

Comments

@michaelproino
Copy link

Hi,
Although I try to change frequency with; (changing frequency=20 Hz and keep it constant)

static float frequency = 20.0;
unsigned long freqReg = gen.freqCalc(frequency);
gen.adjustFreq(MiniGen::FREQ0, freqReg);
delay(100);

My Minigen's output still 150kHz,
Why?

@mhord
Copy link
Contributor

mhord commented Dec 6, 2016

Try adding this line before your gen.adjustFreq() line:

gen.FreqAdjustMode(MiniGen::FULL);

There are several settings for the range of the multiplier, and freqCalc() works for the FULL range.

Sorry for the confusion!

@michaelproino
Copy link
Author

Now, my all code is;

#include <SPI.h>
#include <SparkFun_MiniGen.h>

MiniGen gen;

void setup()
{
gen.reset();
delay(2000);

gen.setMode(MiniGen::SQUARE);
delay(3000);

gen.setMode(MiniGen::SQUARE_2);
delay(3000);

gen.setMode(MiniGen::TRIANGLE);
delay(3000);

gen.setMode(MiniGen::SINE);

}

void loop()
{

static float frequency = 200.0;
gen.setFreqAdjustMode(MiniGen::FULL);
unsigned long freqReg = gen.freqCalc(frequency);

gen.adjustFreq(MiniGen::FREQ0, freqReg);
delay(100);
frequency += 200.0;
}

What I mean is getting 20 Hz frequency and increasing it step by step (for example : 10 Hz for every loop)

@mhord
Copy link
Contributor

mhord commented Dec 16, 2016

Change the "frequency" value to 20 and the frequency+=200.0 line to frequency += 10.

@mhord mhord closed this as completed Dec 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants