AFM Experiment - IGOR PRO NIDAQ Tools
Carlo
I started studying the manual NIDAQ tool for IGOR PRO and I can acquire the signal AFM on different channels that I've assigned.
Now I would like to try to acquire the signal by changing the frequency in live mode, how can I do?
THX :)
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
March 23, 2015 at 11:02 am - Permalink
Certain aspects of the acquisition are controlled by the properties of the waves you provide to receive the data. If multiple channels are being scanned, you must provide multiple waves. All the waves must have the same length. The sampling period is set by the dX factor of the wave scaling of the first wave in WaveParameterString. See Analog Input: Using Waves.
in
displayhelptopic("DAQmx_Scan")
HJ
March 23, 2015 at 12:38 pm - Permalink
So I have to use the AFM to acquire the signal deflection and torsion, so are two channels. Using an NI PCI-6052E.
On IGOR_NIDAQ use the command DAQmx_Scan / DEV = "devicename" WAVES = "Def, 2, Tor, 3;"
to acquire the signal, also including the relative FLAG, as for example / RPT.
With this command, I believe that the capture rate can not be changed, I Would indeed effettare scan of acquiring the signal at different frequencies (eg. From 10Hz to 300Hz).
CB
March 24, 2015 at 03:21 am - Permalink
"The sampling period is set by the dX factor of the wave scaling of the first wave in WaveParameterString."
This should work as long as your sampling increment is within the limits of the NI board you are using. You will have to re-scale (and possibly change the number of points) of the destination waves for each frequency you use.
March 24, 2015 at 07:13 am - Permalink
thanks, so if:
Make/O/N=100 Deflection, Torsion [100 points]
SetScale/P x, 0,0.1 "s", Deflection, Torsion
DAQmx_Scan/DEV="dev4" WAVES="Deflection, 2; Torsion, 3;" (There are my parameters)
Then, display the two waves.
After I want to change the sampling period, so, I write in the command line:
SetScale/P x, 0,1 "s", Deflection (for example)
right?
Can you give me an example, please?
March 24, 2015 at 07:53 am - Permalink
March 24, 2015 at 08:09 am - Permalink
The NIDAQ package READS the DX value from the wave scaling and sets the sampling frequency to this value.
Your example will change the sample rate from, 10Hz to 1Hz.
I assume you will first have to readjust your number of data points in the wave, then set the wave scaling to your altered sample frequency and start the acquisition AGAIN (and maybe you want to keep a copy of the other data).
HJ
March 24, 2015 at 08:23 am - Permalink
Thank You so much: so I do this:
Firstly:
Make/O/N=100 Deflection, Torsion [100 points]
SetScale/P x, 0,0.1 "s", Deflection, Torsion
DAQmx_Scan/DEV="dev4" WAVES="Deflection, 2; Torsion, 3;"
Then, display the two waves.
Secondly, I re-adjust the number of data points in the wave, then set the new wave scaling:
Make/O/N=200 Deflection, Torsion
SetScale/P x, 0,1 "s", Deflection, Torsion
DAQmx_Scan/DEV="dev4" WAVES="Deflection, 2; Torsion, 3;"
and finally again, display waves
right?
PS.
So in < SetScale / P x , 0.1 " s" , waveName >
0.1 is the frequency of 1Hz , while 0,0.1 = 10Hz ?
why? I don't understand.
March 24, 2015 at 08:31 am - Permalink
The NIDAQ Tools MX manual includes a chapter called "Guided Tour of NIDAQ Tools MX". That chapter includes a section "Programmer's Tour" that takes you through just this issue, step-by-step. Perhaps that will help you.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
March 24, 2015 at 10:07 am - Permalink
March 25, 2015 at 02:03 am - Permalink
setscale/P x, 0, 20e-6,"s" Input0, Input1, Input2, Input3 // set the sample rate at 50kHz ( 20us per point)
string ScanString = "Input0, 0/PDIFF, -0.5,0.5;Input1, 1/PDIFF, -0.5,0.5; Input2, 2/PDIFF, -0.5,0.5; Input3, 3/PDIFF, -0.5,0.5;"
// using a string variable to store the wave information is a good way to make more readable code
DAQmx_Scan/MC={"/Dev1/RTSI7", 20e6}/DEV="dev1"/TRIG={"/dev1/Ctr0InternalOutput"}/AVE={100,40}/BKG/EOSH="scan_hook()"/STRT=0 WAVES = ScanString
// you can ignore the detailed flags; they are documented if you are interested
I hope this helps.
March 25, 2015 at 03:35 am - Permalink
With the /P flag for the
setscale
command you give a start value and an increment for the wave's x axis. The increment dx is the spacing of the data points. If you set dx to 0.1 you have 10 points in the interval [0,1[ . The NIDAQ assumes you want 10 points to be sampled in 1 s with constant temporal spacing. This is called 10 Hz.If you set dx to 1 it means 1 sample per second: 1Hz.
If you set dx to 0.01 it means 100 samples per second: 100Hz and so on.
Regarding your example a few comments:
If you use the
make
command twice the old waves will be overwritten. You can make waves with a new name or use theduplicate
command to store a copy.It is not necessary to display the waves again; Igor updates the graphs if the data is changed. You can use
appendtograph
to add 'waves to a graph' (actually you don't add the data but a reference to the data)Your new number of data points seems odd: The first example records for 10s the second one for 200s (time=DataPoints * dx)
HJ
March 25, 2015 at 03:36 am - Permalink
Thank you very much , I 'll try it!
March 25, 2015 at 05:04 am - Permalink
Thanks to all , now I understand how to set the frequency with you your examples !
Thank You!!!
March 30, 2015 at 07:03 am - Permalink
- I must acquire the signal for a specific time interval ( eg 30 seconds)
( I mean start capturing and stopped after the time set by me)
- Acquired the signal , make a calculation of the standard deviation ( the command should be wavename wavestat - . V - SDEV ) Right?
thanks again!
March 31, 2015 at 03:08 am - Permalink
Do your acquisition.
Call
Wavestats
on your data wave and the std.dev. is stored in V_sdef. If you ONLY need the std.dev. you can also use thesqrt(variance(wavename))
functions as mentioned in the wavestats help.I strongly recommend to read the manual (I know there are many pages. But Igor can do a lot and its well documented.)
HJ
March 31, 2015 at 03:25 am - Permalink
Dear HJDrescher , thank you for your support, I'm reading the manual, but there are some steps that I have not clear , unfortunately, are a student novice and is the first time that I work with this program and I look out the programming . Unfortunately I have no tutor to ask for clarification .
Then following your advice , I should set "make / N = 30000 " for the number ofdata points to be acquired in 30 seconds , but the "sample rate" and "duration" as I configure them ?
I suppose that to set SampleRate ---> SetScale/P x 0,0.0001 wave0 (right?)
March 31, 2015 at 05:42 am - Permalink
There are several examples in the manual, try to program something simple where you know the result to get some feeling. You don't have to remember every detail in the manual but you should get familiar with the basic concepts and where to look up details (I would recommend to read Volumes I & II).
First you need to decide your sample rate and your acquisition time.
The number of needed data points is calculated by N=sample rate * acquisition time
Your dx is calculated as dx= 1/sample rate.
You create your input wave and set the scale.
Then you start your data acquisition and the NIDAQ will do the rest.
By these parameters for the wave you tell the NIDAQ how it should acquire the data. If you wonder how, try this:
Make /N=(Rate*Duration) InputWave
SetScale /P x, 0, (1/Rate), "s" InputWave
InputWave=2*Sin(x)+GNoise(0.5)+1 //Simulate some data acquisition
Display InputWave
Print "dx="+Num2Str( DimDelta(InputWave,0) )
Print "Rate="+Num2Str(1/ DimDelta(InputWave,0) )
Print "NumPnts="+Num2Str(NumPnts(InputWave))
Print "Duration="+Num2Str(NumPnts(InputWave)*DimDelta(InputWave,0))
Notice: The four print commands at the end only use the InputWave as a source of information -- just like the NIDAQ.
HJ
PS:
Your example would record for 3 seconds at 10 kHz.
March 31, 2015 at 06:05 am - Permalink
Thanks a lot, really. I'm trying to read the manual IGOR PRO.
I tried your commands and work well with my tests.
Just one question, when I try everything with the command:
DAQmx_Scan / DEV = "dev4" /RPT WAVES = "wave0, 2;"
after setting "duration = 30" (example).
The expiration of 30 seconds acquisition does not stop, why? what am I wrong?
March 31, 2015 at 07:25 am - Permalink
DAQmx_Scan
says/RPT (for WAVES keyword only) Causes the scanning operation to be re-started when all data are acquired. The same waves are used again, overwriting previously acquired data. This causes an oscilloscope-type mode.
There may be some latency between the end of one scan and the beginning of the next, as the end of a scan is detected only during Igor's main event loop or when DoXOPIdle is called.
If the scanning operation uses a trigger, the same trigger is used for every scan. NOTE: this is different from previous versions of NIDAQ Tools.
If you are not sure what commands and flags do, the Igor help or the manual is the first address to go :-)
HJ
March 31, 2015 at 08:05 am - Permalink