Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Error using DAQmxCfgDigEdgeStartTrig

Hi all,

I am trying to sample a 8bit input using sample clock and 'start sampling' trigger. Here's how I configure the task:

DAQmxErrChk(DAQmxCreateTask("",&samplHandle));
DAQmxErrChk(DAQmxCreateDIChan(samplHandle,"Dev1/port1/line2:7,Dev1/port2/line0:1","",DAQmx_Val_ChanForAllLines)); // choose my 8 bit DI lines PFI2:PFI9
DAQmxErrChk(DAQmxCfgSampClkTiming(samplHandle,"/Dev1/PFI0",1000000.0,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,length));
DAQmxErrChk(DAQmxCfgDigEdgeStartTrig(samplHandle,"/Dev1/PFI1",DAQmx_Val_Rising));
DAQmxErrChk(DAQmxRegisterEveryNSamplesEvent(samplHandle,DAQmx_Val_Acquired_Into_Buffer,length,0,Callback,this));
DAQmxErrChk(DAQmxTaskControl(samplHandle,DAQmx_Val_Task_Commit));

When I run it in QT Creator it gives me this error:

 

DAQmx Error: Specified property is not supported by the device or is not applicable to the task.

Property: DAQmx_StartTrig_Type

 

Task Name: _unnamedTask<0>

 

Status Code: -200452

DAQmx Error: Task specified is invalid or does not exist.

Status Code: -200088

 

Previously, when I used analog input instead of digital, I did not have any problems. Any one has a clue what's wrong with my channel configuration?

I am using PCI6259 and BNC2110.

0 Kudos
Message 1 of 13
(5,942 Views)

NazRB,

 

There are a number of problems with what you are wanting to do.

 

1) There is no true Digital Start Trigger on the 6259. This can be worked around though.

2) If you are wanting to do a hardware timed digital output generation then you will have to be on Port 0 of the device. Ports 1 and 2 are software timed only.

 

Do you need to use an external clock or can you use a counter on the card? If so, you could use a counter to generate the clock that you want and use a Counter Arm Start Trigger to provide you the 'Start Trigger' functionality that you are looking for.

 

Example of using Counter for Correlated DO.

 

Details on how to use an Arm Start Trigger on a counter

 

The reason you didn't have the issue with the Analog input is because all AI channels are capable of being hardware timed and they have a start trigger.

Aaron W.
National Instruments
CLA, CTA and CPI
0 Kudos
Message 2 of 13
(5,931 Views)

Aaron,

Thank you for your reply.

It is essential that I sample using external clock, and I need an external trigger to start sampling. Having these two requirements, can I sample lines to aquire 8bit signal?

I just can not see how I could do it using counters.

0 Kudos
Message 3 of 13
(5,927 Views)

From the M-Series User Manual:

 

If you are using an external signal (such as PFIx) as the source for DI Sample Clock or DO Sample Clock, you must trigger that external signal.

 

Can you gate your external clock, externally with your trigger line? Where is your trigger coming from?

 

Another thing that comes to mind is to try and use the AI or AO timebase on the DAQ card and make it have an external clock and then use the trigger funcationality built in. You would specify the clock source for the digital generation to be your AI or AO timebase. You would also specify a start trigger for your AI or AO task that you use. I'm not sure if this would work as I have never tried it with an external clock and don't have the hardware available to me to try it.

Aaron W.
National Instruments
CLA, CTA and CPI
0 Kudos
Message 4 of 13
(5,919 Views)

Aaron,

I do not understand what means 'gate external clock externally with the trigger'.

I have a microcontroller that runs a CCD array. It provides rising edge when the signal from the CCD is ready to be sampled. Also, it tells when to start sampling. I must have these two trigger sources to make sure sampling is sincronized with signal output.

 

Using AI timebase seems to be a way to fix the problem, but it can not figure out how to properly place it in to a program code. So first, I define my digital input channel:

 

DAQmxCreateDIChan(samplHandle,"Dev1/port0/line0:7","",DAQmx_Val_ChanForAllLines);

Then, I cofigure the clock saying that this channel sould be sampled on the rising edge of the analog input 'ai1': 

DAQmxCfgSampClkTiming(samplHandle,"/Dev1/ai1",1000000.0,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,length));

Then, I say that the start sampling sould be on the ai0 rasing slope of value 5.0 (that will be the 'high' 5V signal from the microcontroller):

DAQmxCfgAnlgEdgeStartTrig(samplHandle,"/Dev1/ai0",DAQmx_Val_RisingSlope,5.0);

But how to hook up the internal AI sample clock to the DI sample clock I have no idea.

Could you, please, give me some hint on that?

0 Kudos
Message 5 of 13
(5,911 Views)

