Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Generating and outputing square waveforms from Digital I/O ports DIO 0...7 of NI 6034E

HI,
I am using the 6034E device by National Instruments for my specific application.  What I want to do is use three of the 8 Digital I/O pins and make them output a pulse pattern shown as the following:


DIO0   01010101 01010101
DIO1   00110011 00110011
DIO2   00001111 00001111

These three DIOs will be used as inputs to a multiplexer chip, where they will serve as logic decode inputs.  I know there are examples of this using Labview, but I don't have the Labview software right now.  I was wondering if there might be examples of doing this in Visual Basic or C?  

Also, I have found out from here that the E Series DAQ boards, such as the one that I am using, have static I/O lines.  So, we cannot use continuous sampling mode here.  How would we go about performing software-timed reads and writes???

One last thing.  When connecting the Digital I/O pins (serving as outputs) of this DAQ board to an external circuit, do I have to connect DGND(pin 13) to the ground on my external circuit???.  

Thanks
0 Kudos
Message 1 of 10
(5,425 Views)
If you navigate to Start >> Programs >> National Instruments >> NI-DAQ, you'll find a lot of help files pertaining to NI-DAQ devices.  Specifically, you'll find "NI-DAQmx C Reference Help" which gives a detailed view of the C language API for the DAQ driver.  Also the DAQmx examples for ANSI C can be located at the following directory:  <National Instruments>\NI-DAQ\Examples\DAQmx ANSI C . If these examples aren't present, you can modify the National Instruments Software installation to include the examples as described in this KnowledgeBase article.  Hope that helps answer part or your question.
former NIer
Austin Walton, Engineering Manager
0 Kudos
Message 2 of 10
(5,414 Views)

Welcome to the discussion forums, pd_engineer!

In addition to the NI-DAQmx C Reference Help, you can also find the NI-DAQmx C API Visual Basic 6.0 Help in the same path (Start » National Instruments » NI-DAQ).

In these help files you will find all the functions available for reading and writing digital lines/ports. A great way to get started is by using the examples, already pointed out by Austin.

Voltage is always measured and generated in reference to something. The digital lines will output 0-5 volts in reference to the card’s GND pins. So if you want to ensure that you are reading the value you are outputting, you’ll need to connect the GND signals.

Mark E.
Precision DC Product Support Engineer
National Instruments

0 Kudos
Message 3 of 10
(5,380 Views)
Hello, thanks for the help,
I just have a few other questions.

As I have said before, I am using the NI 6034E DAQ board in order to generate simultaneouly 3 different TTL digital signals, with different pulse width, and output these TTL signals to an external circuit that I am using for this application.

The following pattern of the TTL pulses will look like this:
0101010101010101
0011001100110011
0000111100001111

From what I understand,  I have to use the 2 counters, Ctr0 and Ctr1, to generate the TTL pulses that I desire, because the DIO lines are software timed only and I will not be able to produce a deterministic output period using these DIO lines.  Am I correct?    Also, do I have to use a separate counter to generate a separate TTL digital pulse.  I need 3 different TTL pulses and there are only 2 counters for this DAQ device.  The three generated TTL signals will be feed to an external circuit.  Concerning the hardware connections for my application, I assume that the generated TTL signals will be output from GPCTR0_OUT(pin 2)  for counter 0 and GPCTR1_OUT(pin 40) for counter 1 of the NI 6034E. Is this correct?  Is there any way that these TTL signals can be output from three DIO lines(DIO0...2). 

Here is some code that I plan in order to do this:

 #include <NIDAQmx.h>
static TaskHandle gTaskHandle = 0;
DAQmxCreateTask ("", &gTaskHandle);
DAQmxCreateCOPulseChanTime (gTaskHandle, "Dev1/ctr0", "", DAQmx_Val_Seconds, DAQmx_Val_Low, 1.0, 2.0, 2.0);
DAQmxCreateCOPulseChanTime (gTaskHandle, "Dev1/ctr1", "", DAQmx_Val_Seconds, DAQmx_Val_Low, 3.0, 4.0, 4.0);
DAQmxCreateCOPulseChanTime (gTaskHandle, "?????", "", DAQmx_Val_Seconds, DAQmx_Val_Low, 7.0, 8.0, 8.0);

