Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

PXI 6541 MATLAB

I managed to get an error description before matlab crashed, and it says Keyword was expected, but not found in the script. I dont think Im passing the right argument this is my code so far:

loadlibrary (dllfile, hfile);

%define variables

name =

'a';

channel = [0,1,0,1];

name2 =

'';

name4 =

'';

name5 =

'my';

name6= int8(

'NIHSDIO_VAL_PFI2_STR');

name7= int8(

'NIHSDIO_VAL_SCRIPT_TRIGGER2');

triggerID = libpointer(

'int8Ptr',name7);

rise = int8(12);

source = libpointer(

'int8Ptr',name6);

Datastr = [1:10;1:10];

clock = libpointer(

'int8Ptr',int8(''));

wait =(double(10.0e12));

sampleClockRate =(double(30.0e6));

pname = libpointer(

'int8Ptr',int8(name));

pname2 = libpointer(

'int8Ptr',int8(name2));

pname3 = libpointer(

'uint32Ptr',0);

pname4 = libpointer(

'int8Ptr',int8(name4));

pname5 = libpointer(

'int32Ptr',0);

pname6 = libpointer(

'int8Ptr',0);

waveformname = libpointer(

'int8Ptr',int8(name5));

waveformdata = libpointer(

'uint32Ptr',uint32(channel));

pname7 = libpointer(

'int8Ptr',int8('script myScript Repeat 1 Generate my end Repeat end script'));

%initiate generation

[errint pname pname2 pname3] = calllib(

'niHSDIO','niHSDIO_InitGenerationSession',pname,0,0,pname2,pname3);

%assign channels

[errchn pname4] = calllib(

'niHSDIO','niHSDIO_AssignDynamicChannels',uint32(pname3),pname4);

%configure clock rate

[errclk clock] = calllib(

'niHSDIO','niHSDIO_ConfigureSampleClock',uint32(pname3),clock,sampleClockRate)

%use named waveform

calllib(

'niHSDIO','niHSDIO_ConfigureGenerationMode',uint32(pname3),15)

%External trigger

calllib(

'niHSDIO','niHSDIO_ConfigureDigitalEdgeScriptTrigger',uint32(pname3),triggerID,source,rise)

%write waveform to device

calllib(

'niHSDIO','niHSDIO_WriteNamedWaveformU32',uint32(pname3),libpointer('int8Ptr',int8(name5)),10,libpointer('uint32Ptr',uint32(channel)))

%Write script to device

calllib(

'niHSDIO','niHSDIO_WriteScript',uint32(pname3),pname7)

%generate waveform

calllib(

'niHSDIO','niHSDIO_Initiate',uint32(pname3))

so now it only fails at script trigger function. the script trigger fails with the error code -1074135008.

 

0 Kudos
Message 21 of 30
(2,320 Views)
Hi,
  was wondering if you could please post your entire matlab script at this point.
It seems as though there's been several advances made in this from the original script you posted, and it might be useful to put a stick in the sand as it were with the whole script.
 
Since you're making DLL calls, through LoadLibrary and calllib for the function calls, I'm pretty sure that Matlab isn't even looking at the header files, so any constants will have to be translated directly.
 
If you setup for a script trigger, you have to setup the generation to be scripted, i.e. you need a call to the niHSDIO_ConfigureGenerationMode and tell it that it's scripted (value 15) rather than waveform (value 14 by default).
If however, you want to do a hardware start trigger, then that's a different function call to niHSDIO_ConfigureDigitalEdgeStartTrigger (rather than niHSDIO_ConfigureDigitalEdgeScriptTrigger).
 
This is where your current script would probably help a bit in seeing how you're setting up to start with.
 
Thanks
Sacha Emery
National Instruments (UK)
ATE Systems Engineer.
// it takes almost no time to rate an answer Smiley Wink
0 Kudos
Message 22 of 30
(2,319 Views)

Hi,

  ok - so I was writing that last reply as you submitted yours.

Bear with me!!!

Sacha Emery
National Instruments (UK)
ATE Systems Engineer

// it takes almost no time to rate an answer Smiley Wink
0 Kudos
Message 23 of 30
(2,317 Views)
Oh good we got some more minds to join the discussion!
Glad you confirmed what I've been suspicious about the define constants not being recognised. I try to put every progress onto here even if it is minute so that I don't lose track of where I'm going wrong. Oh and looks like the error code wasn't to do with a keyword, its something to do with source terminal not being  found on the device. so think its the :

name6= int8(

'"PFI2"');

source = libpointer('int8Ptr',name6);

