Vasilich2004
2008-07-23 01:10:07 UTC
Data transfer methods surprised me twice J
First time I was surprised when I wrote program and found that there are 3 data transfer choices DMA, Interrupts, and Programmed I/O. Actually, there are 2 data transfer types Programmed I/O and DMA. Also there are 2 ways how program will know that data are ready by polling and interrupt.
Finally I read a manual (for example, <a href="http://www.ni.com/pdf/manuals/371022j.pdf" target="_blank"> http://www.ni.com/pdf/manuals/371022j.pdf</a> page 10-4) and I could realized that
- Programmed I/O means ?polling and Programmed I/O?
- Interrupts means ?interrupt and Programmed I/O?
- DMA means ?interrupt and DMA?
It was interesting mixture.
Next time I was surprised and am still surprising ?
Let me bring example. I need to measure 1 (only one) AI signal on 1 MHz rate. I take PCI-6251 (up to 1.25 MHz rate) and should be happy. I also have another parameter. I need to measure 50 ms or 50 kSamples. Any M-series PCI card has only 4 KSamples buffer. To work all 50 ms continuously the card should use algorithm, like
split the buffer on two parts 2 + 2 KSamples and work in schedule - when card?s ADC fills first 2 kSamples data transfer mechanism moves another 2 kSamples to PC memory. Of course, I use DMA data transfer method (it means ?interrupt and DMA?). But CPU will get interrupt each 2 ms and Windows is not real time system. So I should lose data time to time.
I got PCI-6251 card and tested. I changed NI example ?Acq&Graph Voltage-Int Clk-Dig Start.vi? slightly
- put measurement in continuously loop
- set ?Samples per Channel? = 700 000
- set ?Rate (Hz)? = 1 000 000
It worked and CPU was loaded not so much.
I started another program and loaded CPU. In this test CPU was loaded constantly from 70% to 100%. Again I didn?t notice then system missed data. Why? Has anyone idea? (Unfortunately, I have Core DUO CPU (= 2 CPUs) and the test maybe be wrong.)
Finally, there are 2 parameters in the card specification (<a href="http://www.ni.com/pdf/manuals/371291h.pdf" target="_blank"> http://www.ni.com/pdf/manuals/371291h.pdf</a>) . One parameter is that DMA is ?scatter- gather? type (I know that). Another parameter is ?scan list memory = 4095 entries? (It seems I know it also but don?t see how it can be used by the card). Looking on the parameters a stupid idea came to my mind. Maybe driver (using CPU) allocates memory in PC (can be not continuous) and starts measurement. Then the card measures, transfers data (as PCI DMA master, so CPU is not involved) to PC memory according list, and sets interrupt when measurement was finished and data was transferred.
It would be interesting if someone from NI explains how really works the card and driver. Thanks.
First time I was surprised when I wrote program and found that there are 3 data transfer choices DMA, Interrupts, and Programmed I/O. Actually, there are 2 data transfer types Programmed I/O and DMA. Also there are 2 ways how program will know that data are ready by polling and interrupt.
Finally I read a manual (for example, <a href="http://www.ni.com/pdf/manuals/371022j.pdf" target="_blank"> http://www.ni.com/pdf/manuals/371022j.pdf</a> page 10-4) and I could realized that
- Programmed I/O means ?polling and Programmed I/O?
- Interrupts means ?interrupt and Programmed I/O?
- DMA means ?interrupt and DMA?
It was interesting mixture.
Next time I was surprised and am still surprising ?
Let me bring example. I need to measure 1 (only one) AI signal on 1 MHz rate. I take PCI-6251 (up to 1.25 MHz rate) and should be happy. I also have another parameter. I need to measure 50 ms or 50 kSamples. Any M-series PCI card has only 4 KSamples buffer. To work all 50 ms continuously the card should use algorithm, like
split the buffer on two parts 2 + 2 KSamples and work in schedule - when card?s ADC fills first 2 kSamples data transfer mechanism moves another 2 kSamples to PC memory. Of course, I use DMA data transfer method (it means ?interrupt and DMA?). But CPU will get interrupt each 2 ms and Windows is not real time system. So I should lose data time to time.
I got PCI-6251 card and tested. I changed NI example ?Acq&Graph Voltage-Int Clk-Dig Start.vi? slightly
- put measurement in continuously loop
- set ?Samples per Channel? = 700 000
- set ?Rate (Hz)? = 1 000 000
It worked and CPU was loaded not so much.
I started another program and loaded CPU. In this test CPU was loaded constantly from 70% to 100%. Again I didn?t notice then system missed data. Why? Has anyone idea? (Unfortunately, I have Core DUO CPU (= 2 CPUs) and the test maybe be wrong.)
Finally, there are 2 parameters in the card specification (<a href="http://www.ni.com/pdf/manuals/371291h.pdf" target="_blank"> http://www.ni.com/pdf/manuals/371291h.pdf</a>) . One parameter is that DMA is ?scatter- gather? type (I know that). Another parameter is ?scan list memory = 4095 entries? (It seems I know it also but don?t see how it can be used by the card). Looking on the parameters a stupid idea came to my mind. Maybe driver (using CPU) allocates memory in PC (can be not continuous) and starts measurement. Then the card measures, transfers data (as PCI DMA master, so CPU is not involved) to PC memory according list, and sets interrupt when measurement was finished and data was transferred.
It would be interesting if someone from NI explains how really works the card and driver. Thanks.