Hi,
I have a requirement of doing Analog Input and Output on a PCI FPGA card using VC++2003.
I found out that i have to make a LabVIEW project with the FPGA target and build Host vis for the functions i require. I got this information from the knowledgebase available in the ni website.
http://digital.ni.com/public.nsf/allkb/CF5427DEE53A3A0786256D4B0055D713?OpenDocument
Let me explain in detail what i have done in my code.
I have a FPGA code in which one AI and one AO loops are there. I have 4 host vis - one for Opening FPGA reference, one for Analog Input, one for Analog Output and the other for Closing FPGA reference. I did like this because, i need to access AI and AO separately.
Now for these four host vis, four dlls are made. I am attaching my project files along with this.
Before porting the dlls into VC++ environment, to check whether the dlls are working properly, a vi using Call Library Function node with these dlls and found the dlls are working perfectly.
The same dlls are used in VC++, everything compiled properly without any errors. When the program is running, i checked the Analog Output and that is also giving the same voltage level as i am defining in my VC++ code. The problem here is with the Analog Input. I am not getting the actual input voltage which is given as input. It shows some garbage value. I thought that may be dll is behaving erratically. But sometimes, i also get the correct Analog Input values.
Say, for eg, i give AO as 5V, run the VC++ code multiple no of times, once in 50 executions, i get the correct readings in AI. I am not able to figure out the reason why i am not getting correct values in AI.
My VC++ codes also is attached. I have also seen there is a C Interface for FPGA in NI-Labs. But that looks complicated compared with this approach. So i have not tried that also dont want to try that.
Regards,
Sundar Ganesh
CLAD, India