Quantcast
Channel: Counter/Timer topics
Viewing all articles
Browse latest Browse all 1271

Use multiple counters on PCI 6601

$
0
0

Hello, my name is Igor and i'm an young VB6 programmer. I'm an electronic engineer but i never used this language to my study.

 

My problem is "simple", i need to measure 3 PWM with an PCI 6601, this is the easy, but my problem is the reading's times.

 

The frequency that i would to measure is 1Khz and if i measure only one channel no problem, i have 1000 samples for second. If i want measure 2 or more PWM the numbers of measure drop to 22 (case with 3 counters).

 

The code is

 

   'Questa funzione serve a creare il canale dalla quale poi viene effettuata la misura
    DAQmxErrChk DAQmxCreateCIPulseWidthChan(taskHandle1, "Dev1/ctr0", MyChannel1, 0.00001, _
    0.00009, DAQmx_Val_TimeUnits3_Seconds, DAQmx_Val_Edge1_Rising, "")
    DAQmxErrChk DAQmxCreateCIPulseWidthChan(taskHandle2, "Dev1/ctr1", MyChannel2, 0.00001, _
    0.00009, DAQmx_Val_TimeUnits3_Seconds, DAQmx_Val_Edge1_Rising, "")
    DAQmxErrChk DAQmxCreateCIPulseWidthChan(taskHandle3, "Dev1/ctr2", MyChannel3, 0.00001, _
    0.00009, DAQmx_Val_TimeUnits3_Seconds, DAQmx_Val_Edge1_Rising, "")

    'Setta il numero di campioni da acquisire ogni volta che va in lettura e
    'il modo di lettura. Si è impostato "contsamps" per avere la lettura continua
'    DAQmxErrChk DAQmxCfgImplicitTiming(taskHandle1, DAQmx_Val_AcquisitionType_ContSamps, 1)
'    DAQmxErrChk DAQmxCfgImplicitTiming(taskHandle2, DAQmx_Val_AcquisitionType_ContSamps, 1)
'    DAQmxErrChk DAQmxCfgImplicitTiming(taskHandle3, DAQmx_Val_AcquisitionType_ContSamps, 1)
    

'parte di prova per lettura di 3 task
    Tm = Timer
    counter = 0
    counter1 = 0
    'While per vedere quanti campioni legge in un secondo. IL numero di counter va
    'poi diviso per due. Si è fatto così almeno si salva sia il periodo basso
    'che quello alto
    DAQmxErrChk DAQmxStartTask(taskHandle1)
    task1IsRunning = True
    DAQmxErrChk DAQmxStartTask(taskHandle2)
    task2IsRunning = True
    DAQmxErrChk DAQmxStartTask(taskHandle3)
    task3IsRunning = True
    'task1IsRunning = True
    Do While (Timer < (Tm + 1))
        DoEvents
        DAQmxErrChk DAQmxReadCounterScalarF64(taskHandle1, 0.005, data1, ByVal 0&)
        DAQmxErrChk DAQmxReadCounterScalarF64(taskHandle2, 0.005, data2, ByVal 0&)
        DAQmxErrChk DAQmxReadCounterScalarF64(taskHandle3, 0.005, data3, ByVal 0&)
        
'        DAQmxErrChk DAQmxReadCounterF64(taskHandle1, 1, 0.005, data1(0), 1, 1, ByVal 0&)
'        DAQmxErrChk DAQmxReadCounterF64(taskHandle2, 1, 0.005, data2(0), 1, 1, ByVal 0&)
'        DAQmxErrChk DAQmxReadCounterF64(taskHandle3, 1, 0.005, data3(0), 1, 1, ByVal 0&)
        counter = counter + 1
    Loop
    counter1 = counter
'fine prova
 

If i use '    DAQmxErrChk DAQmxCfgImplicitTiming(taskHandle1, DAQmx_Val_AcquisitionType_ContSamps, 1) i read faster but i can't use this function for evry task because the pci6601 have only one dma and i've try to change read mechanism but i not arrived to the solution.

 

Can you help me??

 

Sorry for my english that are not so good.

 

Best regards

 

Igor

 

 


Viewing all articles
Browse latest Browse all 1271

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>