Hi,
I would have liked to use a DAC operating using the SPI protocol in order to generate a saw tooth having a 2 ms period.
Believing my dream was impossible to achieve with a serial DAC, I turned to the LTC4050CN using HC TTL logic and this version may turns lot of times faster if needed.
By chance, reading an authorized comment in the following section:
https://forum.arduino.cc/index.php?topic=483715.0
I met a serious hope of being able to use an SPI DAC since someone speaking of work in a completely realistic way with DAC MCP4922 at a frequency ranging 25 kHz.!
My problem was only restricted to 5 kHz so I have expected to have a chance...
I bought an MCP4922 to give it a try.
- To carry out this test, I have used the following Github library:
-
When I measured the period of the generated sawtooth, I greatly simplified the given example because I want to work with an Arduino Uno (official item) equipped with a 16 MHz crystal, and I absolutely have to use the precision given by the 12 bits of the DAC.
-
I have simplified the program to avoid unnecessary waste of time and I use only Channel A of the MCP4922.
-
By measuring the period of the clock SCK, I noticed that the clock SPI worked at 4 MHz, I added a line in order to witch it to 8 MHz:
SPI.setClockDivider (SPI_CLOCK_DIV2); -
While examining the CPP file, I replaced all “digitalWrite ()” instructions with faster accesses to the PORT B and PORTD used by CS and LDAC /.
-
I have attach a compressed file containing the modified library and, as an example, the program that I am using to create the “fastest” Saw tooth described here…
As these signals are repetitive, the use of an analog oscilloscope is enough to picture timings scope but to be able to have correct scope printouts, I have used my old Tektronix TDS360 and you will find a copy in the Zipped file.
On these Scope printouts you will see:
- The saw tooth (Fig 1) whose period of 15 msec could be further improved by a few microseconds if I left the LDAC / signal permanently tied to zero volts.
You will notice that the maximum frequency obtained is 1 /0.015 sec. (or 66 Hz) therefore very far from the announced 25 kHz and my question is quite simple:
What can I modify and how to modify it to reach 5 kHz target ?
- Fig 2 shows the timing of CS / versus LDAC /.
- Fig 5 being an enlarged view of LDAC / with respect to the rising edge of CS /
- Fig 3 shows the timing of CS / in relation to CSK.
- Fig 6 highlights the delay between the falling edge of CS / and the rising edge of the first clock in the series of 2 times 8 pulses.
- Fig 8 highlights the time between the 2 transfers of 8 bits in the MCP4922 registers.
- Fig 7 highlights the time separating the 16th SCK pulse from the rising edge of CS /
- As for fig 4 it shows an enlarged shape of clock SCK.
I am unfortunately not a great specialist in C or C ++ (nor in ATMega Assembler) but I suppose that this forum is not lacking of very skilled professionals and maybe one of them could really help me achieve the repetition frequency of 5 kHz?
That said, despite my great age, I am ready to make a serious effort to improve my C (++) and ATMega Assembler knowledge.
French is my mother language so I pray you to excuse my very poor English!
Thanks in advance for your help....:
Objective 5 kHz using Arduino Uno 16 MHz and MCP4922, one DAC used with 16 bits resolution.!
MCP4922F-Arduino-SPI-Library-master.zip (3.8 KB)
timing MCP4922 _FAST.pdf (64.1 KB)




