04-16-2014 09:54 AM - last edited on 07-15-2024 09:47 AM by Content Cleaner
I am attempting to read in an Analog Devices AD7714 ADC into a myrio using the SPI VIs.
data sheet: http://www.analog.com/static/imported-files/data_sheets/AD7714.pdf
In order for this to work it seems like I would need to understand the low level SPI message protocals for this ADC and write values properly to configure the ADC and then read from the adc as an array of 8 bit words, then post process them into channels and convert them to the proper voltages based on the programed gain built in to the ADC.
Am I on the right track here? Has anyone done something similar?
I have found the SBrio tutorial and using it as reference for this project.
link: http://www.ni.com/white-paper/11249/en/
04-16-2014 11:30 AM
Yup, you're on the right track. Check out page 14 in the data sheet. It describes the registers on the ADC. You will probably have to configure some registers on power up to configure the ADC, then read from registers an re assemble the data in LabVIEW.
Everything you need should be in the data sheet (but can be tricky to find). Reading data sheets like this is a good skill to develop because this is a very common way to interact with a sensor (SPI or I2C to read / write registers in the sensor).
Let us know if you have any specific questions as you move forward.
-Sam K
Join / Follow the LabVIEW Hacker Group on google+
04-21-2014 11:11 PM
Sammy_K,
Thank you for the response and pointing me down the right path. I am slowly getting more and more familiar with this datasheet and have began setting up the VI.
I am a litle confused about the DRDY. The flow chart on page 30 shows the initialization steps then the aquisition loop where DRDY pin gets polled and signals the master that data is ready.
The MyRIO SPI interfaces has pins for MISO, MOSI and SCLK but nothing for DRDY. Will I need to input the DRDY signal into a digital pin and poll that in a case structure to start the next read/write opperation?
Also, for the circuit diagram on p19, For the MCLKin and MCLKout do I use a crystal oscillator that matches the SPI setting on the MyRIO? So a 1MHz crystal for the MyRIO SPI rate set to 1MHz?
Thanks for you help!
04-22-2014 09:25 AM
I figured out he oscillator section of that post. I'm still unsure about the DRDY.
04-25-2014 09:30 AM
The DRDY pin is used to indicate when it is safe to read from the data register. DRDY will be low when it is safe to read. If DRDY is high that means that the data register is currently being updated and if you read from the register you might get bad data. For example if you read from the data register when DRDY is high you may be one byte from the current sample and another byte from the previous sample that has not been updated yet.
Let us know if that helps.
-Sam K
Join / Follow the LabVIEW Hacker Group on google+
05-12-2014 11:23 PM
Thanks for the help,
So attached is the progress I have made so far. I am trying to convert the following two example code to labview and am not getting the expected results.
http://www.mcu-bg.com/mcu_site/viewtopic.php?p=16057#16057
http://www.ccsinfo.com/forum/viewtopic.php?t=32305
Am I on the write track here for the SPI communication?
05-13-2014 02:40 AM
I figured out the main issue. I had my SPI setting to leading edge when it should have been trailing edge.
I have attached a VI to multiplex through 3 differential channel inputs and convert them back to voltage and it is working correctly.
However, the sample rate is very low. I want to be able to sample the channels at a rate close to 1kHz but am currently streaming the values at something much lower (maybe 5 Hz or so). Any idea on what settings to change or how to change the code to make it more efficient?
05-14-2014 10:05 AM
Hey cyotani,
I wonder if you're getting stuck waiting for DRDY to go low. You could add an indicator to the inner most while loop to see how many times it checks DRDY before it actually gets a value.
-Sam K
Join / Follow the LabVIEW Hacker Group on google+
05-19-2014 09:42 AM
It turns out the sample rate spec is only for reading one channel continuously and not for indexing through the channels. So this ADC is incapable of scanning through the channels and the rate I require. I have ordered a different ADC (AD7730) which should be more capable of this task. I will report back when I get those parts in and tested.
If anyone is looking for sample myrio code for SPI communication to an AD7714, that last VI I posted works just fine.
05-20-2014 09:15 AM - last edited on 07-15-2024 09:48 AM by Content Cleaner
Hi cyotani,
If your code has been tested and is working I would suggest posting to the community examples or to the myRIO community page so that others can find it easier.
Thanks!