NI Home > Community > NI Discussion Forums

Driver Development Kit (DDK)

Showing results for 
Search instead for 
Do you mean 
Reply
Member
FStewart
Posts: 9
0 Kudos

Re: Programming Analog Input Registers for MSeries NI-6221

Hi Tom

 

I fingered it out from a couple of code comments that I had to change a parameter in the AIPersonalize routine for a 6221 card and I am now reading data. Yay!

I still need to figure out how to compile and link "chipobjects", dma and rdhddk_rtx code in a Visual Studios Net 2003 project so that I can utilize these functions in my 6221 driver running under RTX and a proprietary API. Any tips or advice would be appreciated.

 

 

 

Active Participant
Tom_W_[DE]
Posts: 1,716
0 Kudos

Re: Programming Analog Input Registers for MSeries NI-6221

[ Edited ]

Hi Floyd-

The biggest thing you would need would be to define all of the virtual paths for the various source and include files.  You might also need to add preprocessor #defines for a couple of things, notably kLittleEndian or kBigEndian.  All of these settings can be made in the Visual Studio project properties window (right-click on the project name in project explorer).

I don't have an RTX environment up to test on, so I just built a project for Windows (using NI VISA) and got it compiling.  You should be able to use most of the settings here to help get your RTX build working.  I just noticed that you're using VS2003 and I created mine in VS2005, so you might want to download one of the "free" Visual Studio 2005 express editions to view this.

My project was created with all files residing in C:\mhddk.  The additional include directory setings and preprocessor defines are made as shown here:

\

Since you're using the entirely source-based RTX O/S interface from the MHDDK you shouldn't need to include any additional libraries for the linker.  FYI, I had to include visa32.lib for mine because I was using NI-VISA for Windows.



Message Edited by Tom W [DE] on 02-15-2008 11:24 AM
Tom W
National Instruments
Member
FStewart
Posts: 9
0 Kudos

Re: Programming Analog Input Registers for MSeries NI-6221

Thanks again Tom
 
I started over with my project and it all compiled perfectly, not sure what I did wrong.
 
I have the Analog Inputs working like a champ and now I am getting into the Digital I/O
 
I have Ports 0 to 2 working correctly as inputs but I am trying to understand the following example in dioex2.cpp
 
  // ---- Start DIO task, Port 1 DO, Port 2 DI ----
    board->IO_Bidirection_Pin.writeRegister (0x00FF);
    board->PFI_Output_Select_1.writeRegister (0x4210);
    board->PFI_Output_Select_2.writeRegister (0x4210);
    board->PFI_Output_Select_3.writeRegister (0x210);
    board->PFI_Output_Select_4.writeRegister (0x000000);
    board->PFI_Output_Select_5.writeRegister (0x000000);
    board->PFI_Output_Select_6.writeRegister (0x00);
Evidently this sets the PFI Port 1 to Digital Out and PFI Port 2 to Digital In but I am having trouble understanding the calls and why.
 
When I init the card I have a 32 bit word that will enable the channels I want
 
example 0xFF will enable the Static Port 0 channels 0 to 7
 
then I have a direction word
 
Example 0xF0 would make DIO 4 to 7 Outputs and 0 to 3 Inputs
 
 
Active Participant
Tom_W_[DE]
Posts: 1,716
0 Kudos

Re: Programming Analog Input Registers for MSeries NI-6221

Hi Floyd-

tMSeries.h defines some helpful enums (that we chose, for some reason, to not use in that example :smileywink:  ), for example tPFI0_Output_Select() which defines PFI_DO as 0x10.  The format of the PFI_Output_Select_1 register is as follows:

bits 0-4: PFI0 select
bits 5-9: PFI1 select
bits 10-14: PFI2 select
bit 15: reserved

with the same pattern repeating for PFI_Output_Select_N where N is a number between 1 and 5 and the PFI bitfields increase with the same pattern as PFI_Output_Select_1.  PFI_Output_Select_6 contains the selection for PFI15 in bits 0-4 and the rest of the bitfields are reserved.

The values written to those registers by dioex2 correspond to setting the lowest PFIn lines to PFI_DO (i.e. output) and the upper PFIn lines to "default" (i.e. input).  The setting for IO_Bidirection_Pin sets the PFI lines to input or output where bits 15-0 correspond to PFI15-PFI0, respectively.  As you might guess, a value of '1' corresponds to output and a value of '0' corresponds to input.

 

Tom W
National Instruments
Member
rastov
Posts: 7
0 Kudos

Re: Programming Analog Input Registers for MSeries NI-6221

Hello Tom,

 

I am solving a similar issue here.  When I was trying to perform "make" I have received an error saying, that it can not open the file "visa.h". I really don't have this file, when I check win-visa.mak -> path "C:/VXIPNP/WinNT/include".  Can you give me any advice, how could I create this dir structure or any other solution?

 

Thank you in advance for your reply.

 

Rasto

Member
John_M.
Posts: 113
0 Kudos

Re: Programming Analog Input Registers for MSeries NI-6221

Hi Rasto,


Depending on the development support selections you made when you installed NI-VISA, "visa.h" and "visa.lib" may be in a couple of places. A couple of common locations are as follows:

 

For visa.h:
C:\Program Files\National Instruments\Shared\CVI\include\visa.h
C:\Program Files\IVI Foundation\VISA\WinNT\include\visa.h

For visa.lib
C:\Program Files\National Instruments\Shared\CVI\bin\msvc
C:\Program Files\IVI Foundation\VISA\WinNT\lib\msc

You could also run a search on your harddrive for the file. Then you can copy it and any dependencies to whatever directory you desire.

 

John M

National Instruments
Applications Engineer
Member
rastov
Posts: 7
0 Kudos

Re: Programming Analog Input Registers for MSeries NI-6221

Hello John,

 

thank you very much for your reply. I have found all the needed files in path proposed by you and changed it in "win-visa.mak". After that, compiling was running well.  Then there were some changes in "ai.h" to configure measurement and everything is running well.

 

Thank you once again,

 

Rasto

Member
rastov
Posts: 7
0 Kudos

Re: Programming Analog Input Registers for MSeries NI-6221

Hello, I am trying to make running solution in VS2003 C++ MFC project. For start, I would like to display the serial number of DAQ NI 6221. I have included all the paths to header files into: Project -> Properties -> C/C++ -> General -> Additional Include Directories i.e. C:\Program Files\IVI Foundation\VISA\WinNT\include C:\...\nimhddk_visa C:\...\nimhddk_visa\VISA C:\...\dma C:\...\nimseries\Examples C:\...\ChipObjects\nimdbg C:\...\GipObjects Also, I have included visa32.lib and ivi.lib into Tools -> Options -> Projects -> VC++ Directories I have used the functions from examples and when I try to build the project, I get an error: "error LNK2019: unresolved external symbol "class iBus *__cdecl acquireBoard(char *)".... I really don't know, what else (or how) should I include to make the solution link ok. Please, if anybody have similar experience, I will be greatful to get any response. Thank you very much, Rasto