LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

voltage Ramp and Counter

Hey everyone, just have some quick questions about the program I'm making.

 

I'm writing a program in Labview 7.1 that is supposed to send out a voltage ramp out to another system that will trigger in return TTL pulses that are sent back to the computer. The voltage ramp is set up so it sends a voltage in small increments every few milliseconds. I want the counter to count the pulses that follow each voltage increment, so that eventually I can make a graph of how many pulses occurred in each section of time, or each voltage segment. I have the voltage ramp attached. How would I add in the counter portion of this vi so that it can function like the way presented? 

 

Also, how can I test a pulse counter that I create? Since I can't connect the computer to the system yet, I don't have a surefire way to test my program. I am using a PCI-6229 card. The Labview for Everyone third edition book's activity 11-9 says that I can generate a pulse by using a wire between a ground terminal and the PFI0 terminal, but that hasn't been working. Is there a way to make that work? Or, how else can I test my counter?

 

Thanks,

 

Luke 

0 Kudos
Message 1 of 14
(4,989 Views)

Hello Luke,

 

For counting the events, I would recommend you take a look at the "Count Digital Events" example in the LabVIEW Example Finder.  By calling the DAQmx Read a short time after writing the update and subtracting the previous iteration's total from the current total, you can get an accurate count of the pulses that occur after each voltage increase.

 

To test the counter, you can use the "Correlated Digital Write with Counter" example, using your second counter as the clock, to produce a series of pulses.  You'll want to connect your counter's source to the digital port and then connect the digital grounds.

 

I would also recommend that you pull all the DAQmx VIs except the DAQmx write VI outside of the second loop in your voltage ramp VI.  It's more efficient to just create and open the DAQmx session once, then close it when everything is done.

 

Regards,

Seth B.
Principal Test Engineer | National Instruments
Certified LabVIEW Architect
Certified TestStand Architect
Message 2 of 14
(4,963 Views)

Thank you for the reply.

 

I also want to log this data to an array, but I'm not sure how to write it to multiple array elements. Although the solution to this probably comes in hand with getting the program to subtract the previous totals of counts, how would I go about doing that?

 

Here's an updated version of my program. Could you see if my counter line works for this purpose?

 

Thanks again,

 

Luke 

0 Kudos
Message 3 of 14
(4,908 Views)

Luke,

 

I was talking to a few engineers here about your application, and we found a very similar application already solved on the discussion forums.  Check out this post and let me know if that is similar to what you're trying to do.  The engineer that answered that posted some example code called AO_Count_Benchmark.vi in message 7, and the diagram for the application is shown in message 5.  Let me know if you need further assistance after reading this.  Have a great day!

Sincerely,

Chris G in AE
0 Kudos
Message 4 of 14
(4,891 Views)

Hi Luke,

 

Chris showed me your post the other day, and we noted it sounded remarkably similar to the one I had posted to here. I hope you had time to read through my posts over there and found them applicable to what you are trying to do.

 

I hadn't heard of this specific use case for our DAQ hardware before, and was wondering if you could provide more details about the application.  If this is some sort of standard, I would like to know more information about it.  Particularly, I am curious if there is a widely-accepted name for what you are trying to do or if there is a good place to find more information online.

 

If this is something that multiple people would be interested in, I could look into putting up a possible reference example on our Community Site.

 

-John

Message Edited by John P on 07-14-2009 12:25 AM
John Passiak
0 Kudos
Message 5 of 14
(4,851 Views)

Yes, I have been looking through that thread. Thank you two for referring it to me. It seems just about how my program is supposed to act, except the way that that program is supposed to carry out the voltages is different. Thanks to that and some of my own fiddling with the general counter vi, I was able to get my vi most running save for a few things.

 

As for applications, the computer that runs this vi is supposed to be connected to a machine that runs XPS (X-ray photoelectron spectroscopy) and QMS (Quadrupole mass spectrometry) experiments, where the computer would send a voltage ramp, the machine would react to those voltages, and would return a certain number of TTL pulses corresponding to each voltage which the program would count. It would seem to be a simplified version of the vi in question in that thread. The important parts of this program though would be start and end voltages, the voltage step it takes each time the voltage increases along the ramp, and the dwell time on each step.

 

 Unfortunately, I don't know much about standards that have to do with this. I would assume that it would be similar to the linked vi if that has been labeled.

 

 

 Luke

 

Message Edited by Kiyohitokage on 07-14-2009 02:09 AM
0 Kudos
Message 6 of 14
(4,836 Views)

I have a question, though, about the idea mentioned earlier of subtracting the previous iteration's total from the current total to get the pulse count after each voltage increase. How exactly do you do this? I have fiddling around with the feedback node, but still not really getting the results I want (the graph still looks similar to a graph displaying just the increasing number of counts). Maybe I'm looking at this or using the functions wrong.

 

Here's the example counter vi that I've been playing with that probably looks like a complete mess. Do you know how I can solve this? 

 

Thanks again

 

Luke 

Message Edited by Kiyohitokage on 07-16-2009 11:44 AM
0 Kudos
Message 7 of 14
(4,792 Views)

Hi Luke,

 

In the post we linked earlier there is actually a VI that does this by using a Buffered Period Measurement instead of a Buffered Count Edges task--see post 7 of the thread. 

 

You should also be able to make the following wiring change to your existing code to subtract the previous value of the counter from the current value:

 

Feedback_Node.PNG

 

 

Either of the above options should work.  In the first option, we are actually clearing the count register at every sample.  In the second, we are accounting for this in software.

 

 

-John

Message Edited by John P on 07-16-2009 01:25 PM
John Passiak
Message 8 of 14
(4,783 Views)

I finally got the chance to draft up an example code for this application:

 

Communities: Synchronize Analog Output Sample Clock With TTL Pulse Count

 

The code is built for a 2D case (sweeping both X and Y coordinates), but if you set the number of Y steps to 1 it should work just fine for the 1D scenario.  You might have your code working by now, I just thought I'd share what I came up with.  I hope everything is going well, if you have any feedback don't hesitate to let me know.  Thanks!

 

 

-John

Message Edited by John P on 07-23-2009 10:42 PM
John Passiak
0 Kudos
Message 9 of 14
(4,724 Views)

Yes, I have all the necessary things completed. Thanks for your help and your enthusiam. Everything works pretty well.

 

I have a question, though, about the arrays in the program. If I run multiple cycles through, I want the program to be able to either sum up or average the values I get through each run through. I would think that this would be most easily accomplished by adding the arrays together and dividing by whatever, but I can't seem to find a way to do this. So, I guess my question is, how do you take the values from a previous cycle and add it to the current cycle?

0 Kudos
Message 10 of 14
(4,692 Views)