07-17-2018 09:47 AM
Running the following Matlab code:
Visa6541Address = 'PXI17::14::INSTR';
vv=visa('ni',Visa6541Address)
fopen(vv)
reg1 = memread(vv,0,'uint16','PXICFG',3)
fclose(vv)
Results in reg1 = 4243, 28887,6
Where is there a reference to tell me what these number mean please?
Thanks for any suggestions you can offer!
Solved! Go to Solution.
07-19-2018 08:17 AM
Hi! Can you give more information on what you are doing? The code alone doesn't tell much.
07-25-2018 05:43 PM
Hello, Sorry it took me so long to reply. The code I posted seems too low level to be of much use (unless you happen to be the PXI-6541 designer). I spent a lot of time trying to control the PXI-6541 through the Matlab Instrument Control Toolbox. I have concluded that ICT is useless for the PXI-6541 (not generalizing about all NI PXI instruments). The only way to control the PXI-6541 through Matlab is to write a *.mex file that calls the niHSDIO driver functions. NI has lots of examples of 'C' programs that do this so all you have to do is convert them to *.mex. Than you will have a Matlab function that you can call from a *.m file. You also need Microsoft Visual C installed.
Here is an example of how to compile and link: mex SPIcontrol.c '-LC:\Program Files (x86)\IVI Foundation\IVI\Lib_x64\msc' -lniHSDIO.lib. SPIcontrol.c has a mex structure, a little different but well documented at Mathworks.com. For example, instead of a "main" there is :
/* The gateway function must look like this, don't change names*/
void mexFunction( int nlhs, mxArray *plhs[],
int nrhs, mxArray *prhs[])
{
ViRsrc deviceID = "Dev1"; // NI-MAX assigned this
ViSession generationViSession = VI_NULL; // Not sure why this is called NULL
stat[0] = (double) niHSDIO_InitGenerationSession(deviceID, VI_FALSE, VI_FALSE, VI_NULL, &generationViSession);
and so on....
Finally in your Matlab .m file you have something like:
Emat = SPIcontrol(hex2dec('1234')) % 6541 transmits 1234 on 15 parallel channels out the front panel and returns errors
Maybe this will save some of your readers some time.