Generating Pulses with CTR-502
Hi,
I want to generate 100 Pulses with a frequency of 0.27Hz. After having done no other pulses should be generate until told so.
How can I do that? I'm using an CTR-502 and LabView 7.1.
Any help would be great. I read most of the documentation but either my english is to bad or I couldn't find any solution.
Yves
Hello Yves.
Sorry for me currently not having a CTR-502 at my hands.
Therefore I had to do some "copy and paste" from a project that I worked on in the late 2003.
I hope this VI is a helpful startup - although I could not test it before posting it to you (as already said: I don't have a CTR-502).
The VI is small, configurable and uses low CPU resources.
On a RT target like FieldPoint (FP) or compactFP this VI should typically run at least with "high priority".
I hope this will help in getting your job done.
BR, mgm
Attachments:
constant Frequency with FP-DigOUT.zip 17 KB
Similar Messages
-
Hi,
can I generate defined pulses with the NI-6024 Card? I'd like to generate 100 Pulses with 0.27 Hz frequency.
I'm using LabView 7.1
YvesYou can add the attached vi between the 'Frequency control and the DAQmx function in 'Gen Dig Pulse Train-Finite.vi' in the examples. This will change the frequency slightly to one that will work. You can add a local variable for the 'frequency' control to see what it changed to. You have have to increase the number of visible decimal places to see the change.
Randall Pursley
Attachments:
Set Frequency.vi 14 KB -
Measure pulse width and generate pulse depends on the width
Hi,
i have a serias of pulses ... 600 micro,30 micro,30 micro (around 10 times) ........ nothing for 1 mili second ..
so i need to generate a pulse after the first pulse arrives ... (its width around 600microSecond)
1. use the first counter to measure the pulses ...
2. if arrived pulse ... 500microSecond<the pulse width<700microSeconds .... then generate pulse with second timer ....
the problem is that i dont want to use the while loop inside the labview ...
can i programm the counters to make the width calculation and if the width is bigger to generate trigger to the second counter .... ?
the hardware is 6014 sample card ....
thanks
gena
(see attached)
Attachments:
F0087TEK.JPG 27 KBHi Gena,
I am assuming you are using the DAQmx drivers in LabVIEW for your
PCI-6014. Avoiding a While loop may be difficult if you need to
perform this measurement many times and you might not know when the
signal is going to begin. Without a While loop, you'll have to
set up your timeout period long enough so the pulses will begin before
your VI stops.
With this in mind, you may want to look at some of the shipping
examples with the DAQmx driver. You can find these in LabVIEW's
Help menu by going to Find Examples. For measuring the pulse
width, browse the folders in the Example finder by going to Hardware
Input and Output>>DAQmx>>Counter Measurements>>Period
or Pulse Width. In this folder, there is the Meas Pulse Width.vi,
which measures the pulse width once and stops. You should be able
to take the pulse width measurement you get from here and check to see
if it's in your range, then output a pulse on the other counter if it
is in the range. The pulse output examples can be found in
Hardware Input and Output>>DAQmx>>Generating Digital
Pulses>>Gen Dig Pulse.vi.
Thaison V
Applications Engineer
National Instruments -
Pulse width measurement with FieldPoint CTR-502
I would like to measure the pulse width of a signal (ranging from 10 ms to
400 ms out of a signal with period width of about 1 second). I would like to
use a fieldpoint counter module FP-CTR-502. I could find examples on how to
measure frequency but I did not know how to alter it in order to obtain the
pulse width.
Thanks,
MartienTo measure pulse width of a fixed-period signal, you only need to use one counter, so the configuration and program would be different than the frequency measurement example. Set the count source for counter 0 to "32kHz Reference" and the gate source (and wire your signal) to "Gate Input 0." You'll also need to create a control channel to reset counter 0 (as described in the frequency example).
Your LabVIEW program should run as follows:
- When Gate Input 0 becomes true, do nothing
- When Gate Input 0 becomes false again, read then reset counter 0
- repeat
You can use FP Advise to wait for the gate to change (just like the frequency example).
Once you have the number of counts, you can divide that by the frequency (32 kHz) to calculate the "on tim
e" (pulse width) of your signal.
Regards,
Michael Shasteen
Applications Engineering
National Instruments
www.ni.com/ask
1-866-ASK-MY-NI -
Problem with the Pulse With Measurement with FP-CTR-502
I use a sensor that outputs a PWM-signal (10 Hz; "normal": Duty Cycle 20% (20 ms high, 80 ms low); high = 6 V, low = 0.5 V).
The sensor is connected to the Gate Input Channel of the FP-CTR-502 with an external supply voltage (Vsup) of 5 V.
I tried to measure the pulse width with the "Pulse_Width_Measurement_with_FP-CTR-50x.vi".
I know, that (due to the specifications) the FP-CTR-502 registers an ON
state when Vin is 2 or lower and an OFF state when Vin is 3 or higher -
which means that the measurement would be "upside down".
But my problem is that the (measurement-)results of the VI vary from
0.03 to 1.8 (without the presents of the substance that should be
measured!).
Does anyone know what the problem might be?I can answer this question myself!
The answer is in the *OLD* version (July 2000) of the operator's manual for the FP-CTR-502. For some reason, this has been removed from the latest version (June 2003).
See page 11 of this link for more information:
http://www.ni.com/pdf/manuals/322660a.pdf
Christopher Farmer
Certified LabVIEW Architect
Certified TestStand Developer
http://wiredinsoftware.com.au -
How do you create a finite pulse train using a FP-CTR-502?
I have recently replaced my FP-PG-522 module with a FP-CTR-502 module, to achieve higher output frequencies (FP-PG-522 max output freq is 5kHz, wheras the FP-CTR-502 max output freq is 16 kHz).
I need to be able to generate a finite pulse train. Has anybody created a finite pulse train using a FP-CTR-502 module before? I have started to look into it, but my ideas so far have been complicated (compared to doing it in a PG module).
Any tips on this would be much appreciated.
Christopher Farmer
Certified LabVIEW Architect
Certified TestStand Developer
http://wiredinsoftware.com.au
Solved!
Go to Solution.I can answer this question myself!
The answer is in the *OLD* version (July 2000) of the operator's manual for the FP-CTR-502. For some reason, this has been removed from the latest version (June 2003).
See page 11 of this link for more information:
http://www.ni.com/pdf/manuals/322660a.pdf
Christopher Farmer
Certified LabVIEW Architect
Certified TestStand Developer
http://wiredinsoftware.com.au -
Trying to measure frequency with the cFP-CTR-502. Can't get tutorial to work!
Hello,
I am trying to measure the frequency of a
signal that I'm counting using the cFP-CTR-502. I can successfully
count pulses but I what I really need to know is the RATE of counts
(counts/s or the frequency). I have found some Labview programs that
supposedly do this that I've downloaded from ni.com (link below). The
concept makes sense of using a gate and output but the programming is
crazy - at least the program in the link below is.
1. Is there an easier way to measure the frequency of counts?
2. Why will the program from the link below ( frequency_measurement__ctr_.vi
) not work on my system? I get an error everytime I run it. Could I be
missing some VI's necessary for it to run? Or is it from another
LabView version that is not compatible?
The
entire error is: -32810 occured at FieldPoint initialization failed.
Possible causes, 1. Missing or corrupt configuration file; 2. Failed to
create call backs. : FP Open.vi
Link for program: http://sine.ni.com/devzone/cda/epd/p/id/4682
Thanks in advance for all your help and time!
Sam TSam,
Have you tried the example titled Frequency Measurement.vi that ships with LV? -
Generate a delayed pulse with analog trigger
I want to generate a pulse with counter when the gate of counter receives a voltage value which is generated by analog output chanel,is this possible??
I am using PCI-6713
Thanks!!You can generate a triggered pulse in a counter by sending a signal to the gate from the Analog output, as long as such analog output meets the operational contitions of the counter of the PCI-6713. Just make sure that the signal does not exceed 5V. The trigger on the gate pin will be taken as low from 0 to 0.8V and as high from 2 to 5V.
Thanks for contacting National Instruments! -
How do I generate a pulse with a user specified puse duration, down time and repitition, and then out put to a graph and then to daq ports?
I used lab view in engineering class, but that was the extent of my usage and after fiddling around in lab view and looking on the web looking for solution, I could not produce desired results. My professor wants me to produce something that will output a pulse for a specified duration, then downtime for another specified duration and then repeat the process a specified amount of times.
I am using labview version 7.1
Thanks in advance.Hello,
Are you using hardware (DAQ card) to generate this pulse or are you planning on doing this all in software. If you have a DAQ card in LabVIEW you can go to Help » Find Examples and then select Hardware Input and Output » DAQmx » Generating Digital Pulses » Gen Dig Pulse Train-Finite.vi. This will use a counter from your DAQ card to generate a finite number of pulses at a specified frequency and duty cycle. Give this a try, or let me know if you are not using hardware, and we can figure something else out.
Regards, -
Generate a long pulse with a different source clock
I have configured the 6601 to generate a 1khz train on Ctr0
I would like to feed this into the source of Ctr1 to generate pulses of longer duration.
I use the command DaqmxCreateCOPulseChanTicks to set up my pulse train on Ctr1.
It works if I leave the source terminal as Null "", but it does not work if I change the source.
To change the source, I have wired ctr0 output to the source of ctr1 and use the label "dev1/PFI39" as the source terminal and have tried "dev1/ctr0Output".
I am using Visual Basic 6.
What am I missing?Hi,
Are you receiving any errors when you use anything except null as your source or is the counter simply not outputting anything? Also, have you tried using "Dev1/ctr0internaloutput" as a source as well?
Regards,
Hal L. -
Signal generator Pulse train with switch cycle
Bonjour,
J'essaie de générer un signal avec un rapport cyclique tres variable sur une carte PCI6602
Par exemple,
j'utilise en signal source internal clock de 20MHz et je souhaite que mon signal soit de la forme suivante :
4cycles d'horloge à l'etat haut
puis 2cycles d'horloge à l'etat bas
puis 17cycles d'horloge à l'etat haut
puis 4cycles d'horloge à l'etat bas
puis 20cycles d'horloge à l'etat haut
puis 5cycles d'horloge à l'etat bas
pour cela j'utilise le generateur de signaux Pulse Train avec la fonction ND_SWITCH_CYCLE
mais en verifiant à l'oscillo je ne vois pas le signal varier de cette sorte juste appliquer le dernier rapport cyclique défini.Unfortunately, I don't think you can accomplish that with a 6602. The only way to change the pulse specs on-the-fly is through software calls to the driver, and those won't execute nearly as quickly as you need. You would need to change the pulse specs for each and every pulse, and do it at a rate of ~1+ MHz. The software calls will limit you far below that -- I'd guess somewhere in the order of 10 kHz.
There's a further issue that you must let the prior pulse specs produce a pulse before the new pulse specs are allowed to take their place. So even for very slow pulse trains, it's difficult if not impossible to produce exactly one pulse at each set of specs.
What is needed (see my wishlist starting at reply #10-11) is the ability to perform hw-timed buffered counter pulsetrain outputs. Some of the M-series boards allow for hw-timed digital output at rates up to 10 MHz, but it appears that some of your intervals need to be odd multiples of a 20 MHz clock. Some of the high-speed digital boards could work, but you're looking at ~$2000.
How many cycles of precisely-timed pulses do you need? If 8 or fewer, there may be a way to setup a bunch of separate counters that are hw-triggered to start simultaneously, but each produces a single pulse with just the right specs. Then you'd need an output logic circuit which would essentially OR all the counter outputs together to produce the 1 output you need.
-Kevin P. -
Generate pulse frequency with usb-6259 on matlab
Hi,
I would like to create a pulse with the ni usb-6259 counter via Matlab (R2007b). As Matlab Data Acquisition Toolbox dosen't support the access to the counter/timer of the 6259, I call 'DAQmxCreateCOPulseChanFreq' from the library. However, it returns a negative status indicating that the channel was not created. Can someone tell me why I have a negative status?
Thanks,
Miko
Here is the code:
% %load libraries nicaiu.dll,nidaqmx.h if not loaded
clc
if ~libisloaded('myni')
disp('Matlab: Load nicaiu.dll')
funclist = loadlibrary('nicaiu.dll', ...
'C:\Program Files\National Instruments\NI-DAQ\DAQmx ANSI C Dev\include\nidaqmx.h', ...
'alias', ...
'myni' );
end
disp('Matlab: dll loaded')
disp('')
% Counter must be driven and read through 'c' function calls
% Define variable for taskhandle
taskh1 = uint32(1);
% Create task
[a,b,taskh1] = calllib('myni', 'DAQmxCreateTask', 'master', taskh1);
% Create channel name for counter input edge count
taskchans1 = ['Dev1/ctr0'];
%define required properties for pattern generation
DAQmx_Val_Hz = 10373; % a pre-scaled unit (aka DEFINE)
DAQmx_Val_Low = 10214; % resting state, pre-define unit
initialDelay = 0; % sec
freq = 16000; % Hz
dutyCycle = 0.5; % width / period. This ratio, combined with frequency, determines pulse width and intervals
% Create channel: specify duty cycle and frequency
nStatus = calllib('myni', 'DAQmxCreateCOPulseChanFreq',...
uint32(taskh1), taskchans1, '', DAQmx_Val_Hz, DAQmx_Val_Low, initialDelay, freq, dutyCycle);
if nStatus == 0 % channel created successfully
disp('Success')
elseif nStatus < 0 % error: channel not created
disp('Error')
elseif nStatus > 0 % channel created with warning
disp('Warning')
end
MikoThanks Peter!
It indeed proved useful, thanks to the last comment (slastuka p.10).
It seems that the input and output type depend on NIDAQmx version.
Here is the code (that works for me), in case help someone else:
clear all, close all
clc
if ~libisloaded('myni')
disp('Matlab: Load nicaiu.dll')
loadlibrary('nicaiu.dll', ...
'C:\Program Files\National Instruments\NI-DAQ\DAQmx ANSI C Dev\include\nidaqmx.h', ...
'alias', ...
'myni');
end
disp('Matlab: dll loaded')
% libfunctionsview('myni')
% Counter must be driven and read through 'c' function calls
% Define variable for taskhandle
Taskh1 = [];
% Create task
[a,b,Taskh1] = calllib('myni', 'DAQmxCreateTask', 'Counter', Taskh1);
Taskh1 = libpointer('voidPtrPtr',Taskh1);
% Create channel name for counter input edge count
Taskchans1 = libpointer('cstring','Dev1/ctr0');%Counter name
NameChan = libpointer('cstring','');%Channel name
%define required properties for pattern generation
DAQmx_Val_Hz = int32(10373); % Units: Hz <-> 10373
DAQmx_Val_Low = int32(10214); % Resting state: Low <-> Terminal is at a low state at rest. Pulses move the terminal to a high state.
InitialDelay = 0; % Delay (sec) from the start call to the beginning of the pulse train ; this is currently set to 0.0 by default.
Freq = 16000; % Hz
DutyCycle = 0.5; % width / period. This ratio, combined with frequency, determines pulse width and intervals
% Create channel: specify duty cycle and frequency
nStatus = calllib('myni', 'DAQmxCreateCOPulseChanFreq',...
Taskh1, Taskchans1, NameChan, DAQmx_Val_Hz, DAQmx_Val_Low, InitialDelay, Freq, DutyCycle);
if nStatus == 0 % channel created successfully
disp('Success')
elseif nStatus < 0 % error: channel not created
disp('Error')
elseif nStatus > 0 % channel created with warning
disp('Warning')
end
I don't know for the following, but at least I can create the channel.
Miko -
I am using FP-CTR-502 counters with LV to detect missing pulses, is there a way to reset the counters from the VI?
You should be able to create a virtual item for the Reset command in MAX. Then write to this item from within your VI to reset the counter.
Regards,
-Khalid -
CFP-CTR-502 Simple Event Counting
Hello All,
I have a CTR-502 counter module which I understand is a sourcing counter module and therefore the external input has to be a sinking source. I am testing the counter with a function generator. How do I turn a sourcing output to a sinking output? Directly connecting the function generator to the counter module does not register any counts (testing it with MAX).
Thanks,
Karthik.Karthik,
You can not directly turn a sourcing output into a sinking output, however, you can adapt two sinking or two sourcing outputs to work with each through the use of pull-up or pull down resistors. In order to connect the [c]FP-CTR-502 (sourcing) with a function generator (sourcing), you will need to place a pull-down resistor
between the two. Specifically, you connect the In[x] terminal of the [c]FP-CTR-502 module to the Output of the function generator. In addition, you place a resistor between In[x] and Com of the [c]FP-CTR-502 module. The resistor size will vary based upon the voltage levels in use.
The function generator should be set to provide a unipolar output (e.g. 0 V ON, 10 V OFF, not -5 V ON, 5 V OFF) that is comparable in value to the
power supply wired to the V & C terminals of the [c]FP-CTR-502. If you have wired a 12 V supply to the [c]FP-CTR-502, you should set the voltage of the function generator to 0 to 12 V. The ON voltage must be more than ~3 V less than the supply voltage (see [c]FP-CTR-502 Operating Instructions for exact specs). The OFF voltage must be within ~1 V of the power supply voltage. When using a sinking input device, the polarity is reversed (0 V ON).
Regards,
Aaron -
Hello!
My problem appeared when I tried to update my code from Traditional NI-DAQ Legacy to DAQmx.
I am using 2 counters (counter 5 and counter 7) from PCI-6602, to generate pulse train, and also the Digital I/O lines of the port 0 (the lines form 0 to 7). What I do in my application is that I am starting to generate the pulse train on the output of the 2 counters, and after that I am playing with the state of the digital lines.
In traditional there was no problem using the counters and the digital lines in the same time, everything was going perfectly, but in DAQmx this is not possible.
What happens: I start to generate pulse train on the output of the counters, no errors encountered, but when I try to modify the state of one line of the digital port the generation of the pulse train is stopped. This is happening when I start the task associated to the digital port.
My question is: it is possible to create a channel on the digital lines without altered the channels created for the counters?
Another thing what I manage to see using the "Measurement & Automation Explorer" and Test panels for PCI-6602, basically is the same thing, I generate pulse train on the output of the counter 7 and try to start a task on the digital line, but I get one error :
"Error -200022 occurred at Test Panel
Possible Reason(s):
Measurements: Resource requested by this task has already been reserved by a different task.
Device: Dev4
Terminal: PFI8"
Instead if I use the counter 0 or counter 1 to generate pulse train I don't encounter the same problem.
Which resources are used by the counters 2 to 7 from the PCI-6602 board and the counters 0 and 1 do not use?
Thank in advance for any replies!
Ciprian
Solved!
Go to Solution.Hello Jordan, thank you for your reply.
I am sorry but I can not see or run your example, I don't use LabView, I use Visual C++ for developing.
Here is the code for generating the pulse train:
GeneratePulseTrain(unsigned long ulCount1, unsigned long ulCount2)
short nStatus = 0;
nStatus = DAQmxCreateTask("",&m_taskHandle);
nStatus = DAQmxCreateCOPulseChanTicks (m_taskHandle, "Dev4/count5", "", NULL, DAQmx_Val_Low, 0.0, ulCount1,ulCount2);
if( bTriggerMode == true) // if hardware trigger is enabled
nStatus = DAQmxSetTrigAttribute (m_taskHandle, DAQmx_ArmStartTrig_Type, DAQmx_Val_DigEdge);
nStatus = DAQmxSetTrigAttribute (m_taskHandle, DAQmx_DigEdge_ArmStartTrig_Edge, DAQmx_Val_Rising);
nStatus = DAQmxSetTrigAttribute (m_taskHandle, DAQmx_DigEdge_ArmStartTrig_Src,"Dev4/PFI17" );
//set the internal timebase
nStatus = DAQmxSetCOCtrTimebaseSrc(m_taskHandle,"Dev4/count5","20MHzTimeBase" );
nStatus = DAQmxStartTask(m_taskHandle);
return nStatus;
And the code where I try to set the digital line:
SetChannelState(short nState)
short nStatus = 0;
uInt8 wrtBuf0[1]={0};
nStatus = DAQmxCreateTask("",&m_taskHandle);
// Configure line as output
nStatus = DAQmxCreateDOChan (m_taskHandle, "Dev4/port0/line0", "", DAQmx_Val_ChanPerLine);
nStatus = DAQmxStartTask(m_taskHandle);
wrtBuf0[0] = nState;
nStatus =DAQmxWriteDigitalLines (m_taskHandle, 1, 0, 0, DAQmx_Val_GroupByScanNumber , wrtBuf0, NULL, NULL);
nStatus = DAQmxWaitUntilTaskDone(m_taskHandle,10);
nStatus = DAQmxStopTask(m_taskHandle);
nStatus = DAQmxClearTask(m_taskHandle);
m_taskHandle = 0;
return nStatus;
Maybe you are looking for
-
Strange problem. Lightroom 5.5. Windows 8.1. Dual monitor setup. I'm processing a large batch of photos. I have Monitor #1 set as my main develop window, with Monitor #2 set only to display a larger version of the image I'm working with. If I copy
-
UseBean & NoClassDefFoundError
Hey OK. I am relatively new to JSP. So far I have installed Jakarta Tomcat on my PC. At the moment I am just throwing together a few simple bits of code so I can understand how it works. First of all I used the following code in file test.jsp located
-
How do I get ipad to recognise my wifi?
how do I get my new Ipad to recognise my wifi?
-
It works on my Computer, but not in my DVD Player
I burned a DVD, It works on my Computer, but not in my DVD Player...why?
-
External Mic is not working on Line in?
Problem: I attached a non-powered microphone to my MBP Line-in port to record some voice overs. But the system doesn't record my voice. Only from built-in mic. What I've tried so far: Check input settings in Sys Prefs, and Utilities > Audio Setup che