DAQmxCfgImplicitTiming (gTaskHandle, DAQmx_Val_FiniteSamps, 5);
DAQmxStartTask (gTaskHandle);


Please provide me with some feedback.  It would greatly be appreciated.
Thank You

    DAQmxErrChk DAQmxStopTask(gTaskHandle)
    DAQmxErrChk DAQmxClearTask(gTaskHandle)

0 Kudos
Message 4 of 10
(5,345 Views)

Hi pd_engineer,

To output digital pulses on the digital line you don’t need counters. In fact, as you’ve already pointed out, you only have 2 counters. (If you want to do continuous digital generation it only requires 1 counter, but finite requires 2.) Either way, you can only do digital generation in software with the PCI-6040E.

Start with the digital generation examples. Basically you are going to have Boolean arrays that represent the desired pattern and you will send in one element each iteration of a for loop to generate a high or low signal. The timing would be set with a timing VI inside the loop.

The pinouts of any device can be found in Measurement & Automation Explorer (MAX) by right-clicking the device and selecting “Device Pinouts”.

I hope this helps.

Mark E.
Precision DC Product Support Engineer
National Instruments

0 Kudos
Message 5 of 10
(5,314 Views)
Hi Everybody!

I am facing a similar problem, and I just can't get through it.

Task: I am controling a plant from within matlab (at least I want to 🙂 ). I'm writing a driver for my device (NI USB-6215). The input interface of the driver is working. The only thing left is the output. I need to create PVM sigmnals on the DO lines.

I found that the function I need is DAQmxCreateCOPulseChanTime.

I tried to configure it like this:

char chan0[256] = "Dev1/port1/line0";
DAQmxErrChk( DAQmxCreateCOPulseChanTime(thDigitalOut, chan0, "", DAQmx_Val_Seconds, DAQmx_Val_High, 0, 1, 0) );

And I get the message:

Measurements: I/O type of the physical channel does not match the I/O type required for the virtual channel you are creating.
Physical Channel Name: Dev1/port1/line0
Virtual Channel Name: Dev1/port1/line0
I/O Type Required for Virtual Channel: DAQmx_Val_CO

How can I make this thing work?

Best regards,

Kolumbán

Message Edited by Kolixx on 12-12-2007 06:18 AM
0 Kudos
Message 6 of 10
(5,198 Views)
For the future generations:

this is the resolving code:
DAQmxErrChk( DAQmxCreateCOPulseChanTime(thDigitalOutPWM0,"Dev1/ctr0","",DAQmx_Val_Seconds,DAQmx_Val_Low,0 , lowtime , hightime));
DAQmxErrChk( DAQmxCfgImplicitTiming(thDigitalOutPWM0, DAQmx_Val_ContSamps , 10 ));
DAQmxErrChk( DAQmxStartTask(thDigitalOutPWM0));
0 Kudos
Message 7 of 10
(5,173 Views)

Hey all,

I am trying to generate three digital pulses at the DIO port of SCB-68 using NI PCI 6024-E/NI PCI MIO 16E-1 (i have 2 cards) ....but some how not able to figure it out how to do this.....I have attached the timing diagram of what i need to do .....ALso i need to do this N number of times which should be user defined..Can any one please help me with this...

thank you,

regards,

Sandesh R

0 Kudos
Message 8 of 10
(4,554 Views)

Hello Sandesh!

 

Thank you for posting to the NI forums! Just to clarify, are you programming in LabVIEW or in a text based programming Language? We have many examples that will direct you on how to execute your application, but they are found in different places depending on the programming enviroment you are using. Please let me know what you are programming in and I will be able to direct you to the location of the examples as well as what example would be a good starting point. Have a great day!

Regards,
Margaret Barrett
National Instruments
Applications Engineer
Digital Multimeters and LCR Meters
0 Kudos
Message 9 of 10
(4,530 Views)

Hey Margaret,

Thankyou for replying.I am doing it using labview and I was able to do it today...

regards,

Sandesh R

 

0 Kudos
Message 10 of 10
(4,526 Views)