domenica 18 dicembre 2011
hist.c
// cd C:\Users\Studenti_Simone\Desktop\CorsoSimone\LezioneMilillo\3Novembre\ROOT
//root
//.L Hist.C
void PlotHistogram()
{
FILE *my_file = fopen("C:\\Users\\Studenti_Simone\\Desktop\\CorsoSimone\\Risorse\\isto.txt","r");
if(!my_file)
{
printf("\n file di input non trovato /n ");
return ;
};
//mettilo cosi ti toglie la prima riga!!!!!
char line[1024];
fgets(line,1025,my_file);
float dato ;
TH1F *hist=new TH1F ( " asse x ", " asse y ",10 , 10 , 20 ) ;
int i=0;
while (fscanf(my_file,"%f %*s",&dato) && i<1000)
{
//printf("%f\n", dato);
hist->Fill(dato);
i++;
}
i=0;
while ( i<=11)
{
printf("BinContent %f \n", hist->GetBinContent(i));
i++;
}
fclose(my_file);
TCanvas*c1=new TCanvas();
hist->Draw();
}
void PlotHistogram2D()
{
FILE *my_file = fopen("C:\\Users\\Studenti_Simone\\Desktop\\CorsoSimone\\Risorse\\isto.txt","r");
if(!my_file)
{
printf("\n file di input non trovato /n ");
return ;
};
//mettilo cosi ti toglie la prima riga!!!!!
char line[1024];
fgets(line,1025,my_file);
float dato1, dato2 ;
TH2F *hist=new TH2F ( " X ", " Ë Un bellissimo istogramma ",10, 0.05 , 0.5,20 , 16 , 32 ) ;
//su x ho messo slope su y N
while (fscanf(my_file,"%f %f",&dato1, &dato2) && !feof(my_file))
{
//printf("%f\n", dato);
hist->Fill(dato2,dato1);
}
fclose(my_file);
TCanvas*c1=new TCanvas();
hist->SetMarkerColor(2);
hist->SetMarkerStyle(6);
hist->Draw();
}
void motobalistico()
{
double v0x=4, v0y=6, passo=0.001 ;
int t=30, i=0 , step=50;
double x[51] , y[51];
// creare un grafico
TGraph *gr = new TGraph(t,x,y);
while (i<step){
x[i]=v0x*i;
y[i]=(v0y*i)-(0.5*9.28*i*i);
gr->SetPoint(i,x[i],y[i]);
i++;
}
TCanvas*c1=new TCanvas("C1","Cinematica", 200,10, 600, 400);
gr->Draw("AC*");
// Draw A = mostra assi * mostra il segno sul punto
//TMath::Sin()
}
void PlotHistogramSlope()
{
FILE *my_file = fopen("C:\\Users\\Studenti_Simone\\Desktop\\CorsoSimone\\Risorse\\isto.txt","r");
if(!my_file)
{
printf("\n file di input non trovato /n ");
return ;
};
//mettilo cosi ti toglie la prima riga!!!!!
char line[1024];
fgets(line,1025,my_file);
// ISTOGRAMMA PER SLOPE
float dato ;
TH1F *hist=new TH1F ( " Slope", " asse y ",100 , -0.03 , 0.5 ) ;
int i=0;
while (fscanf(my_file," %*s %f ",&dato) && i<1000)
{
//printf("%f\n", dato);
hist->Fill(dato);
i++;
}
i=0;
while ( i<=11)
{
printf("BinContent %f \n", hist->GetBinContent(i));
i++;
}
//fclose(my_file);
TCanvas*c1=new TCanvas();
hist->SetFillColor(2);
hist->Draw();
// ISTOGRAMMA PER N
//mi riposiziono sennÚ Root legge sempre l'ultimo
rewind(my_file);
char line2[1024];
fgets(line2,1025,my_file);
i=0;
float dato2 ;
TH1F *hist2=new TH1F ( "N ", " asse y ",20 ,11 , 31 ) ;
int i=0;
while (fscanf(my_file,"%f %*s",&dato2) && i<1000)
{
//printf("%f\n", dato2);
hist2->Fill(dato2);
i++;
}
i=0;
while ( i<=11)
{
printf("BinContent %f \n", hist2->GetBinContent(i));
i++;
}
fclose(my_file);
TCanvas*c2=new TCanvas();
hist2->SetFillColor(kOrange -3);
hist2->Draw();
}
void Dipendenza()
{
FILE *my_file = fopen("C:\\Users\\Studenti_Simone\\Desktop\\CorsoSimone\\Risorse\\isto.txt","r");
if(!my_file)
{
printf("\n file di input non trovato /n ");
return ;
};
//mettilo cosi ti toglie la prima riga!!!!!
char line[1024];
fgets(line,1025,my_file);
float dato, dato2 ;
//Bin1
TH1F *hist0=new TH1F ( " Bin1 ", " asse y ",25 , 10 , 35 ) ;
TH1F *slope0=new TH1F ( " Slope1 ", " asse y ",10 , 0 , 0.06 ) ;
int i=0;
while (fscanf(my_file,"%f %f",&dato , &dato2) && i<3100)
{
if(dato2<0.05 && dato>15){
//printf("%f\n", dato);
slope0->Fill(dato2);
hist0->Fill(dato);
}
i++;
}
rewind(my_file);
fgets(line,1025,my_file);
//Bin2
TH1F *hist=new TH1F ( " Bin2 ", " asse y ",25 , 10 , 35 ) ;
int i=0;
while (fscanf(my_file,"%f %f",&dato , &dato2) && i<3100)
{
if(dato2<0.15 && dato2>0.05 && dato>15){
//printf("%f\n", dato);
hist->Fill(dato);
}
i++;
}
rewind(my_file);
fgets(line,1025,my_file);
//Bin 3
TH1F *hist2=new TH1F ( " Bin3 ", " asse y ",25 , 10 , 35 ) ;
int i=0;
while (fscanf(my_file,"%f %f",&dato , &dato2) && i<3100)
{
if(dato2>0.15 && dato2<0.25 && dato>15){
//printf("%f\n", dato);
hist2->Fill(dato);
}
i++;
}
rewind(my_file);
fgets(line,1025,my_file);
//Bin 4
TH1F *hist4=new TH1F ( " Bin4 ", " asse y ",25 , 10 , 35 ) ;
int i=0;
while (fscanf(my_file,"%f %f",&dato , &dato2) && i<3100)
{
if(dato2>0.15 && dato2<0.25 && dato>15){
//printf("%f\n", dato);
hist4->Fill(dato);
}
i++;
}
i=0;
while ( i<=11)
{
printf("BinContent %f \n", hist->GetBinContent(i));
i++;
}
fclose(my_file);
TCanvas*c1=new TCanvas();
c1->Divide(2,3);
c1->cd(2);
hist->Draw();
c1->cd(3);
hist2->Draw();
c1->cd(1);
hist0->Draw();
c1->cd(4);
hist4->Draw();
c1->cd(5);
slope0->Draw();
}
void graficoTemp()
{
int i=0;
double x[1500] , y[1500], m[1500];
FILE *my_file = fopen("C:\\Users\\Studenti_Simone\\Desktop\\CorsoSimone\\Risorse\\RisultatoTempDay.txt","r");
if(!my_file)
{
printf("\n file di input non trovato /n ");
return ;
};
TGraph *gr = new TGraph(i,x,y);
//su x ho messo slope su y N
while (fscanf(my_file,"%*s %lf %lf",&x[i], &y[i]) && !feof(my_file))
{
printf("%f\n", x[i]);
m[i]=(((y[i]-y[0])/60)/60);
gr->SetPoint(i,m[i],x[i]);
i++;
}
fclose(my_file);
TCanvas*c1=new TCanvas("C1","Temperatura", 200,10, 400, 500);
gr->Draw("A*");
// Draw A = mostra assi * mostra il segno sul punto
//TMath::Sin()
}
Monitor temperatura
#include <stdio.h>
#include <NIDAQmx.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
void wait ( int seconds )
{
clock_t endwait;
endwait = clock () + seconds * CLOCKS_PER_SEC ;
while (clock() < endwait) {}
}
int main(void)
{
time_t rawtime;
struct tm * timeinfo;
time ( &rawtime );
time_t seconds;
int flag=0;
double temp=0;
int i=0;
uInt8 s=0;
uInt8 Dati[8]={0,0,0,0,0,0,0,0};
uInt8 Porta1[2]={0,0};
uInt8 LED[8]={1,0,0,0,0,0,0,0};
TaskHandle tk1, tk2, tk3, tk4, data, led, t, t2; ;
DAQmxCreateTask("tk1",&tk1);
DAQmxCreateTask("tk2",&tk2);
DAQmxCreateTask("tk3",&tk3);
DAQmxCreateTask("tk4",&tk4);
DAQmxCreateTask("Data",&data);
DAQmxCreateTask("led",&led);
DAQmxCreateTask("task1",&t);
//Creo File
FILE *fp = fopen("C:\\Users\\Studenti_Simone\\Desktop\\CorsoSimone\\Risorse\\RisultatoTemp.txt","w");
if(!fp)
{
printf("\n file di input non trovato \n");
system("pause");
return 0;
};
for(flag = 0; flag <= 1000; flag++)
{
//Output channel
DAQmxCreateDOChan(tk1, "Dev1/port1/line0", "Output1", DAQmx_Val_ChanForAllLines);
DAQmxStartTask(tk1);
DAQmxCreateDOChan(tk2, "Dev1/port1/line7", "Output2", DAQmx_Val_ChanForAllLines);
DAQmxStartTask(tk2);
DAQmxCreateDOChan(tk3, "Dev1/port1/line6", "Output3", DAQmx_Val_ChanForAllLines);
DAQmxStartTask(tk3);
DAQmxCreateDOChan(led, "Dev1/port0/line0:7", "Output4", DAQmx_Val_ChanForAllLines);
DAQmxCreateDOChan(t, "Dev1/port1/line0:1", "input", DAQmx_Val_ChanForAllLines);
//Input Channel
DAQmxCreateDIChan(tk4, "Dev1/port2/line1", "input1", DAQmx_Val_ChanForAllLines);
DAQmxStartTask(tk4);
DAQmxCreateDIChan(data, "Dev1/port0/line0:7", "InputData", DAQmx_Val_ChanForAllLines);
DAQmxStartTask(data);
//Otput Reset linea 1.0
DAQmxWriteDigitalLines(tk1,1,0,10,DAQmx_Val_GroupByChannel,&s,NULL,NULL);
s=1;
DAQmxWriteDigitalLines(tk1,1,0,10,DAQmx_Val_GroupByChannel,&s,NULL,NULL);
s=0;
DAQmxWriteDigitalLines(tk1,1,0,10,DAQmx_Val_GroupByChannel,&s,NULL,NULL);
//Output Start Conversion linea 1.7
DAQmxWriteDigitalLines(tk2,1,0,10,DAQmx_Val_GroupByChannel,&s,NULL,NULL);
s=1;
DAQmxWriteDigitalLines(tk2,1,0,10,DAQmx_Val_GroupByChannel,&s,NULL,NULL);
s=0;
DAQmxWriteDigitalLines(tk2,1,0,10,DAQmx_Val_GroupByChannel,&s,NULL,NULL);
//printf(" Waiting for data ready on linea 2.1\n");
i = 0;
while(s==1){
//printf("Step %d:\nlinea2.1 %d \n", i,s);
DAQmxReadDigitalLines(tk4,1,10,DAQmx_Val_GroupByChannel,&s,1,NULL,NULL,NULL);
i++;
};
s=0;
//Output Data Enable 1.6
DAQmxWriteDigitalLines(tk3,1,0,10,DAQmx_Val_GroupByChannel,&s,NULL,NULL);
s=1;
DAQmxWriteDigitalLines(tk3,1,0,10,DAQmx_Val_GroupByChannel,&s,NULL,NULL);
//printf(" linea 1.6 abilitata\n");
//Fase di lettura porta 8 Bit
//printf("Fase di Lettura : Inizio lettura porta0 a 8 bit\n");
//operazione di lettura
DAQmxReadDigitalLines(data,1,1,DAQmx_Val_GroupByChannel,Dati,8,NULL,NULL,NULL);
// FIne Lettura
i=0;
while(i!=8){
printf("%d", Dati[i]);
fprintf(fp,"%d" ,Dati[i]);
temp=(Dati[i]*pow(2.,i))/2+temp;
i++;
}
fprintf(fp,"\t" );
seconds = time (NULL);
timeinfo = localtime ( &rawtime );
printf("-> %.1f C %ld sec %s", temp, seconds,asctime (timeinfo));
fprintf(fp,"%f\t%ld\t%s\n" ,temp,seconds,asctime (timeinfo));
temp=0;
printf(" \n");
//Output Data Disable 1.6
s=0;
DAQmxWriteDigitalLines(tk3,1,0,10,DAQmx_Val_GroupByChannel,&s,NULL,NULL);
DAQmxStopTask(tk1);
DAQmxStopTask(tk2);
DAQmxStopTask(tk3);
DAQmxStopTask(tk4);
DAQmxStopTask(data);
//segnali di inizializzazione
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);
printf("\a");
DAQmxStartTask(led);
//visualizzo sui led
DAQmxWriteDigitalLines(led,1,0,1,DAQmx_Val_GroupByChannel,Dati,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);
wait(2);
DAQmxStopTask(t);
DAQmxStopTask(led);
}
fclose(fp);
system("pause");
}
Lettura registro a 8 bit
#include <stdio.h>
#include <NIDAQmx.h>
#include <stdlib.h>
int main(void)
{
uInt8 Porta1[3]={0,0,0};
uInt8 OneEl[1]={0};
uInt8 c=0;
int flag=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 Dati[8]={0,0,0,0,0,0,0,0};
uInt32 a=1;
int i = 0;
TaskHandle t;
TaskHandle DDisp ;
TaskHandle t2;
TaskHandle t3;
TaskHandle LEDd;
DAQmxCreateTask("LED",&LEDd);
DAQmxCreateTask("task1",&t);
DAQmxCreateTask("DDisp",&DDisp);
DAQmxCreateTask("task2",&t2);
DAQmxCreateTask("task3",&t3);
while(flag!=10)
{
printf("Set Registro\n");
system("pause");
//creo un canale di output digitale associato al dato task t
DAQmxCreateDOChan(t, "Dev1/port1/line0:2", "Output", DAQmx_Val_ChanForAllLines);
DAQmxStartTask(t);
DAQmxCreateDIChan(DDisp, "Dev1/port2/line1", "input", DAQmx_Val_ChanForAllLines);
DAQmxStartTask(DDisp);
DAQmxCreateDIChan(t3, "Dev1/port0/line0:7", "input3", DAQmx_Val_ChanForAllLines);
DAQmxStartTask(t3);
//Inizializzazione segnale di reset(linea 1.0)
DAQmxWriteDigitalLines(t,1,0,10,DAQmx_Val_GroupByChannel,Porta1,NULL,NULL);
Porta1[0]=1;
DAQmxWriteDigitalLines(t,1,0,10,DAQmx_Val_GroupByChannel,Porta1,NULL,NULL);
Porta1[0]=0;
DAQmxWriteDigitalLines(t,1,0,10,DAQmx_Val_GroupByChannel,Porta1,NULL,NULL);
//Fine inizializzazione
//Inizio data Request (linea 1.2)
//printf("Inizio Data-request (linea 1.2):\n");
//Porta1[1] sta gi‡ a 0 quindi mando il comando
//DAQmxWriteDigitalLines(t,1,0,1,DAQmx_Val_GroupByChannel,Porta1,NULL,NULL);
Porta1[2]=1;
DAQmxWriteDigitalLines(t,1,0,10,DAQmx_Val_GroupByChannel,Porta1,NULL,NULL);
//printf("Fine Data-request (linea 1.2):\n");
//Fine data Request (linea 1.2)
//Verifico Disponibilit‡ dati ( cioË se linea2.1 Ë nello stato alto
//printf("Verifico Disponibilit‡ dei dati (linea 2.1):\n");
//creo un canale di input digitale associato al dato task DDisp
/*DAQmxCreateDIChan(DDisp, "Dev1/port2/line1", "input", DAQmx_Val_ChanForAllLines);
DAQmxStartTask(DDisp);*/
// se la linea 2.1 Ë nello stato alto i dati possono essere letti
i = 0;
while(c==0){
//printf("Step %d:\nlinea2.1 %d \n", i,c);
DAQmxReadDigitalLines(DDisp,1,10,DAQmx_Val_GroupByChannel,&c,a,NULL,NULL,NULL);
i++;
};
c=0;
// Fine lettura linea 2.1
// Fase di Lettura : richiedo abilitazione su linea 1.3
//printf("Fase di Lettura : richiedo abilitazione su linea 1.3\n");
DAQmxCreateDOChan(t2, "Dev1/port1/line3", "input", DAQmx_Val_ChanForAllLines);
DAQmxStartTask(t2);
OneEl[0]=0;
DAQmxWriteDigitalLines(t2,1,0,1,DAQmx_Val_GroupByChannel,OneEl,NULL,NULL);
OneEl[0]=1;
DAQmxWriteDigitalLines(t2,1,0,1,DAQmx_Val_GroupByChannel,OneEl,NULL,NULL);
//printf(" linea 1.3 abilitata\n");
OneEl[0]=1;
// abilitazione compleatata
// Inizio lettura Porta0 a 8 bit
printf("Fase di Lettura : Inizio lettura porta0 a 8 bit\n");
//operazione di lettura
DAQmxReadDigitalLines(t3,1,1,DAQmx_Val_GroupByChannel,Dati,8,NULL,NULL,NULL);
// FIne Lettura
i=0;
while(i!=8){
printf(" %d ", Dati[i]);
i++;
}
// Riporto a basso le linee 1.3 1.2
//linea 1.3
OneEl[0]=0;
DAQmxWriteDigitalLines(t2,1,0,1,DAQmx_Val_GroupByChannel,OneEl,NULL,NULL);
//linea 1.2
Porta1[0]=0;
Porta1[2]=0;
DAQmxWriteDigitalLines(t,1,0,1,DAQmx_Val_GroupByChannel,Porta1,NULL,NULL);
// Inizio Accensione LEDd con i dati letti
// chiudo il task che usa in input la porta0
DAQmxStopTask(t3);
printf("Inizio Accensione LEDd con i dati letti 1 \n");
DAQmxCreateDOChan(LEDd, "Dev1/port0/line0:7", "Output2", DAQmx_Val_ChanForAllLines);
DAQmxStartTask(LEDd);
printf("inizzializzo:\n");
printf("spento\n");
//Segnale Spegnimento
DAQmxWriteDigitalLines(LEDd,1,0,1,DAQmx_Val_GroupByChannel,Dati,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);
/*
printf("inizzializzo:\n");
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);
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);
DAQmxStopTask(LEDd);
DAQmxStopTask(DDisp);
system("pause");
flag++;
}
}
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);
}
martedì 28 dicembre 2010
mercoledì 6 ottobre 2010
Iscriviti a:
Post (Atom)