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

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

 

 


How can I set auto trigger : off in AG5313xA ?

$
0
0

Dear All

 

I try set config "Level.vi" at trigger level type : volt and trigger level : 0.

 

 

But I still found auto trigger : ON in AG5313xA.

 

Best regard,

Sermsak

How do I get a timestamp for each daq counter measurement?

$
0
0

Hello, I am currently using DAQmx to read a PWM signal and calculate the pulse width using the implicit timer. Is it possible to also get the timestamp of each pulse width measurement? I have been able to do this with an analog signal by using a waveform output, but I can't figure out how to do this with a counter measurement. Thanks in advance for the help!

Tachometer

$
0
0

I am new at this but do have some knowledge on the subject. I am building a digital tachometer for a college project and have picked the 555 timer and icm 7217 chip.. i do not want to use a microcontroler. Is this the right approach and I would want to hook 4 digit 7 segment segment display. Any advise would surely help.

 

Thanks

Richard62

PCI-6602 routing limitation

$
0
0

I am trying to use 4 counters to generate 4 signals, synchronized with external trigger (PFI 38). If I use counters 0 to 3, it fails to build a route connecting counter 0 internal output with start trigger of counter 1. - as on attached snippet.

If I use any other counter (4 to 7) instead of counter 0, it works fine.

I could not find anything forbidding the first configuration in NI Max device routes table. It shows only ArmStart trigger connections, they are directly connected to counters' internal outputs if in the same half (0-3 or 4-7) and through trigger bus if in the other. 

Is there a way to develop a configuration like that without trying? Am I reading something wrong, is there complete routing documentation somewhere? 

 

Daq mx 9.3, MAX 5.0

 

 

 

Counter output cannot update duty cycle...?

$
0
0

I'm encountering (pun not intended) a strange issue with my counter generation. I am currently using this example (https://decibel.ni.com/content/docs/DOC-8306) to generate a PWM signal that can change the PWM frequency on the fly. The VI from the link works beautifully.

 

... However, it's when I build an equivalent VI in Labview 2012 that I start encountering problems. It keeps telling me that it cannot update the duty/frequency because the previous cycle was not completed. I placed various wait and "is done?" blocks before the property node to no avail. Short of putting a stop before the property node, I'm really curious as to why this is not working from Labview 8 to 2012. I've even started up a blank VI, copy/pasted the reference code, and having the same error message pop up. For reference, I've included the 2012 VI. The reference VI can be found at the link above.

 

 

