domenica 18 dicembre 2011
Accensione LED
#include <stdio.h>
#include <NIDAQmx.h>
#include <stdlib.h>
int main(void)
{
uInt8 Porta1[2]={0,0};
uInt8 LED[8]={1,0,0,0,0,0,0,0};
uInt8 LED2[8]={0,0,0,0,0,0,0,1};
uInt8 Spento[8]={0,0,0,0,0,0,0,0};
/*uInt8 Dat[8][8]={{0,0,0,0,0,0,0,0},
,{0,0,0,1,0,0,0,0},{0,0,1,0,0,0,0,0},
,{0,0,1,1,0,0,0,0},
,{0,1,0,0,0,0,0,0},
,{0,1,0,1,0,0,0,0},
{0,1,1,0,0,0,0,0},
{0,1,1,1,0,0,0,0},
{1,0,0,0,0,0,0,0},
{1,0,0,1,0,0,0,0}}*/
int i = 0;
float flag ;
TaskHandle t;
TaskHandle t2;
DAQmxCreateTask("task1",&t);
DAQmxCreateTask("task2",&t2);
DAQmxCreateDOChan(t, "Dev1/port1/line0:1", "input", DAQmx_Val_ChanForAllLines);
DAQmxStartTask(t);
DAQmxWriteDigitalLines(t,1,0,1,DAQmx_Val_GroupByChannel,Porta1,NULL,NULL);
Porta1[0]=1;
DAQmxWriteDigitalLines(t,1,0,1,DAQmx_Val_GroupByChannel,Porta1,NULL,NULL);
Porta1[0]=0;
DAQmxWriteDigitalLines(t,1,0,1,DAQmx_Val_GroupByChannel,Porta1,NULL,NULL);
DAQmxCreateDOChan(t2, "Dev1/port0/line0:7", "input", DAQmx_Val_ChanForAllLines);
DAQmxStartTask(t2);
printf("inizzializzo:\n");
printf("spento\n");
//Segnale Spegnimento
DAQmxWriteDigitalLines(t2,1,0,1,DAQmx_Val_GroupByChannel,Spento,NULL,NULL);
//Segnale di scrittura per rendere effettivo lo spegnimento
Porta1[1]=0;
DAQmxWriteDigitalLines(t,1,0,1,DAQmx_Val_GroupByChannel,Porta1,NULL,NULL);
Porta1[1]=1;
DAQmxWriteDigitalLines(t,1,0,1,DAQmx_Val_GroupByChannel,Porta1,NULL,NULL);
Porta1[1]=0;
DAQmxWriteDigitalLines(t,1,0,1,DAQmx_Val_GroupByChannel,Porta1,NULL,NULL);
system("pause");
printf("Vettore 1\n");
//Accendo 1 si 1 no
DAQmxWriteDigitalLines(t2,1,0,1,DAQmx_Val_GroupByChannel,LED,NULL,NULL);
//abilito scrittura
Porta1[1]=0;
DAQmxWriteDigitalLines(t,1,0,1,DAQmx_Val_GroupByChannel,Porta1,NULL,NULL);
Porta1[1]=1;
DAQmxWriteDigitalLines(t,1,0,1,DAQmx_Val_GroupByChannel,Porta1,NULL,NULL);
Porta1[1]=0;
DAQmxWriteDigitalLines(t,1,0,1,DAQmx_Val_GroupByChannel,Porta1,NULL,NULL);
system("pause ");
printf("Vettore 8\n");
//Accendo 1 si 1 no
DAQmxWriteDigitalLines(t2,1,0,1,DAQmx_Val_GroupByChannel,LED2,NULL,NULL);
Porta1[1]=0;
DAQmxWriteDigitalLines(t,1,0,1,DAQmx_Val_GroupByChannel,Porta1,NULL,NULL);
Porta1[1]=1;
DAQmxWriteDigitalLines(t,1,0,1,DAQmx_Val_GroupByChannel,Porta1,NULL,NULL);
Porta1[1]=0;
DAQmxWriteDigitalLines(t,1,0,1,DAQmx_Val_GroupByChannel,Porta1,NULL,NULL);
system("pause");
printf("spento\n");
//Segnale Spegnimento
DAQmxWriteDigitalLines(t2,1,0,1,DAQmx_Val_GroupByChannel,Spento,NULL,NULL);
//Segnale di scrittura
Porta1[1]=0;
DAQmxWriteDigitalLines(t,1,0,1,DAQmx_Val_GroupByChannel,Porta1,NULL,NULL);
Porta1[1]=1;
DAQmxWriteDigitalLines(t,1,0,1,DAQmx_Val_GroupByChannel,Porta1,NULL,NULL);
Porta1[1]=0;
DAQmxWriteDigitalLines(t,1,0,1,DAQmx_Val_GroupByChannel,Porta1,NULL,NULL);
DAQmxStopTask(t);
DAQmxStopTask(t2);
}
Iscriviti a:
Commenti sul post (Atom)
Nessun commento:
Posta un commento