LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

USB 8451-SPI AD7904

Hi,
I am using SPI 8451 Module to send commands to AD7904 (4 input multiplexer ADC).  
I have set up the VI to read/write from 1 channel only. I have a constant voltage on my input but the read data is constantly varying. 
 
i think the problem I am facing is that SPI 8541 can only write 8 bit word and I am writing 16 bit word to my AD7904.
 
If someone knows how to make the usb spi 8541 to write/read 16 bit word, then my issue is resolved.
 
Thanks
 
Allan
0 Kudos
Message 1 of 2
(2,412 Views)

Hi,

  for 16 bit, it should be a case of writing / reading 8 bits twice so using the array of data itself..

You may need to re-order the either the bit order, or the byte order to match you device though. You can split and join two 8 bit numbers from/to a 16 bit one using the inbuilt vi's on the data manipulation palette.

For the AD7904 I believe the MSB is the first one in the stream, so you may need to re-order the data to match correctly and since the AD7904 is only actually expecting 12 bits of data, but requires 16 clocks, then you need to make sure you've pushed the data to the correct end of the two 8 bit numbers.

The timing performing this however might not match to the AD7904 if it introduces a SCLK setup time delay in between each byte (hence an array of them shouldn't generate the delay).

Have a look at the shipping Atmel AT25080A Read.vi (and the matching write one) under the example finder - search for SPI.
You should find that there's a 16 bit number split into 2 8 bits for transmission before going into a build array with the 0x3 read command on the front.

Hope that helps

Thanks

Sacha Emery
National Instruments (UK)

// it takes almost no time to rate an answer Smiley Wink
Message 2 of 2
(2,396 Views)