AFM Experiment - IGOR PRO NIDAQ Tools

Hi, I started my lab activities using an AFM.

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 :)
You haven't given us much information. What frequency do you want to change? Is this something in the AFM? If so, it will depend entirely on how the instrument works. It may be possible, but without knowing how your AFM works, we can't help.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
I can only guess but if you want to change the sampling rate you will have to change the wave scaling of your input wave and most likely restart the scan (I am too lazy to search my old NI USB-6008 without further details):

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
Ok! excuse me
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
From the NIDAQmx Tools manual:
"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.
s.r.chinn wrote:
From the NIDAQmx Tools manual:
"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.


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?
But using SetScaling I only change the set of x or y axis, I don't understand how is possible to change the frequency.
This is actually quite simple to explain (and was actually mentioned twice):
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
HJDrescher wrote:
This is actually quite simple to explain (and was actually mentioned twice):
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


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.
Carlo-

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
I apologize if I have put many questions , but I have a little ' difficulty in using the program Igor , means specially in the programming , because it is the first time I look at this SW .
Here is an example of some code I used. Sometimes it is easier to read code than write it:)
make/O/N=20000 Input0, Input1, Input2, Input3   //  inputs for A/D
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.
I would also suggest to read chapter II-5 about waves in the Igor manual.

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 the duplicate 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
s.r.chinn wrote:
Here is an example of some code I used. Sometimes it is easier to read code than write it:)
make/O/N=20000 Input0, Input1, Input2, Input3   //  inputs for A/D
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.


Thank you very much , I 'll try it!
HJDrescher wrote:
I would also suggest to read chapter II-5 about waves in the Igor manual.

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 the duplicate 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


Thanks to all , now I understand how to set the frequency with you your examples !

Thank You!!!
Now that I have learned to acquire the signal , I have to do it this way :
- 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!
Calculate the number of data points you need (30 000) from the sample rate (1000 1/s) and the duration (30 s).
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 the sqrt(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
HJDrescher wrote:
Calculate the number of data points you need (30 000) from the sample rate (1000 1/s) and the duration (30 s).
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 the sqrt(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


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?)
Starting new is tough, but reading the manual is usually a good way to get started :-)

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:
Variable Rate=1000, Duration=30  // 1kHz sampling for 30 secs
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.

HJDrescher wrote:
Starting new is tough, but reading the manual is usually a good way to get started :-)

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:
Variable Rate=1000, Duration=30  // 1kHz sampling for 30 secs
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.


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?
As the documentation of 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