I do know the alternative is to write single pulses for each while loop iteration (similar to http://zone.ni.com/devzone/cda/epd/p/id/5712) but I'd like to understand why my previous attempts did not work.

 

 

Thanks!

 

 

edit: I should also state that I'm using the myDAQ as my hardware platform.

6602 Buffer size

$
0
0

Respected SIr,

I am using 6602 timer/counter card for time stamping random events having count rate of 10,000 cps. For this purpose I am using NI test program "Measure Buffered Period (NI-TIO).vi". Acqisition time is 1 hour. When i am setting the buffer size to 1,65,00,000 the program is working fine. But when i change the setting to say 1,70,00,000, it is shouting the error (Error 10444 occured at counter control) attached to this post. I would like to know the maximum buffer size supported by 6602 card so that i will able to log the data for the above said count rate for 1 hour. 

Large frequency counter method reading data at higher rate

$
0
0

Iam using ni 6341 USB device and using Large frequency counter method to measure frequency from 0hz to 10khz which is varying at 200ms but iam not able to get the data perfectly in the chart as well as while  logging the data.The data  comes is of 1 s  instead of 400ms (200 ms for reaching  from 0-10khz and 200ms from 10khz-0).Iam confused as it works for  the ramp (0-500hz at 200ms and 500hz-0hz at 200ms).

 

I have given sweep (square wave) start frquency 0Hz and stop frequency 10kz with sweep time 200ms and return time 200ms from signal generator and also tested this in the oscilloscope but when i tried  meassuring with ni usb 6341 the problem was occuring .I have connected to counter 0 of 6341


Trouble setting up an encoder input and PWM output tasks on CompactDAQ

$
0
0

I am using a cDAQ-9174 chassis with a 9474 and 9411 modules. I don't believe it matters but they are the old NI cRIO-XXXX modules that came with a test setup that was distributed to early adopters. I am using DAQmx tasks in an application (C libraries) to read a quadrature encoder (angular position) and to drive a motor directly with PWM current (pulse output). To satisfy various other requirements, my setup of the tasks is as follows:

 

[DAQmx] MajorVersion = 9

MinorVersion = 2

[DAQmxChannel GenV 9411 Rotary Encoder Input/AngularPosition]

CI.AngEncoder.PulsesPerRev = 500

CI.AngEncoder.InitialAngle = 0

CI.Encoder.ZIndexVal = 0

CI.Encoder.ZIndexPhase = A High B Low

CI.Encoder.ZIndexEnable = 0

ChanType = Counter Input

CI.MeasType = Position:Angular Encoder

CI.AngEncoder.Units = Ticks

PhysicalChanName = cDAQ1Mod2/ctr2

CI.Encoder.DecodingType = X4

 

[DAQmxChannel GenV 9474 PWM Output/PulseOutput]

CO.Pulse.IdleState = Low

ChanType = Counter Output

CO.OutputType = Pulse:Time

CO.Pulse.HighTime = 5.0000000000000004E-006

CO.Pulse.LowTime = 5.0000000000000002E-005

CO.Pulse.Time.InitialDelay = 0

CO.Pulse.Time.Units = Seconds

PhysicalChanName = cDAQ1Mod1/ctr3

 

[DAQmxTask GenV 9411 Rotary Encoder Input]

Channels = GenV 9411 Rotary Encoder Input/AngularPosition

SampQuant.SampMode = Continuous Samples

SampClk.ActiveEdge = Rising

SampQuant.SampPerChan = 100000

SampClk.Rate = 100000

SampTimingType = Sample Clock

SampClk.src=/cDAQ1/100kHzTimebase

 

[DAQmxTask GenV 9474 PWM Output]

Channels = GenV 9474 PWM Output/PulseOutput

SampQuant.SampMode = Continuous Samples

SampQuant.SampPerChan = 100000

SampTimingType = Implicit

RegenMode = Allow Regeneration

 

[DAQmxCDAQChassis cDAQ1

] ProductType = cDAQ-9174

DevSerialNum = 0x18B3EC0

 

[DAQmxCDAQModule cDAQ1Mod1]

ProductType = NI 9474

DevSerialNum = 0xDEDF40

CompactDAQ.ChassisDevName = cDAQ1

CompactDAQ.SlotNum = 1

 

[DAQmxCDAQModule cDAQ1Mod2]

ProductType = NI 9411

DevSerialNum = 0xDEDB24

CompactDAQ.ChassisDevName = cDAQ1

CompactDAQ.SlotNum = 2

 

Each task works fine on its own (i.e., without the other). The problem is that if I start the encoder task first and then the PWM task, the latter causes an error:

 

Error -89137 occurred at DAQ Assistant
Possible Reason(s):
Specified route cannot be satisfied, because it requires resources that are currently in use by another route.

Source Device: cDAQ1
Source Terminal:
80MHzTimebase
Destination Device: cDAQ1
Destination
Terminal:
Ctr3Source

Required Resources in Use bySource
Device:
cDAQ1
Source Terminal: 100kHzTimebase
Destination
Device:
cDAQ1
Destination Terminal: Ctr2SampleClock

Task Name: _unnamedTask<61>

 

I don't know why that is but if I start the PWM task first and then the encoder task, it also works. I should also mention that initally I was using counter 0 for the encoder, which caused a redirection of 100kHzTimebase to Ctr0SampleClock, which, according to the 9411 device routes, is not supported; yet it worked (by itself). I wonder if what is actually happening under the hood is not quite what is being shown.

 

What exactly is the conflict and what can I do to avoid it? The reasons for needing to use the specific modes and parameters chosen (e.g., the "continuous samples" with the 100kHzTimebase clock) are rooted in various performance and optimization requirements that have been established in a previous version of our software, so I'd prefer not taking a completely different route, if some small changes would lead us to correcting the problem.

 

I appreciate your assistance.

Kamen

read no. of pulse count with fixed time interval

$
0
0

Hi,

I am try to read no of pulse count ( Pulse period = 500ms, On time = 100msec and Off time = 400msec). Between pulses there is a fixed time interval of 2seconds. I am using NI USB DAQ 6341. Can anybody help me regarding this? 

ReadSingleSampleDouble

$
0
0

I'm trying to use a two edge separation counter, and I have it configured as such...

 

CWCounter3Task = new Task();
CWCounter3FirstEdge = CITwoEdgeSeparationFirstEdge.Rising;
CWCounter3SecondEdge = CITwoEdgeSeparationSecondEdge.Rising;
CWCounter3Task.CIChannels.CreateTwoEdgeSeparationChannel("Dev1/Ctr3", "Outbound",
minVal, maxVal, CWCounter3FirstEdge, CWCounter3SecondEdge,
NationalInstruments.DAQmx.CITwoEdgeSeparationUnits.Seconds);

 

The resulting call to ReadSingleSampleDouble, doesn't seem to be returning consistent results.  In some of the cases it's returning a value that is approximately half of the expected value.

 

If I put a 1 second delay between the configuration of the counter and where I issue the ReadSingleSampleDouble, it works perfectly.


I have run into a similar situation with another project, and eventually I had just left the delay in the code so that it works.

 

Do you know of any reason why the delay is necessary with the .NET version of the library?  

 

Thanks in advance.

Can I measure period with USB 6501?

$
0
0

Hi,

I was told that I can use the one counter in the NI USB 6501 to measure period.  So, I wrote this little VI, modeled after the VI I have that measures encoder period using the counters built into the NI cDAQ 9174 with the NI 9401 digital I/O module.  I have my encoder wires GND and 5VDC on terminals 1 and 2, respectively.  Also, I have encoder channel A and Channel B wires connected to terminals 9 (P2.7) and 24 (P0.7) respectively.  With the MAX, I can count edges with this wiring.  The purpose of this VI is to display an average value of 25 period measurements of the encoder.  The encoder (120 cpt) is turning at about 2-5 rev/second, so, not that fast, maybe a total of 500 period per second; should be easy for this counter.  I'm just spinning it with my finger, so, not that fast.

 

Please advise how to use the USB 6501.  I can't find any wiring instructions, other than the pinout, but, the pinout doesn't tell you which channel is the counter gate on the USB 6501, so, I found a response on MAX at channel 24.

 

When I run this, the array is correctly initialized to 0.5, but, then I get this error, 200431. I found some things on the forum that suggest I cannot measure period, that I can only count edges.  Should I throw this 6501 away?

 

Thanks,

Dave

Need Help to estimate time for counting edges of analog square wave

$
0
0

Dear fellow labview users,

 

I am building a DC magnetic motor and I have integrated a hall effect sensor to count the frequency of the motor. 

Due to the limited number of 'counter' channel in my USB 6211, I decided to use an analog input channel to retrieve the

signal from the hall effect sensor. 

Thus far, I have managed to count the edges (falling) of the analog square wave. I intended to estimate time needed to complete

one square wave cycle and calculate the frequency. I know such approach may not be as accurate as the 'counting edge/frequency' using

the counter channel but this is necessary as I wanted to use the analog input channel for the measurement. 

 

I need some advice/help to get the time and complete the routine for calculating the frequency of the motor. 

I have attached some info for references. 

Thanks a lot guys..

 

Alam

Input impedance of NI 6602 Card

$
0
0

Hi All,

    Why is the Input impedance of the PFI's are Finite? In the data sheet it is mentioned that input impedance is 25k-500k ohms. I have measured the impedance of the PFI channel using a Multimeter and it shows that as 9k ohms. In any case (say even if 25k ohms), why is the input impedance finite?

When i connect my PWM signal to a PFI channel it is pulled down and so pulses ar not detected. I have had to use a pull up to count pulses. So, can any one explain why this input impedance is finite.

 

Thanks in advance

speedometer

$
0
0

hello

I would like to measure a speed on a reedcontact. With arduino Uno. Is there a example how to show speed in a graph?

thanks


Synchronize on restart of task

$
0
0

I'll outline what I need to do and hopefully someone can tell me how to best tackle it. A code example would be best if possible.

 

I have an application that will always be reading data on analog inputs (specifically strain on 4331 cards), but not always writing output data (on 6733 cards). However, when voltage is being output, I need it synchronized with start of my AI reads. I can synchornize them by using the start trigger when my application is first started up. But, if I stop my AO task, then restart it, I need it to synch back up to the AI. I figure I may be able to use a counter to do this but I'm not sure how.

 

So, to clarify with an example: Analog input and output tasks will be synchronized. The analog output task will be stopped but the AI task keeps reading. At some point in the future, the AO task restarts, but it shouldn't start outputting data until I get to the beginning of an AI read. So, if I am continuously reading 1000 AI samples from the buffer, but my AI task is currently reading sample number 500 out of 1,000 (i.e. only halfway done with a read) and my AO task restarts, the AO task shouldn't start outputting data until all 1,000 samples have been read by my AI task.

Mesuring machine cycle time

$
0
0

I want to measure the cycle time of 10 plastic molding machines and view the results along with cycle counters on HMI on a PC.

I can produce a 0v-5v pulse from the machine at the start of every cyle.

What Hardware is most applicable for this application.

Thanks. 

3 quadrature encoders on one 9411

$
0
0

I'm trying to read three quadrature encoders using a 9411 in a cDAQ. In the cDAQ is a 9437 reading a load cell.

Sample rate is set to 1613 HZ, and the counters use the cDAQ/ai_clock .


Reading one encoder on DI0a/DI1a, I have no problems. As soon as I add a second encoder on DI2a/DI3a, I begin to get strange results. It's as if the position skips or jumps occasionally.

 

I guess before I start troubleshooting I'm wondering if there is any reason I should not be able to measure three quad encoders using the 9411.

 

The three encoder readings are three different tasks. Perhaps I should make them one task? These tasks are all read in a loop, 20 readings at a time, but they're reading in parallel.

 

Using LV2013, Win 7.

 

Hoping to get some advice on the code.

 

Jeff

"loopback" counter output without wiring

$
0
0

I will be outputting a pulse on Trig0 line that resides on an AO card, based on that AO card's counter0. The problem I am having is that this AO card itself needs to trigger off this pulse. Is there any way I can do this without physically wiring up some sort of loopback and triggering off a different line for that card? I'm trying to minimize extra wiring if we can do this all internally. Also, I know a 6672 timing module card resolves this, but we're actually trying to figure out if we can do this without purchasing that extra card.

how to measure the rpm using NI 9411 and counters

$
0
0

How to calculate the rpm of a shaft using NI 9411 and counters?

Viewing all 1271 articles
Browse latest View live


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