Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

synchronizing two counters output with a USB-6212

In your case, you have two signals (frequencies f and 2*f).  If you trigger off of the slower frequency, you should see a stable waveform on the scope. 

 

 

However, if you trigger continuously off of the faster frequency the slow waveform could shift to one of two possible phases:

 

       22947i531B1AB69A904494

 

I'm guessing this is probably what you're seeing.

 

 

Best Regards,

John Passiak
Message 11 of 26
(3,935 Views)

 

Yes, you're right, I should have thought about it earlier.

 

Now this works, I have two other questions.

In the VI attached, I added a part which reads an analog input synchronously with the ctr0 and triggered by ctr1. It works fine. My question is about the frequency. I read that USB-6212 has a maximum sampling frequency of 250 kHz, so my VI won't work if I put a frequency greater than 250 kHz. Is there a way to make it work ? If not, it is not critical.

 

Then, I need (in the same application) to generate pulses, synchronously with ctr0, but with a different period. This is to fire a LED.

It is not clear to me if I can use a numerical output to do this, or if I need to use an analog output ?

 

Tanks again for all the help !

Best regards,

JB

____________________
JB
0 Kudos
Message 12 of 26
(3,920 Views)

Hi JB,

 

The maximum specced frequency for AI is 250 kHz, but you could probably go slightly higher than this before you start running into problems.  At a certain point you will start to receive ADC Overrun errors if you try to sample too fast.

 

Since there are only two counters on the 6212 you'll need to come up with some other way to generate the third signal.  Analog Output is certainly an option.  Depending on the requirements of your clock signal you may be able to use the Frequency Generator to output the clock.  However, the Frequency Generator can't be triggered and the number of frequencies available is quite limited (see diagram below):

 

           23048i56259646C4A2AE53

 

 

One other thing about your code--you probably want to start the AI Task before the counter task so that you are guaranteed not to miss any sample clock edges.

 

 

Best Regards,

John Passiak
0 Kudos
Message 13 of 26
(3,915 Views)

 

Actually, I need something really simple: I switch a 5V signal on and off each time I see a rising edge on ctr1... I think it won't be too hard to do with an AO.

 

____________________
JB
0 Kudos
Message 14 of 26
(3,907 Views)

 

Well, this is not so simple.

In principle, I wanted to create a AO task, generate a 5V voltage and switch the task on and off on rising edges of ctr1.

However, I cannot find a way to react on a rising edge of ctr1. Is it possible ?

 

 

____________________
JB
0 Kudos
Message 15 of 26
(3,900 Views)

You could write a waveform like [5, 0, 5, 0, ... ] and use the ctr1 Internal Output as the sample clock.

 

For the overall structure of the AO code, you can refer to this example:

Continuously Generate Voltage Using External Sample Clock

 

 

 

Best Regards,

John Passiak
0 Kudos
Message 16 of 26
(3,895 Views)
Well, I said 5, but in principle the value should be set by the user. So I cannot use the VI Express to generate my signal. And as I ue a continuous generation, I don't know if a table could be used to generate the signal.
23148i4C16475B753685FE
In addition, I'd like to modify the part of my VI below to read the 133 samples each time there is a rising edge of ctr1. Putting the "Read Waveform" VI in a loop give me an error with buffers. How could I do that ?
23150iD7E38938A864064D
____________________
JB
0 Kudos
Message 17 of 26
(3,889 Views)

The example I posted doesn't use the Express VI, you can set whatever voltage value you want.  The idea is still to clock out AO based off of the output of ctr1.

 

 

You have your task configured to be "finite".  So, if you try to read more than the 133 samples you'll get an error.  Change the task to "Continuous", then set the number of samples to read input to DAQmx Read to be 133.  You can then call this repeatedly inside a loop.

 

 

Best Regards,

John Passiak
0 Kudos
Message 18 of 26
(3,885 Views)

The difficult point for me here is how to set the right parameters for the waveform generation.

I tried to use property nodes, but it seems to be a problem.

You can see in the attached VI (bottom) that I try to get ctr1 frequency and feed it in the waveform generation vi. I also build a cluster with frequency and number of samples per channel.

 

____________________
JB
0 Kudos
Message 19 of 26
(3,878 Views)

Something like this should work:

 

23166i37549C3021D0D3F8

 

The trigger isn't necessary since the external sample clock is starting the generation.  You can use only onboard memory if you want since there are only 2 samples that need to be repeatedly clocked out.  I also changed the instance of DAQmx Write to be 1D DBL since it makes a little more sense than waveform in this application.

 


Best Regards,

John Passiak
0 Kudos
Message 20 of 26
(3,875 Views)