Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

WriteDigitalLines disables input operations(always read 0)

Hi,

I'm working on a software using NI6533 and Ni-Daqmx
I must get continuously data on 32 bits(port 0-3) and I want to send data on the control line not used(port5).
I build 2 tasks:
- 1 to read data each 0.5s
- 1 to write data on demand

here is a summary of my code:
// continuous acquisition
    i_res = DAQmxCreateTask("Tache Acquisition Dev2",&AcqDev2TaskHandle);
    if(i_res == 0)
        i_res = DAQmxCreateDIChan(AcqDev2TaskHandle, "Dev2/port0_32", "Start Dev2", DAQmx_Val_ChanForAllLines);        
    if(i_res == 0)
        i_res = DAQmxCfgSampClkTiming (AcqDev2TaskHandle, "OnboardClock", 2, DAQmx_Val_Rising, DAQmx_Val_ContSamps,                                                                               ONE_SAMPLE_PER_CHANEL);        
    if(i_res == 0)
    {
       i_res = DAQmxSetBufferAttribute(AcqDev2TaskHandle, DAQmx_Buf_Input_BufSize, 10000);
    }
   
    // output task
    if(i_res == 0)
        i_res = DAQmxCreateTask("Tache output",&SyncDev2TaskHandle);
   if(i_res == 0)
        i_res = DAQmxCreateDOChan(SyncDev2TaskHandle, "Dev2/port5/Line1", "", DAQmx_Val_ChanForAllLines);
    if(i_res == 0)
        i_res = DAQmxCreateDOChan(SyncDev2TaskHandle, "Dev2/port5/Line3", "", DAQmx_Val_ChanForAllLines);
    if(i_res == 0)
        e_res = ACQ_OK;
// read function used 
 i_res = DAQmxReadDigitalU32 (    AcqDev2TaskHandle,
                                    READ_ALL_SAMPLE,
                                    NO_TIMEOUT,
                                    DAQmx_Val_GroupByChannel,
                                    pui_sample,
                                    ONE_SAMPLE_PER_CHANEL,
                                    &iNumRead,
                                    NULL    );
// write function
int             i_sample_written     = 0;
unsigned char     pc_data[2]             = {0,1};
DAQmxWriteDigitalLines (SyncDev2TaskHandle, 1, 0, -1, DAQmx_Val_GroupByChannel, pc_data, &i_sample_written, 0) ;


My problem:
I read data correctly until I write data on port 5!
After a first call of the writing function, I can always read but when I call the write function for the second time, my read function returns always 0 as buffer read!!!
The Ni-DAQmx functions do not return any error.

If someone can help me, It would be wonderfull!!

Thanks

Greg

PS: I made some mistakes when posting the message. If an admin could delete the message with "des" as title 🙂
0 Kudos
Message 1 of 3
(3,321 Views)

Hi,

The 653x line of products have 4 available digital I/O ports. (not 5)

In handshaking mode, port 4 is reserved for the handshaking communication signals. If I am not in the handshaking mode, you free up port 4 to perform normal digital I/O. Here is the pinout match for port 4 when not in handshaking mode.

You can found on the link below, informations about that you want make.

Link :

http://digital.ni.com/public.nsf/websearch/4928E74CAD93831E86256E5A0070B778?OpenDocument

http://forums.ni.com/ni/board/message?board.id=70&message.id=1326&requireLogin=False

http://digital.ni.com/public.nsf/websearch/372EA5820B74C9BF86256856007D95D0?OpenDocument

http://digital.ni.com/public.nsf/websearch/BF6BB452E339B0F28625666B00505012?OpenDocument

Regards,

Christophe S.
Account Manager East of France І Certified LabVIEW Associate Developer І National Instruments France

0 Kudos
Message 2 of 3
(3,302 Views)
Thanks for your answer.

I use NiDAQ-mx and in NI 6533/6534 for NIDAQ-mx help file there is:

Control Lines

The NI 6533/6534 has two timing controllers (Group 0 and Group 1) for high-speed data transfer. Each group contains four control lines which can time the input/output of data with hardware precision. You can use Groups 0 and 1 to perform the following actions:

  • Generate or receive digital patterns and waveforms at regular intervals or timed by an external TTL signal
  • Transfer data between two devices using the handshaking or burst sample timing type
  • Acquire digital data every time the state of a data line changes (the change detection sample timing type)

Using Unused Control Lines as Extra Data Lines: Ports 4 and 5

If you are not using Group 0 and/or Group 1 as timing controllers for timed operations, you can use their control lines as extra data lines. These lines constitute Ports 4 and 5. The direction of these lines is not configurable—four lines are used as input only (Port 4), and four are used as output only (Port 5). On a per line basis, Port 5 lines can be configured for open collector generation.

Even though there are eight actual lines, the port widths are 4 bits. The following table shows the lines that make up Ports 4 and 5.

Direction Line Group I/O Pins Physical Channel Name (Lines)
Input 0 0 PFI 0 Dev1/port4/line0
1 1 PFI 1 Dev1/port4/line1
2 0 PFI 2 Dev1/port4/line2
3 1 PFI 3 Dev1/port4/line3
Output 0 0 PFI 4 Dev1/port5/line0
1 1 PFI 5 Dev1/port5/line1
2 0 PFI 6 Dev1/port5/line2
3 1 PFI 7 Dev1/port5/line3

So there is a port 5!

However I found a way to use without any problem the data card. I do not start any task and perform read (port0_32) and write (port5/Line1 and 3).
If I start any one of my 2 tasks, the read proccess is perturbed at the first write request.

If anyone can explain it to me.

Regards,

Greg

0 Kudos
Message 3 of 3
(3,291 Views)