I am trying to interface an DAC with the Arduino board. I am using the LTC1660 octal 10-bit DAC with serial input. Each DAC channel has 3 main control pins -- a data input, a load/convert pin, and a clock pin. As long as the load pin is LOW i.e. set to perform the loading operation, the data on the data input pin is advanced into a shift register at each clock pulse. Once the data is fully loaded and the convert pin is pulled HIGH the DAC perfoms the conversion. I am using three digital output pins on the Arduino board to provide the three control signals to the DAC. I am using software to provide the clock by writing 1/0 s to one of the digital pins. This method works but is not what I want as the sampling rate depends on the latency of the software. Is there a way I can do the conversion as an independent process with the clock being derived from the main board?
Are there other solutions (may be an already available shield) to have a constant sampling rate irrespective of the program that the arduino board is running?
Are there other solutions to have a constant sampling rate irrespective of the program that the arduino board is running?
The best way to tackle this is to use an interrupt service routine (ISR) triggered by one of the timers set to go at the required sample rate. Then the ISR will get a sample from a buffer and output it to the D/A using the method you have already. Mind you your main program still has to fill up the buffer and watch it doesn't overflow.
independent process with the clock being derived from the main board
If you use the SPI pins for the connection then you can derive the clock from the main processor and don't have to generate it in software. However it only transfers in blocks of 8 bits at a time so if you need an odd number of bits you are stuck. There is an SPI library available but if you look inside it you will see it is quite simple.
Thanks so much. I pursued an interrupt based solution, which has worked well. However, I am trying to improve the maximum sampling rate that I can achieve. I described the problem I am facing in