Interfacing with TI DAC856x, DAC816x, or DAC756x

Status
Not open for further replies.
I'll have to make a decision on audio DAC vs mine.

I need the precision for the pitch CV —*and I'm happy with the one I chose for that.

The reason for thinking about audio is that I'm doing some funky pitch bends. The other CV out is going to be used for envelope.

Regardless — I presume I can do "audio" just at a lower rate —*which is probably enough.

My not-based-on-anything calculations — each write is 24bits — @ 44100Hz it only needs a couple of Mhz if it was streaming out bits.

Looking at the oscilloscope this evening, a sine wave at 523hz has 33 or so points.

Which indicates about 17khz update?
 
Looking at the oscilloscope this evening, a sine wave at 523hz has 33 or so points.

Which indicates about 17khz update?

i think if you show some code, that would be easier to say? haven't you got some timer/interrupt thing going on?

re DAC vs codec, CV vs audio: why don't you just do 2 boards, each doing what it can do best? ... it's modular.
 
This is what I'm doing:

Code:
void loop() {

  data = sinewave(523.25);
  digitalWrite(slaveSelectPin, LOW);
  byte c1 = B00011111;
  byte c2 = data >> 8;
  byte c3 = data;
  SPI.transfer(c1);
  SPI.transfer(c2);
  SPI.transfer(c3);
  digitalWrite(slaveSelectPin, HIGH);
  SPI.endTransaction();
    
}



Code:
unsigned int sinewave(double hz) {
  double usfrac = micros() / 1000000.0;
  double angle = (twopi * hz) * usfrac;
  return sin(angle) * 32768 + 32768;
}


DS1Z_QuickPrint5.png
 
Last edited:
Using the sin16 function from FastLED — I get much more resolution:

Code:
unsigned int getDataFast(double hz) {
    double usfrac = micros() / 1000000.0;
    double angle = (65535*hz) * usfrac;
    return sin16(angle) + 32768;
}
[code]

[ATTACH=CONFIG]2988._xfImport[/ATTACH]
 
Using the sin16 function from FastLED — I get much more resolution. I make it about 100 per sinewave at 523 Hz

Code:
unsigned int getDataFast(double hz) {
    double usfrac = micros() / 1000000.0;
    double angle = (65535*hz) * usfrac;
    return sin16(angle) + 32768;
}
[code]

[ATTACH=CONFIG]2988[/ATTACH]


EDIT: And I get a few more if I don't use a double for the hz.
 
Last edited:
You are calculating the same values over and over, which is slow and wasteful. I suggest populating an array of Uint16_t (say, 1025) with pre-calculated sine values in setup(). Easiest to duplicate the first array value into the last array position as well. Then in your data function, scale your current time to get a value N in the range 0 to 1023 and a fractional part F. Do simple linear interpolation between the values array[N] and array[N+1] using F. (This N+1 is why you need the extra duplicated value, and 1025 not 1024 array entries). Return the result. You probably need a local variable to keep track of the current phase.
 
Status
Not open for further replies.
Back
Top