Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

How to read digital signal on one of the PFI lines?

Hi,
 
I have recently acquired NI USB6210 DAQ and using LabView Signal Express version 2.5.0 as part of my project for MSc. I need to use one of the digital inputs as a trigger for my analog signal so that i can view both of them simultaneously. I have Cyan microcontroller board and i am using one of the port pins as the digital signal input to the DAQ. The analog signal is current which i have connected to AI1 line. I have tried using PFI0 as the trigger but i am not able to see both the signals simultaneously. I even tried reading digital signal alone but in both the cases i get error about the Acquisition mode that i cannot use continuous sampling.
 
This is the first time i am using NI instrument and LabView. I read the forum for simialr problems but could not get much clue. Do i need to write any program for this?
 
any help appreciated. thanks in advance
 
 
-newbi
0 Kudos
Message 1 of 10
(6,305 Views)
Hi Newbi,

I've investigated your hardware and software and have found the root cause of your issue: your hardware does not support timed DIO. Additionally, you can't trigger your digital task. Finally, under SignalExpress, you can't trigger a counter that could be used to sync the two operations together.

Using your current hardware
Using SignalExpress and the 6210, the closest you can get to what you want (as far as I understand) is:
  • An on-demand software-timed digital input with no triggering
  • An hardware-timed analogue input with triggering on PFI0
This would give you the digital data and the analogue data. The latter would be triggered as required. However, the two lines would not necessarily start at the same time and they would not acquire samples at the same time either. If this is suitable for you, I'd recommend you try this.

Upgrading for more features
If you need both tasks to be triggered, or for each task to acquire data at the exact same time, you need to re-think your hardware and software. The ideal setup in this case would be to use LabVIEW and a more sophisticated M-series DAQ device such as the 6251. In this case, you could:
  • Set up an continuous, buffered analogue input task with no triggering using a counter internal output
  • Set up a continuous, buffered digital input task with no triggering using a counter internal output
  • Set up a counter task to output a pulse train. This pulse train would then be used to acquire samples at exactly the same time on your DI and AI tasks.
  • Trigger the pulse train on PFI0 - your digital line. This will start the pulse train, which in turn will start your AI and DI tasks. Without a pulse train, the AI and DI do nothing.
In this situation, you can have both your inputs completely synchronised and started on the same trigger.

If you'd like any more information on either of these methods, please let me know!

Cheers,


Message Edited by Tom O on 07-28-2008 05:30 AM
Tom

Applications Engineering, NI UK
0 Kudos
Message 2 of 10
(6,276 Views)

Hi there

I think my problem is very similar to the discussion in this thread.

 

I have a NIUSB6210 pluged on a openSuSE Linux box with USB 2.0 (USB 1.0 on developing hardware).

 

I am trying to sincronize continuos (slow) analogic input and digital triggered fast analogic waveforms.

 

Is this possible WITH THIS HARDWARE NIUSB6210?

 

Do you have a handy example C/C++ DAQmxBase to show me?

 

Thanks in advance

César Bravo

cesarabravop@hotmail.com

0 Kudos
Message 3 of 10
(6,069 Views)

Hello Cesar,

 

You can have a look at the C Reference Help that was installed with your DAQmxBase driver on your PC, or try the following locations for examples:

  • Windows
    • C:\Program Files\National Instruments\"LabVIEW version"\examples\daqmxbase
    • C:\Program Files\National Instruments\NI-DAQmx Base\Examples
  • Linux
    • /usr/local/natinst/"LabVIEW version"/examples/daqmxbase
    • /usr/local/natinst/nidaqmxbase/examples/
  • Mac OS X
    • /Applications/National Instruments/"LabVIEW version"/examples/daqmxbase
    • /Applications/National Instruments/NI-DAQmx Base/examples

 

 

I hope this helps,

 

Kind Regards,

Michael S.
Applications Engineer
NI UK & Ireland

0 Kudos
Message 4 of 10
(6,003 Views)

Hi Michael

 

I just compiled the example:
/usr/local/natinst/nidaqmxbase/examples/ai/acquireNScans-DigRef.c


But when try to run it, the followin error raises:

/usr/local/natinst/nidaqmxbase/examples/ai ./acquireNScans-DigRef
DAQmxBase Error: Specified property is not supported by the device or is not applicable to the task.


the error happens in the call:
DAQmxErrChk (DAQmxBaseCfgDigEdgeRefTrig(taskHandle,triggerSource,triggerSlope,triggerSamples));

