LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Getting my photon count to display in realtime?

Hi, I have developed a pretty basic LabView program to take two sets of photon counts one passing through a cell, and one not and then work out the absorbance in the cell.

I am using a Stamford Research SR400 photon counter connected via GPIB USB interface. Currently my programme is set up to perform a set number of photon counts, and then dump it all to a table and 3 graphs (one for channel A, one for channel B and one calculating the absorbance). I ideally would like these to display in realtime as the data is being collected, is there anyway of doing this? I have tried several things and can't get it to update in realtime so I'm wondering is this because I don't know what I'm doing in LabView, or an issue with the GPIB read/write timing or the photon counter? If anyone could offer some help I'd be very greatful.

I am using LabView 7 Express and my code is attached. Thanks

0 Kudos
Message 1 of 22
(3,037 Views)

You must really love sequence frames. Smiley Wink

 

In order to see the data as it's collected you need to put the graphs inside the for-loop where it's being collected. As it is, dataflow dictates that the graph won't diplay any data until the loop is finished. If you want to use XY graphs then you need to use a shift register to populate the array that's fed to the XY graph.

 

You also seem to have parts of your code cased out, but use constants. Is there a reason for this? Also, is there a specific reason you're using the old GPIB functions as opposed to VISA?

Message 2 of 22
(3,030 Views)

Ha yes, I can only follow what I'm doing in sequence frames! It helps me understand how things flow/are connected. I have very limited knowledge of labview and basically have things the way I have them because that's the only way i could get it to work. I had loads of problems initially with timing, getting maybe only every 5th photon count put into labview etc which I think is why I have the constants. I am not really familiar at all with VISA so used the GPIB as I figured that would be what I needed as I am reading and writing to/from GPIB? I will try putting all of my plots into the for loop and changing to shift registers, hopefully without deleteing all of my existing code or something!!

Thanks very much I am slowly hopefully getting the hang of this! 

0 Kudos
Message 3 of 22
(3,014 Views)

okey, dokey. If you run into problems, just post back.

 

FYI: VISA is an API that includes GPIB, serial, and TCP/IP.  You can get a high-level overview here: http://zone.ni.com/devzone/cda/tut/p/id/3702

Message 4 of 22
(2,999 Views)

Hi,

I have changed my code as suggested and now have it so there are no errors, however rather than building up a realtime display of each photon count as it is collected, the loop collects one photon count then overwrites it with the next etc. Also the loop doesn't seem to ever stop after the specified number of photon counts has been performed. I think that this is probably something to do with the shift registers as I am not very familiar with these, and from what i have read I need to tell these somehow to move on and collect a second poin etc?

I have attached my "new" code, if you wouldn't mind having a look to see if you can spot my error I'd be most greatful

Thanks for all of your help!

0 Kudos
Message 5 of 22
(2,989 Views)

Yeah, that's not quite right. Smiley Wink The shift register are for your arrays, not for the numeric, which doesn't do anything. Here's a quick example (I can't backsave to 7.0):

 

As I pointed out before, this method will have a memory impact because you're constantly building arrays. A better method is to use Replace Array Subset like this:


Message Edited by smercurio_fc on 09-26-2008 04:42 PM
Download All
Message 6 of 22
(2,984 Views)

Ahh, Ok.

I'll give that a go...and I thought I was getting the hang of this!

Cheers

Message Edited by Khume on 09-26-2008 02:50 PM
0 Kudos
Message 7 of 22
(2,978 Views)

Ok, I have done what i thoght you meant for me to do, but now the photon counter performs x amount of counts and then once it has finished counting it plots them out for you, ie you see the plot being built rather than just getting the final plot dumped on screen, but it still happens after all of the data has been collected. Is it possible that the photon counter only dumps all of it's values to the GPIB after it has finished counting, or have I just done something wrong?

Sorry for all of the hassle, I do realise how incompetant I am and how annoying it must be to somebody who understands these things!

Cheers

0 Kudos
Message 8 of 22
(2,963 Views)

Unfortunately, that's not right at all. Smiley Sad You've seem to have take an incorrect left turn somewhere. In the sample code I posted you see there's a random number generator. This was supposed to be what you get out of the last GPIB Read, as that was the value you wanted. The output of the GPIB Read is the value that you put into the array that gets passed around the shift register. You weren't supposed to duplicate the code exactly. Smiley Surprised You should have only one loop, not 4.

 

Also:

  • I had NaN there for a reason. If you use 0 then you will get x,0 points for all values of x that are larger than the current index. Values of NaN are not graphed. To get the NaN constant place a numeric constant on the block diagram and then simply type NaN. 
  • You have a Wait (ms) function in each frame. Dataflow dictates that there is no way of predicting whether the wait will occur before or after the write/read operation. Thus, in frame 0 you can have the read and then the wait, and in frame 1 you can have the wait and then the write, and in frame 2 you can have the read and then the wait. Or, you can have any combination. If you must explicitly have a delay occur before or after something then you must use dataflow to enforce execution. Or, you can use sequence frames, since you seem to like those so much. Smiley Wink
Message 9 of 22
(2,952 Views)

Hi, sorry, I'm not sure where my head was last Friday, or today come to think about it. Throughout the day I have made a series of stupid mistakes. I now have code which I think (yet again!) is right. This time the code runs fine, and I get realtime output for each channel for about 8 or 9 photon counts, and then it is as if the whole system gets bogged down and it stops displaying any of the data. I had a similar problems when I initially started to construct this code, something to do with emptying and clearing the buffers, which is what resulted in all of the wait times in each frame. It did not seem to matter whether those occurred before or after the GPIB read/write function, so long as they happened before moving onto the next frame. I have tried increasing the length of the wait time in the loop but this does not seem to help. If you have any ideas I would be again most appreciative.

Thanks!! 

0 Kudos
Message 10 of 22
(2,917 Views)