| Electronics > Beginners |
| Starting with modular synths, DAC Question |
| (1/3) > >> |
| calli:
Hi, I stumbled into that rabbit hole... There is so much fun to build yourself in that modular synth region ::) >:D So I thought first build something digital/analog to get my hands dirty and stay a bit in my comfort zone, so I am doing a LFO (low frequency oscillator) generating waveforms with an arduino. That part works, I use a MCP4921 12-bit DAC. So have a look at the attachments, on low frequencies (note the Time/Div) I get a banana curve?! I swear I only add constant values to my variable an would expect a linear sawtooth curve... Is the MCP4921 not linear? Or do I have an error here? My loop looks like so (codensed to the bare minimum, real one has some more stuff but error is the same): --- Code: ---void loop() { x = x + 1; if (x>=4096) x=0; myDac.analogWrite(x); delayMicroseconds(20); } --- End code --- Later I may come here to ask some OpAmp Questions, but so far I can generate the CVs with them ok and also drive stuff with it, also build my vactrol etc :) Cheers, Carsten |
| Kjelt:
Be carefull or your livingroom will end up like this |
| calli:
Yea... I guess not as I am a loser at musicality :scared: And I do not play the lottery. Carsten |
| Kjelt:
But to answer your question i dont know this dac but if i look fast in the datasheet you can not just put 0...4095 through spi since it expects 16 bits where some bits have a change in behaviour like the 2x gain which will interpret 0..2047 differently from 2048..4095 reread the datasheet or place the full code here. |
| MarkF:
I have used the MCP4822 DACs with a SPI interface and the MCP4921 interface is similar. Like @Kjelt says, you must pack the 12-bit DAC value into two bytes. See the datasheet. The code snippet you posted is doing an analog output via an Andrino PWM pin. You MUST instead setup and use the SPI library to send data to the MCP4921. The data format is: |
| Navigation |
| Message Index |
| Next page |