and I just notices that there is a wrong value on the code:
uInt32 triggerSlope = DAQmx_Val_RisingSlope;

so I change it to:
uInt32 triggerSlope = DAQmx_Val_Rising;


but the error remais.

The manual states clearly that NIUSB6210 does support ReferenceTriggers.

Can you help me to solve this problem?
Or the NIUS6210 DO NOT SUPPORT Reference Triggers?

 

I would like to get a WORKING EXAMPLE on how to access NIUSB6210 through VISA on LINUX.

 

Regards
César
P.S. The code follows in attach and at the end of this message.
 /*********************************************************************
 *
 * ANSI C Example program:
 * acquireNScans-DigRef.c
 *
 * Example Category:
 * AI
 *
 * Description:
 * This example demonstrates how to acquire a finite amount of data
 * using a digital reference trigger.
 *
 * Instructions for Running:
 * 1. Select the Physical Channel to correspond to where your
 * signal is input on the DAQ device.
 * 2. Enter the Minimum and Maximum Voltage Ranges.
 * Note: For better accuracy try to match the Input Ranges to the
 * expected voltage level of the measured signal.
 * 3. Select how many Samples to Acquire on Each Channel.
 * 4. Set the Rate of the Acquisiton.
 * Note: The Rate should be AT LEAST twice as fast as the maximum
 * frequency component of the signal being acquired.
 * 5. Select the Source and Edge of the Digital Reference Trigger
 * for the acquisition.
 *
 * Steps:
 * 1. Create a task.
 * 2. Create an analog input voltage channel.
 * 3. Define the parameters for an Internal Clock Source.
 * Additionally, define the sample mode to be Finite.
 * 4. Define the parameters for a Digital Edge Reference Trigger.
 * 5. Call the Start function to begin the acquisition.
 * 6. Use the Read function to retrieve the waveform. Set a timeout
 * so an error is returned if the samples are not returned in
 * the specified time limit.
 * 7. Call the Clear Task function to clear the Task.
 * 8. Display an error if any.
 *
 * I/O Connections Overview:
 * Make sure your signal input terminal matches the Physical
 * Channel I/O Control. Also, make sure your digital trigger
 * terminal matches the Trigger Source Control. For further
 * connection information, refer to your hardware reference manual.
 *
 * Recommended Use:
 * 1. Call Configure and Start functions.
 * 2. Call Read function.
 * 3. Call Stop function at the end.
 *
 *********************************************************************/
 #include "NIDAQmxBase.h"
 #include
 #define DAQmxErrChk(functionCall) { if( DAQmxFailed(error=(functionCall)) ) { goto Error; } }
 int main(int argc, char *argv[])
 {
 // Task parameters
 int32 error = 0;
 TaskHandle taskHandle = 0;
 char errBuff[2048]={'\0'};
 int32 i;
 // Channel parameters
 char chan[] = "Dev1/ai0";
 float64 min = -10.0;
 float64 max = 10.0;
 // Timing parameters
 char clockSource[] = "OnboardClock";
 uInt64 samplesPerChan = 1000;
 float64 sampleRate = 10000.0;
 // Triggering parameters
 char triggerSource[] = "/Dev1/PFI0";
 //uInt32 triggerSlope = DAQmx_Val_RisingSlope;
 uInt32 triggerSlope = DAQmx_Val_Rising;
 uInt32 triggerSamples = 100;
 // Data read parameters
 #define bufferSize (uInt32)1000
 float64 data[bufferSize];
 int32 pointsToRead = bufferSize;
 int32 pointsRead;
 float64 timeout = 10.0;

 DAQmxErrChk (DAQmxBaseCreateTask("",&taskHandle));
 DAQmxErrChk (DAQmxBaseCreateAIVoltageChan(taskHandle,chan,"",DAQmx_Val_Cfg_Default,min,max,DAQmx_Val_Volts,NULL));
 DAQmxErrChk (DAQmxBaseCfgSampClkTiming(taskHandle,clockSource,sampleRate,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,samplesPerChan));
 DAQmxErrChk (DAQmxBaseCfgDigEdgeRefTrig(taskHandle,triggerSource,triggerSlope,triggerSamples));
 DAQmxErrChk (DAQmxBaseStartTask(taskHandle));
 DAQmxErrChk (DAQmxBaseReadAnalogF64(taskHandle,pointsToRead,timeout,DAQmx_Val_GroupByChannel,data,bufferSize,&pointsRead,NULL));
 printf ("Acquired %d samples\n", pointsRead);
 // Just print out the first 10 points
 for (i = 0; i < 10; ++i)
 printf ("data[%d] = %f\n", i, data[i]);
 Error:
 if( DAQmxFailed(error) )
 DAQmxBaseGetExtendedErrorInfo(errBuff,2048);
 if(taskHandle != 0) {
 DAQmxBaseStopTask (taskHandle);
 DAQmxBaseClearTask (taskHandle);
 }
 if( DAQmxFailed(error) )
 printf("DAQmxBase Error: %s\n",errBuff);
 return 0;
 }

