09-15-2014 10:52 AM
Dear Community
I am using a scanning tunneling microscope from which I am feeding two voltage signals to my USB-6212 DAQ card (Labview 2013 SP1). One voltage signal is the voltage applied to a piezo in the microscope (AI0). This signal drifts slowly over time and is noisy. The other voltage signal is a tunneling current converted to a voltage signal (AI2) (See attached picture):
Ideally I would like to save both signals between the dashed lines in one .txt-file everytime the peak event in the top picture comes up. This should be about every second over the course of a day.
So far I have written a VI that calculates the running average of the piezo signal and if the piezo voltage goes a certain percentage over the running average it triggers a "save as file" command. The VI works ok for a sampling frequency of 100 Hz but when I go up to 20 kHz the trigger does not work properly anymore. I am also only looking at a batch of numbers (In this case 1000) and if there is a trigger signal in these 1000 samples. So if there is a signal around 0 or 1000 I would cut it and split it up into two files which I would like to avoid.
I don't have much experience with Labview and have probably broken every design rule in the book.
My question is if there is a smarter way of automatically saving the signal between the dashed lines even at high sampling frequencies?
Thank you very much in advance!
Solved! Go to Solution.
09-19-2014 09:59 AM
Hi Mario Marionis,
You can have a look at Kalman Filters in LabVIEW to filter the signal and avoid voltage drift, this would allow you to analyze your signal more effectively .
Regards,
Mark
09-20-2014 01:06 AM
Hi Mario,
I rewrote portions of your VI to improve performance (hopefully). No need for three queues. No need to enque unless a trigger happens.
I'm confused by the triggering which seems to detect edges on high side of Piezo signal, even though the spike is in negative direction. I modified this logic to (optionally) look for a threshold on high-side of tunneling signal.
It's not clear what might be happening at 20KHz. The example shows a constant 1KHz sampling rate and 1K samples processed per loop. If the sampling rate is changed to 20KHz, then the loop will have to run at 20Hz in order to keep-up with acquired data (@1K samples per read).
Hope the attached (untested) VI helps!
09-22-2014 06:25 AM
Hi Mark
Thanks for the suggestion with the filter! I am looking into how to implement this one to help averaging with the piezo-drift!
Best regards,
Mario
09-22-2014 06:51 AM
Hi 550 nm!
Thanks for the help with the VI! It simplifies it quite a bit with only one Q in there.
Sorry about the confusion with the trigger edge! As I am quite inexperienced with Labview I was only aiming for the program to save the signal roughly around the time when the trigger occours and then write a matlab script to pick out the interesting bit (Just to make sure I don't miss the first bit of the signal). But it is of course much more elegant if Labview saves the correct part of the signal to begin with.
I'll run it on the microscope and keep you updated!
Thanks so much for your help!
Best regards,
Mario
09-24-2014 12:04 PM
Hi 550nm
The trigger works very reliably now even at high frequencies! Thank you for that!
The output files look a bit unexpected if I go to sampling frequencies higher than 2000 Hz. I am not sure yet what's going on there. Might be that my signal is doing something unexpected there.
Thanks!
Mario