Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

SPI interface

That question depends on the application. If this is a dedicated setup that will only and always use spi then it is definitely better to buy the card. If you have a station that is to be generic and test many products or you do a lot of communicating with different chips then it would be worth the time to develop the communication software. Once you do it for spi, developing for other communication protocols will be easier. While I am not familiar with your project, it sound like the spi card is your best solution.
0 Kudos
Message 11 of 16
(1,960 Views)

Hello,

There have been a couple different versions of code posted that can be used with either static or dynamic digital lines.  Please refer to the 5th post in this forum or the others linked below.

Implementing I2C or SPI with Pxi6508 in Labview

SPI with NI PXI 6509   [ NEW ]

 

Samantha
National Instruments
Applications Engineer
0 Kudos
Message 12 of 16
(1,948 Views)
Hi!
I've got a timing problem about this project. I would like to read on a wire and to write on another one  just after the reading sequence...
To be clearer : I would like to use the DAQmxReadDigitalU32 instruction and then DAQmxWriteDigitalU8. My problem is the 1.4~1.6 milliseconds between the end of the reading instruction and the begining of the writing instruction...is it possible to reduce it?


Message Edité par tridardp le 02-28-2008 07:31 AM
0 Kudos
Message 13 of 16
(1,859 Views)

Hello,

Are you reading then writing on the same line/channel?  What hardware did you end up using?  I saw that you previously mentioned the PCI DIO 32HS, the 8451, and the 6533.  Please provide further detail.  Posting a small relevant section of your code might be helpful. 

The DAQmx Read and Write are software calls, thus system dependent.  You are going to see some delays on the order of milliseconds depending on your system.

 

Samantha
National Instruments
Applications Engineer
0 Kudos
Message 14 of 16
(1,819 Views)
Hello,
I am using a PCI DIO 32HS card (same as a 6533 series?). I'm not reading/writing on the same channel but I will soon have to in another project(I2C...).So if you have the answer for both It may save some time.
I would like to emulate an SPI memory and this is a part of the code

    uInt32        *gData=NULL;
    uInt8       *data=NULL;
    int32      
sampsRead;
    char        chanOut[256]= "Dev1/port2/line0:7";
    TaskHandle  taskHandleOut=0,gTaskHandle=0 ;
    float64     rate=1000000.0; //1MHz
    char        chan[256]="Dev1/port0/line0",clockSource[256]="/Dev1/PFI3",clockSource2[256]="/Dev1/PFI2";
    int panelHandle;
    uInt32        gSampsToRead=16,gNumChans
;

    gData = malloc (16*sizeof(uInt32));
    data = malloc (64*sizeof(uInt8));

    DAQmxCreateTask("",&taskHandleOut);
    DAQmxCreateTask("",&gTaskHandle);
    DAQmxCreateDIChan(gTaskHandle,chan,"",DAQmx_Val_ChanPerLine);
    DAQmxCreateDOChan(taskHandleOut,chanOut,"",DAQmx_Val_ChanPerLine);
    DAQmxCfgSampClkTiming(gTaskHandle,clockSource2,rate,DAQmx_Val_Rising,DAQmx_Val_ContSamps,16);
    DAQmxCfgSampClkTiming(taskHandleOut,clockSource,rate,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,8);
    DAQmxWriteDigitalU8 (taskHandleOut, 8, 0, 10.0, DAQmx_Val_GroupByChannel, data, &huit, 0);                         DAQmxStartTask(gTaskHandle);
   DAQmxReadDigitalU32(gTaskHandle,gSampsToRead,10.0,DAQmx_Val_GroupByChannel,gData,gSampsToRead,&sampsRead,NULL);
    DAQmxStartTask(taskHandleOut);

    DAQmxStopTask(gTaskHandle);
    DAQmxClearTask (gTaskHandle);
    DAQmxStopTask(taskHandleOut);
    DAQmxClearTask (taskHandleOut);
    DAQmxResetDevice ("Dev1");
    free(data);
    free(gData);

I used two differents clocks sources (PFI2 and 3) because I got errors telling me that my hardware does not support the same clocksource for both instructions (even if it's fundamentally
the same signal).

0 Kudos
Message 15 of 16
(1,803 Views)
Hello,
 
To help reduce the time between the read and the write, it might be helpful to use the DAQmxTaskControl call to reserve the resources of the write task prior to the start call.  Please refer to the DAQmx C Reference Help to view the topic titled DAQmxTaskControl. 
Samantha
National Instruments
Applications Engineer
0 Kudos
Message 16 of 16
(1,776 Views)