I have been trying to get the MiniGen board to work. My ultimate aim is to have a standalone board that can generate a pure tone on power up.
I am connecting the MiniGen to a Arduino Uno, via the Sparkfun Logic Level Converter( BOB12009; 5V => 3.3V). Power to the Minigen is from the 3.3V pin on the Arduino. The three pin connections are: 10 => FSYNC, 11 => SDATA, 13 => SCLK.
I have checked the pinouts with an oscilloscope to check that my sketches are actually putting out some signals. Also, I have checked again with the oscilloscope that the pulses on the three pins are actually reaching the appropriate pins on the AD9837. Some pictures of the signals on the pins:
FSYNC:
SDATA:
SCLK:
I have tried different SPI speeds, the pulses on the three pins change accordingly, but the MiniGen doesn’t want to budge.
Below is the simplest code I could come up with since the reset on the MiniGen should set it to 100Hz Sine. It doesn’t work though:
#include <SPI.h>
#include <SparkFun_MiniGen.h>
MiniGen gen;
void setup() {
// put your setup code here, to run once:
gen = MiniGen(10);
gen.reset();
}
void loop() {
// put your main code here, to run repeatedly:
}
I also tried hard setting the SPI mode, speed, bit order and interchanged all connections (Ran through all combination options). No improvement.
This sketch should reset the MiniGen and then put out 2 seconds of 100Hz and then 1200Hz:.Also, doesn’t work (Sometimes puts out some sine wave at 1000Hz for some reason).
#include <SPI.h>
#include <SparkFun_MiniGen.h>
MiniGen gen;
void setup() {
SPI.begin();
// put your setup code here, to run once:
SPI.setClockDivider(SPI_CLOCK_DIV64);
gen = MiniGen(10);
SPI.setDataMode(SPI_MODE2);
SPI.setBitOrder(MSBFIRST);
gen.reset();
delay(1000);
gen.setFreqAdjustMode(MiniGen::FULL);
delay(1000);
gen.setMode(MiniGen::SINE);
delay(1000);
}
void loop() {
// put your main code here, to run repeatedly:
float frequency = 100.0;
unsigned long freqReg = gen.freqCalc(frequency);
gen.adjustFreq(MiniGen::FREQ0,MiniGen::FULL,freqReg);
delay(2000);
frequency = 1200.0;
freqReg = gen.freqCalc(frequency);
gen.adjustFreq(MiniGen::FREQ0,MiniGen::FULL,freqReg);
delay(2000);
}
The weird thing though is that sometimes the MiniGen does something seemingly random. On sometimes suddenly changes to square wave, triangle wave or sine, it sometimes changes frequency in a random direction after a reset. This makes me think that I am really doing something wrong here, but I can’t figure it out. I hope someone can help me sort this out!