MiniGen Frequency Programming

Hi all,

I’ve just got my minigen up and running. But I’m unable to output a 8kHz frequency. Here is the code I’m playing with, any suggestions would be appreciated. The code produces a 94 Hz sine wave.

Moderator edit to add code tags

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


MiniGen gen;

void setup()
{

gen = MiniGen(10);
  gen.reset();
  delay(2000);

  gen.setMode(MiniGen::SINE);
  gen.setFreqAdjustMode(MiniGen::FULL);
  gen.selectPhaseReg(MiniGen::PHASE0);
  }

void loop()
{
        static float frequency = (8000);
        unsigned long freqReg = gen.freqCalc(frequency);
        gen.adjustFreq(MiniGen::FREQ0, freqReg);

}

Thanks

Problem solved,

no need for the following command in the code:

MiniGen gen;

Any ideas why my Arduino and Minigen is consuming 55 mA when generating a simple 8khz sine wave? The datasheet of AD9837 suggests, 5 mA and for Arduino 5 mA power consumption, I don’t see why I’m consuming more than 10 mA :frowning:

Thanks

Hi AAmiri,

That’s great to hear you were able to debug your code. As for your question about power consumption, 55mA sounds about right for powering the shield and Arduino. Both the shield and Pro Mini have voltage regulators that will add to your current draw and that current increases depending on the voltage drop across the regulator. Also, the [AD8045 Op Amp has an operating current of 15mA.

To reduce that current draw, you will need to get your supply voltage to as close to 3.3V as possible. You could also try bypassing the voltage regulators. It is not recommended to do so and SparkFun’s Tech Support cannot help with this process as this requires modifying the board but if you need to decrease current consumption, I would recommend reviewing the Eagle files and schematics we have posted for both the Mini Gen and the Pro Mini on their respective product pages.](https://cdn.sparkfun.com/datasheets/BreakoutBoards/AD8045.pdf)