Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

I need help with digital output NI-DAQmx

Hello, I need some help to write in a digital output.

 

I've an array datos[5], and a I've create a digital output like as:
DAQmxCreateDOChan(task,"Dev1/port0/line0:4","",DAQmx_Val_ChanForAllLines);

 

Then I start the task(what I created previusly):
DAQmxStartTask(task);

 

And then I write:
DAQmxWriteDigitalLines(task,1,1,10,DAQmx_Val_GroupByChannel,datos,0,NULL);

 

But all of that doesn't work.
What I want to do is if I have an array "datos" who values are "0,0,1,0,1",
the first 0 writes in the line0, the second 0 in the line1,...,the last 1 in the line4.

I'm programming in C language, and I've seen the Refence C of NI-DAQmx.

 

How I can to do this?

 

Thanks

0 Kudos
Message 1 of 4
(3,682 Views)

Hello Haiza,

 

You have written correctly the sequence of instructions, so it must works. The only thing is strange for me is that you have specified 0 instead on NULL or a var reference, the seventh parameter of DAQmxWriteDigitalLines.

 

I attach an example from NI-DAQmx driver. Compare with your code and look for your mistake.

 

Good luck.

0 Kudos
Message 2 of 4
(3,606 Views)

First of all I wanted to thank your quick answer, and tell you what I had a NULL value but I changed to 0. I'll change it again xD

I've a problem with the hardware, When I have arranged,  I'll try the code

Thanks

0 Kudos
Message 3 of 4
(3,601 Views)

Hello, Sendia!!

I still have the problem with de DO and de Analog Inputs.

The digital writes works perfect, but when I go to read the analog inputs doesn't works.

The problem is that AnalogInput always print 0.000 when it shouldn't be because the sensor value is 2.3 (for example)

 

My code:

 

MAIN:

 

    TaskHandle task; 

    DAQmxCreateTask("",&task);

    DAQmxCreateDOChan(task,"Dev1/port0/line0:4","",DAQmx_Val_ChanForAllLines);
    DAQmxCreateDIChan(task,"Dev1/port0/line0:4","",DAQmx_Val_ChanForAllLines); //To check the digital writes
    

    DAQmxTaskControl(task,DAQmx_Val_Task_Verify); 

    DAQmxStartTask(task); 
    
    for(i=0;i<3;i++) //This is to choose between the multiplexors   

   {
        for(j=0;j<8;j++)//to choose the sensors. Each multiplexor has a 8 sensors       

       {
            error = salida_digital(task,i,j);

            if(error==0)
                 entrada_analogica(taskAnalog,i,j); //In this function I've used readAnalog

       }

 }

 

//ENTRADA_ANALOGICA

    DAQmxReadAnalogScalarF64(task,10.0,&valor,NULL);
    printf("%.3f\n",valor);

 

 

 

0 Kudos
Message 4 of 4
(3,529 Views)