Naz,

 

If you gate the signal externally this would mean that you provide some external circuitry that would only allow the clock to get to the DAQ card once the trigger has occurred.

 

Thinking about it more, using an external clock with an Analog Input or Output will probably not work because the way you indicate that the clock is the AI or AO sample clock, which won't be used when using an external clock. You are still welcome to try it. There is an example of Correlated Digital Input w/ Analog Input Sample Clock. You would change the Analog Input task to External Clock instead of what it currently is configured for.

 

Correlated DIO is just when you use another time base (clock) from either a Counter, Analog Input, or Analog Output to help generate or acquire digital samples. You basically have to setup a dummy AI/AO/Counter Task to get that clock to start running and then use that clock to do your digital input.

 

If using the external clock doesn't work, and I am inclined to believe it won't right now, then you will have to build some external circuitry to gate your clock.

Aaron W.
National Instruments
CLA, CTA and CPI
0 Kudos
Message 6 of 13
(5,888 Views)

Aaron,

I could not figure out how to set up the AI clock to drive DI clock.

Instead, I tried to follow your gating seggestion. I made two tasks: one for analog output and the other - for digital input. I start the DI task before the analog ouput task. Thus, my DI task is wating for the external clock to provide signals. Then, I start my analog task that sends only two samples Hi and Low - they are hooked up the the extenal interrupt of my microcontroller. As soon as this happens, the microcontroller starts generating clock and digital task kicks in. Not the best choice, but it works for right now.

This is the configuration for my DI:

DAQmxCreateDIChan(samplHandle,"Dev1/port0/line0:7","",DAQmx_Val_ChanForAllLines);

I bumped into another problem, though. Now I get an error:

DAQmx Error: Specified digital channel contains more bits than supported by the 8-bit version of DAQmx Port Read.

 

Use a version of DAQmx Port Read that supports wider digital ports.

Minimum Read Size (In Bits): 32

 

Task Name: _unnamedTask<0>

 

Status Code: -200563

I was like: %^&*#&$^! Why is this thing so complicated??? I have only one BNC2110, and it has only lines 0:7 for port0. Is there a way around it? Ofcourse, I need to sample 12bit, but 8bit would be ok to start with. Can I use other port for digital sampling?

 

Thank you.

0 Kudos
Message 7 of 13
(5,869 Views)

Naz,

 

Seems like you are making progress, good idea on having the AO trigger your microcontroller. Look at your DAQmxReadDigital function that you call, there are a number of variants of this, U8, U16 and U32. Which one are you using? You might have to use U32 even though you are not using those channels, I can't remember off the top of my head. Try the DAQmxReadDigitalU32 function and see if the error goes away.

 

As for the number of lines that you need. The 6259 has 32 channels on Port 0 (your HW timed DIO port), so you can do 12 lines. However, the BNC-2110 isn't my favorite accessory because it doesn't give you access to all of the pins on your device. If you need the other pins on port 0 then you will likely need to get another terminal block. Take a look at the SCB-68A.

Aaron W.
National Instruments
CLA, CTA and CPI
0 Kudos
Message 8 of 13
(5,864 Views)

Yes, Aaron,

changing

DAQmxReadDigitalU8

to

DAQmxReadDigitalU32

helped. But now I have another problem: My allocated space is 1048*1000. I must have it in uInt32 because that's what the DAQmxReadDigitalU32 wants as a parameter. Although I sample only first 8 bits which would be uInt8. The problem is - the array required for my application is just too big. Could I sample 1048*1000 samples and then perform four consequitive reads? Is it possible?

DAQmxErrChk(DAQmxCfgSampClkTiming(samplHandle,"/Dev1/PFI0",10000000.0,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,1048000));
DAQmxErrChk(DAQmxRegisterEveryNSamplesEvent(samplHandle,DAQmx_Val_Acquired_Into_Buffer,1048000,0,Callback,this));
DAQmxErrChk(DAQmxTaskControl(samplHandle,DAQmx_Val_Task_Commit));
DAQmxErrChk(DAQmxCfgInputBuffer(samplHandle,1048000));

and then read first quater of the sampled data

DAQmxReadDigitalU32(samplHandle,262000,10.0,DAQmx_Val_GroupByChannel,ddata,262000,&numRead,NULL));

and then read second quater of the sampled data and so on?

0 Kudos
Message 9 of 13
(5,861 Views)

You can't sample only a quarter of the U32 port at a time, the driver doesn't allow that. You can bring back the U32 and then convert to a U8 to prevent from having to have the extra lines.

 

 

Aaron W.
National Instruments
CLA, CTA and CPI
0 Kudos
Message 10 of 13
(5,855 Views)