LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

task is invalid or does not exist

Hi,
I have an issue with Digital input acquisition ,  below is my code , I also attached my MAX configuration file
My problem is that I am loading th task from max and when         DAQmxLoadTask("DigitalInputs", &DigitalInputsTask); this function runs I receive an error
 NON-FATAL RUN-TIME ERROR:   "TestDIO.c", line 52, col 5, thread id 0x000000A4:   Function DAQmxLoadTask: (return value == -200089 [0xfffcf267]). Measurements: Task name specified conflicts with an existing task name. Task Name: DigitalInputs  Status Code: -200089
I don't understand why, it was working before I changed configuration from detect on event change with 1000 samples acquisition to on demand with 1 sample acquistion



#include <formatio.h>
#include <ansi_c.h>
#include <NIDAQmx.h>
//U8 to boolean[8]


#include <cvirte.h>       
#include <userint.h>
#include "TestDIO.h"

static int dio;
static int Quit;
typedef char bool8;

    int PowerFailureByte;
    int EngineFailureByte;
    int TemperatureFailureByte;
    int BrakeResistorFailureByte;
    int OilLevelHighByte;
    int OilLevelLowByte;
    double OilTankVal=100;
    int bit6;
    int bit7;

bool8 *ConvertU8to8Bool32Array(unsigned short int U8Val, bool8 BooleanArray[8]);

uInt8 DigitalInputsU8;
bool8 DigitalInputsBooleanArray[8];
uInt8 DigitalReadLine[8];

TaskHandle DigitalInputsTask;

int32 Spc= 1;
int32 Bps=8;
static unsigned short int U8Val;

int main (int argc, char *argv[])
{
    if (InitCVIRTE (0, argv, 0) == 0)
        return -1;    /* out of memory */
    if ((dio = LoadPanel (0, "TestDIO.uir", DIO)) < 0)
        return -1;
    DisplayPanel (dio);
   
    do{
   
        DAQmxLoadTask("DigitalInputs", &DigitalInputsTask);

        DAQmxStartTask(DigitalInputsTask);
     
        DAQmxReadDigitalLines(DigitalInputsTask, -1, 10, DAQmx_Val_GroupByChannel, DigitalReadLine, 8, &Spc, &Bps, 0);  
       
        SetCtrlVal(dio, DIO_NUMERIC, DigitalInputsU8);
       
       
    }while(Quit==0);   
   
     ConvertU8to8Bool32Array(DigitalInputsU8,DigitalInputsBooleanArray);
   
    PowerFailureByte =  DigitalInputsBooleanArray[0];
    EngineFailureByte =  DigitalInputsBooleanArray[1];
    TemperatureFailureByte = DigitalInputsBooleanArray[2];
    BrakeResistorFailureByte = DigitalInputsBooleanArray[3];
    OilLevelHighByte = DigitalInputsBooleanArray[4];
    OilLevelLowByte = DigitalInputsBooleanArray[5];
    bit6 = DigitalInputsBooleanArray[6];
    bit7 = DigitalInputsBooleanArray[7];
   
    SetCtrlVal(dio, DIO_LED_bit_1,PowerFailureByte);
    SetCtrlVal(dio, DIO_LED_bit_2,EngineFailureByte);
    SetCtrlVal(dio, DIO_LED_bit_3,TemperatureFailureByte);
    SetCtrlVal(dio, DIO_LED_bit_4,BrakeResistorFailureByte);
    SetCtrlVal(dio, DIO_LED_bit_5,OilLevelHighByte);    
    SetCtrlVal(dio, DIO_LED_bit_6,OilLevelLowByte);
    SetCtrlVal(dio, DIO_LED_bit_7,bit6);
    SetCtrlVal(dio, DIO_LED_bit_8,bit7);

    ProcessSystemEvents();

    RunUserInterface ();
    DiscardPanel (dio);
    return 0;
}


int CVICALLBACK QuitCallback (int panel, int control, int event,
        void *callbackData, int eventData1, int eventData2)
{
    switch (event)
    {
        case EVENT_COMMIT:
            Quit=1;
            QuitUserInterface(0);

            break;
    }
    return 0;
}


bool8 *ConvertU8to8Bool32Array(unsigned short int U8Val, bool8 BooleanArray[8])
{

    int i;
    int Rest=0;
   
   
    for(i=7; i>=0; i--)
    {
       
        Rest=U8Val-(pow(2,i));
        if (Rest<0)
        {
            BooleanArray[7-i]=0;
            Rest=U8Val;
        }
        else
        {
            BooleanArray[7-i]=1;
            U8Val= Rest;
        }
       
    }

return BooleanArray;
}


Thanks
       
0 Kudos
Message 1 of 3
(5,438 Views)
Hi,
I have tried to get back to the old configuration on event detection and it still gives me an error

0 Kudos
Message 2 of 3
(5,437 Views)
OK,
 I have found the pbm I should not put the loadtask function in the loop , but I still always get a 0 value on the port even if one of the inputs is at 5v
Message 3 of 3
(5,433 Views)