03-19-2012 11:20 AM
Hi There,
I am trying to do something that is very much simple to do in C, but since I dont have much experience in LABVIEW, I am loosing so many precious hours. Here is what I want to do. I have two sections of the code as the way I wanted. Its just a matter of combining them together.
The ADC in questioin is an AD7490 12 bit ADC. When it is powered up, it needs to go through something called a DUMMY OPERATION.
I managed to get he data that needs to be input during the dummy operation. Here is what I want to do.
The first 2 cycles require the /CS (Chicp Select - active LOW) pin of the ADC to be LOW and then the DATA pin needs to be tied to 1. I managed to do this manually.I also got the second part of the data to work.
The main thing that is bugging me is how I would combine both these codes togetherso that at the end, when the user presses the INITIALIZE button, the initializtion needs to be done. I am attaching my Labview code here.
It would be really good if you could help me out. Im attaching the PDF of the aD7490 as well.
Thanks
Labmat.
03-23-2012 07:13 AM
Hi Labmat,
Thank you for your post, I understand that you wish to perform a series of steps using LabVIEW code to perform a Dummy Operation, sending signals to your ADC chip.
Out of interest what version of LabVIEW are you using and what hardware are you interfacing the ADC with?
Could you provide the step-by-step procedure for a complete "Dummy Operation" as it would be perfomed in C and what digital signals need to be sent to which output pins in hardware. This will allow myself and other forum users to advise accordingly.
Many Thanks
03-23-2012 08:11 AM
@Jamie S. wrote:
Out of interest what version of LabVIEW are you using and what hardware are you interfacing the ADC with?
LabVIEW 2011. You can tell if you open the VI. As for the hardware, it doesn't really matter, since the user is simply controlling digital lines.
Could you provide the step-by-step procedure for a complete "Dummy Operation" as it would be perfomed in C and what digital signals need to be sent to which output pins in hardware. This will allow myself and other forum users to advise accordingly.
Don't need to. That information is right in the data sheet and is pretty clear.
To OP: This would have been a lot easier if you had used a SPI device, such as the NI-8451, or something like the SUB-20. You issue is one of architecture. What you really need is a simple state machine so that you can have an "Initialize" state where you send these 2 dummy conversion operations as part of the chip's power-up. Then, subsequent read requests can be done as necessary. To simplify your clock, use the Initialize Array function to create an array of ones and another to create an array of zeros, then interleave them. This will allow you to drive a for-loop using auto-indexing. Nice and clean.
03-26-2012 03:38 AM
how would one go about and do this clock generation using the initialize array. Correct me if Im wrong. If we have two arrays of 1s and 0s then when we "interleve" them, dont we have to create a delay between the 1st and 0s to represent a digital waveform? the delay would be a 50% duty cycle delay (ON time = OFF time)? Wouldnt the solution with the inverter do the trick?
I have managed to send the data bits on every -ve clock edge. Jamie's solution was to use a state machine - which was exactly what I had in mind. This would mean that without the user pressing the initialize button, on startup of the program, the ADC would go into an initialize mode and then the normal mode.
the solution that I have now (although a bit messy), when viewed through a logic analyzer, shows that it is doing exactly what I want it to do. I have attached the coder here FYI. right now, the program will send a burst of data (2 times) as soon as the CS control is clicked. then from the third time onwards, it will send a data stream with the particular databits ON and OFF (representing the control register of the ADC).
How would we automate this as I explained before?
Thanks,
Kind REgards,
LABMAT
03-26-2012 03:51 AM
how would one go about and do this clock generation using the initialize array. Correct me if Im wrong. If we have two arrays of 1s and 0s then when we "interleve" them, dont we have to create a delay between the 1st and 0s to represent a digital waveform? the delay would be a 50% duty cycle delay (ON time = OFF time)? Wouldnt the solution with the inverter do the trick?
I have managed to send the data bits on every -ve clock edge. Jamie's solution was to use a state machine - which was exactly what I had in mind. This would mean that without the user pressing the initialize button, on startup of the program, the ADC would go into an initialize mode and then the normal mode.
the solution that I have now (although a bit messy), when viewed through a logic analyzer, shows that it is doing exactly what I want it to do. I have attached the coder here FYI. right now, the program will send a burst of data (2 times) as soon as the CS control is clicked. then from the third time onwards, it will send a data stream with the particular databits ON and OFF (representing the control register of the ADC).
How would we automate this as I explained before?
Thanks,
Kind REgards,
LABMAT
03-26-2012 08:33 AM
@LABMAT wrote:
how would one go about and do this clock generation using the initialize array. Correct me if Im wrong. If we have two arrays of 1s and 0s then when we "interleve" them, dont we have to create a delay between the 1st and 0s to represent a digital waveform? the delay would be a 50% duty cycle delay (ON time = OFF time)? Wouldnt the solution with the inverter do the trick?
It would be the same as what you were doing with the shift register and the inverter, except you wouldn't need the shift register and the inverter, and you wouldn't need to wire the number of iterations, since that would already be known based on the size of the array.
Jamie's solution was to use a state machine
Actually, that was my suggestion.
the solution that I have now (although a bit messy), when viewed through a logic analyzer, shows that it is doing exactly what I want it to do. I have attached the coder here FYI. right now, the program will send a burst of data (2 times) as soon as the CS control is clicked. then from the third time onwards, it will send a data stream with the particular databits ON and OFF (representing the control register of the ADC).How would we automate this as I explained before?
That really depends on how you intend to use this VI. Is this VI supposed to be run after you apply power to the device? Is it just a configuration VI, or a more generic VI for talking to the ADC chip? If it's just a configuration VI you don't really need a state machine since the steps for intializing the chip are pretty clear. If it's supposed to be a more generic VI, then you need to use a real state machine, not what you have. You should have an "Idle" state where the state machine just sits there doing nothing, waiting to see if the user pressed any buttons. You'd have an "Init/Power Up" button that sends out those 2 dummy conversions, followed by the configuration bits. Whether you choose to do these two steps in one state or separate states is up to you. You'd use separate states if you want to be able to resend the configuration bits, for example.
Note: do not use floating point datatypes where you should be using integers. In your VI's outer while loop the shift register holding the "state" numeric is a float - it should be an integer.
03-26-2012 10:04 AM
smercurio,
apologies for getting the names mixed. You deserve the credit for mentioning the state machine, Thanks for pointing it out to me.
As to your suggestion whether Im using this as a configuration VI or a generic VI, the answer is that Im using it as a generic VI. The main aim is to guide the user in testing a board that consists an ADC. So, the coden would say which POT to turn and this data is read by the ADC. the output from the ADC is then processed by LABVIEW and presented to the user in a way they can understand.
So, Im guessing Ill have to go through the state machine version of this. Ill work on this and will post this code here for your comments and help.
thanks,
LABMAT.
05-08-2012 05:29 AM
hi there,
thanks for your input. I have managed to automate the above by using different states. now, Im in the problem that I cannot obtain the correct data out.
As I mentioned before, the output of the ADC is 16 bits long with the 4 bits (preceding the Data) is the address of the channel being sampled.
right now, although I am getting the data out, Im getting the data from from all sorts of Addresses instead of just one channel (when I view it through the scope). This has been happening for quite a long time.
can you please help me out here. Im attaching my code here for your information
Please note that the codee I have posted here is the code that I was using for testing purposes. So, the state goes from 0 to 1 and stays at 1 which will ensure that I get the data out.
thanks
Labmat.