High speed data acquisition from 24-bit ADC.

  • Hi,

    We are trying to acquire data from an ADC, DC2289-AA ( Linear technologies). We are using SPI to communicate with the ADC. To implement SPI we created the SPI1 file and we are using the WriteFile and ReadFile methods. Also, we are using an infinite loop in to acquire data continuously. The least sleep interval that we can give inside the loop is 10ms, that equates to around 100Hz. If we remove the sleep statement the entire windows OS hangs up. How can we acquire data at the rate of 100 Khz and and above? I have read the native SPI document and found that the data acquistion rate is in the order of Mega hertz for polling. How can we make use of that? Is there a low level method to poll data through ADC that high frequency? The ADC does not push data, we can to send read signal to the ADC to get each data packet.

  • Hello,


    >>The least sleep interval that we can give inside the loop is 10ms, that equates to around 100Hz. If we remove the sleep statement the entire windows OS hangs up

    << That is not right, only the threads with priority below the SPI driver will be slowed down. 255 is lowest priority, 0 is highest , SPI default is about 103.

    Also i would not use "Sleep" use "WaitForSingleObject" (with timeout) this is more accurate.


    >> How can we acquire data at the rate of 100 Khz and and above?

    << What did you adjust in registry? And what did you measure?

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

    Edited 3 times, last by fs-support_ZU ().

  • Hi,

    The thread priority is 0x00010000 (THREAD_MODE_BACKGROUND_BEGIN, we wanted to make the thread a background thread) for the thread which does the SPI read operation. We tried giving a higher priority, the read operation works, but since CPU is completely used by the infinite loop, the OS becomes unresponsive. That's why we used sleep. The clock frequency in registry is the default value.

    Each time we do the ReadFile operation we are getting 3 bytes (since the ADC is 24 bits) irrespective of the loop delay. Each time we do the ReadFile operation SPI reads from the ADC. I was wondering if there is feature in which the native SPI driver automatically read from the ADC at high frequency at the kernel level, and the application thread could read all the bytes received till now from the SPI.


    Thank you.

  • Hello,


    >> ... but since CPU is completely used by the infinite loop, the OS becomes unresponsive. That's why we used sleep.

    << Ok but this regular if your thread and/or SPI thread have priority higher than most other threads.

    Neverthekless i would prefer "WaitForSingleObject" or use an externel interrupt for trigger "read ADC". Sleep is not an accurate function.

    PS: Use "CeSetThreadPriority" to adjust priorities 0...255. Using "SetThreadPriority" you can't go below 248. Read MS docu.


    >> I was wondering if there is feature in which the native SPI driver automatically read from the ADC at high frequency at the kernel Level.

    << You can't read at a higher (SPI) frequency at kernel level! You may wrap your functionality in a driver to save task switches between kernel and application. But reading 3 Byte 10 times a second should be far away from causing any remarkable overhead!


    << The clock frequency in registry is the default value.

    << So try 4000000Hz. Any improvments?

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.