0 Kudos
Message 5 of 10
(5,998 Views)

Digital reference triggers, while supported in hardware by the USB-6210, are not implemented in the DAQmx Base driver [1]. You can, however, use a digital start trigger since they are implemented in DAQmx Base.

 

If you need a digital reference trigger, then the best solution is to replicate a reference trigger in software. But since DAQmx Base isn't multi-threaded, reading from both the analog and digital tasks can't be done in parallel but in sequence. This limitation introduces a small discrepancy between the time when the digital level change has been detected and when the software would then mark the reference trigger in the analog data.

 

In addition, there is no way to exactly correlate the digital event to the analog data in software since the 6210 cannot hardware time the digital I/O, but can only perform static (software timed) reads and writes.

 

[1] NI-DAQmx Base readme

https://download.ni.com/support/softlib/multifunction_daq/nidaqmxbase/3.2/Linux/readme.txt

Joe Friedchicken
NI Configuration Based Software
Get with your fellow OS users
[ Linux ] [ macOS ]
Principal Software Engineer :: Configuration Based Software
Senior Software Engineer :: Multifunction Instruments Applications Group (until May 2018)
Software Engineer :: Measurements RLP Group (until Mar 2014)
Applications Engineer :: High Speed Product Group (until Sep 2008)
0 Kudos
Message 6 of 10
(5,963 Views)

Dear All,

 

I have USB-6212 and I like to program it in Python 2.7. My goal is to use PFI0 as a fast sampling trigger at 160kHz and PFI1 as a low sampling trigger around 10Hz simultaneously: after every PF1 rising edge ca. 5000 sample should be gathered at the rising edges of PFI0.

 

I have no experience in NIDAQ programming in Python, so I follow step-by-step the Python and ANSI C examples (implementing them into Python). However I get stucked with a very simple problem:

 

I generate a train of alternating 10101010.. digital signal with ca. 2Hz on RedPitaya at 3.3V for High value for testing the digital inputs like PFI0 or PFI1.(see pp.5-6. here: http://staff.ltam.lu/feljc/electronics/redpitaya/RedPitayaScriptingSummary_1.pdf)

The signals are clearly recorded (see ai_input.png) using the analog input example: https://github.com/ni/nidaqmx-python/blob/master/nidaqmx_examples/every_n_samples_event.py

However I can't see anything on the digital inputs neither in NI MAX nor in the Python example: https://github.com/ni/nidaqmx-python/blob/master/nidaqmx_examples/di_sw_timed.py

 

Anyone has an idea what I am forgetting here?

 

Best,

 

Lenard

 

 

0 Kudos
Message 7 of 10
(3,612 Views)

Hi LenardV,

 

Did you solve the issue? I also have similar kind of problem. I am using PFI1 as laser trigger which at 5 KHz and PFI12 as Zaber controller trigger for the data acquisition using NI DAQ 6281. This device was working well and I was getting  the digital outputs too. Recently, I encountered some error while running the LabVIEW program. Upon test, I found that the digital output PFI 1 is working but PFI12 is not measuring anything. It is supposed to measure the Zaber trigger at 5KHz. I have no idea where the problem lies.

If you have solved the issue, could you suggest me the solution please?

 

 

0 Kudos
Message 8 of 10
(871 Views)

Hi @wadhesh

 

If you are still having an issue reading the digital output from the Zaber device, can you email more details of your device, trigger, and wiring at mike@zaber.com? The issue may be on the Zaber side. 

 

Best regards,

 

Mike McDonald

Applications Engineering Team

Zaber Technologies

0 Kudos
Message 9 of 10
(848 Views)

Hi Mike,

Thank you for replying. I solved the issue.

 

Thank you.

 

Regards,

Awadhesh

0 Kudos
Message 10 of 10
(824 Views)