that its failing on. Will have to double check with the measurement explorer

Thanks

 

 

0 Kudos
Message 24 of 30
(2,311 Views)

Hi,

OK - it looks fairly cool - I think what you need to do however is stop using the header defines as your string constants though.

i.e.

name6= int8('NIHSDIO_VAL_PFI2_STR');

so name6 is pointed to by source (as in source = libpointer('int8Ptr',name6);)
and then source is used at 

calllib('niHSDIO','niHSDIO_ConfigureDigitalEdgeScriptTrigger',uint32(pname3),triggerID,source,rise)

whereas I believe that name6 should be

name6 = int8('PFI2');

and similarly for name 7

name7= int8('NIHSDIO_VAL_SCRIPT_TRIGGER2');
triggerID = libpointer('int8Ptr',name7);

so I believe name7 should be

name7 = int8('ScriptTrigger2');

Can you make the suggested changes to name6 and name7 and try the sript again?

Thanks

Sacha Emery
National Instruments (UK)
ATE Systems Engineer



Message Edited by SachaE on 01-03-2008 05:46 PM
// it takes almost no time to rate an answer Smiley Wink
0 Kudos
Message 25 of 30
(2,310 Views)

Hi,

  and again my reply comes just after your update!!!

Sacha Emery
National Instruments (UK)
ATE Systems Engineer

// it takes almost no time to rate an answer Smiley Wink
0 Kudos
Message 26 of 30
(2,309 Views)
Hi,
I tried using the short  name for the source and ID but it hasn't made much of a difference. However, the error code I previously mentioned, recommends using the measurement explorer to find the source and trigger name. So I've had a look at that and in the device route section it defines the PFI sources as '/a/PFI2' where a is my device name. so i've made the following changes:

triggerID = libpointer(

'int8Ptr',int8('/a/do/ScriptTrigger0'));

source = libpointer(

'int8Ptr',int8('/a/PFI2'));

which has lead to another error code

-1074118654, which says something about repeated capability syntax is invalid, do you know what it could imply?

 

0 Kudos
Message 27 of 30
(2,305 Views)

Hi

You have used the repeat syntax here:

pname7 = libpointer('int8Ptr',int8('script myScript Repeat 1 Generate my end Repeat end script'));

Try replacing this with:

pname7 = libpointer('int8Ptr',int8('script myScript Generate my end script'));

'Repeat 1' only performs 'Generate my' once, so you don't need the repeat syntax.

Thanks

Beejal

 

Beejal S
NI UK & Ireland
0 Kudos
Message 28 of 30
(2,288 Views)

Hi Beejal,

The repeated capability error occurs when I try to configure the script trigger, but I changed the script anyway to work without the repeat instruction:

triggerID = libpointer(
'int8Ptr',int8('scriptTrigger0'));

source = libpointer(

'int8Ptr',int8('PFI2'));

pname7 = libpointer('int8Ptr',int8('script myScript Generate my end script'));

%External trigger

calllib(

'niHSDIO','niHSDIO_ConfigureDigitalEdgeScriptTrigger',uint32(pname3),triggerID,source,rise)

And it is still throwing the error code -1074107489

I've tried the same script but leaving the source blank, i.e. :

source = libpointer(

'int8Ptr',int8(''));

and all works fine, so I'm assuming it's something to do with the source name. I've tried the following arguments for the source:

source = libpointer(

'int8Ptr',int8('"PFI2"'));

source = libpointer(

'int8Ptr',int8('NIHSDIO_VAL_PFI2_STR'));

source = libpointer('int8Ptr',int8('/a/PFI2'));

source = libpointer('int8Ptr',int8('/a/NIHSDIO_VAL_PFI2_STR'));

And the error codes I've got are as follows:

-1074118654

-1074107489

-1074135008

-1074118641

-1074115608

And they all have a similar error description.

So I think I there is some problem with selecting the trigger source.

I've used measurement and automation explorer to get the device routes, i.e. '/a/PFI2'. I'm downloading the latest version for this board to see if that makes a difference. Also in the measurement explorer, when you right click the device, the option to see the device pinouts is not highlighted, is that normal?

Thanks! 

0 Kudos
Message 29 of 30
(2,285 Views)
You may be getting to the point where it would be in your best interest to utilize any Matlab tools that make this process easier.  I do not know specifics, but I think they must support this better in a more recent version of Matlab or one of their toolkits.  It may be worth your time to talk to them about any Matlab options they can provide to simplify using instrument drivers.
0 Kudos
Message 30 of 30
(2,260 Views)