Skip to content

Commit 346bf6c

Browse files
committed
Minor documentation improvements
1 parent d051fdc commit 346bf6c

File tree

4 files changed

+35
-25
lines changed

4 files changed

+35
-25
lines changed

code/+vidrio/+AI/hardwareContinuousVoltage.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
hTask.createAIVoltageChan(devName, physicalChannels, [], minVoltage, maxVoltage);
6666

6767

68-
% * Configure the sampling rate and the number of samples
68+
% * Configure the sampling rate and the size of the buffer in samples
6969
% More details at: "help dabs.ni.daqmx.Task.cfgSampClkTiming"
7070
% C equivalent - DAQmxCfgSampClkTiming
7171
% http://zone.ni.com/reference/en-XX/help/370471AE-01/daqmxcfunc/daqmxcfgsampclktiming/

code/+vidrio/+AI/hardwareContinuousVoltageWithCallBack.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
% Also see:
2626
% TMW DAQ Toolbox example: daqtoolbox.AI.analogInput_Continuous
2727
% ANSI C: DAQmx_ANSI_C_examples/AI/ContAcq-IntClk.c
28+
% vidrio.AI.hardwareContinuousVoltage (without a callback function)
2829

2930

3031
% Parameters for the acquisition (device and channels)
@@ -57,7 +58,7 @@
5758
hTask.createAIVoltageChan(devName, physicalChannels, [], minVoltage, maxVoltage);
5859

5960

60-
% * Configure the sampling rate and the number of samples
61+
% * Configure the sampling rate and the size of the buffer in samples
6162
% More details at: "help dabs.ni.daqmx.Task.cfgSampClkTiming"
6263
% C equivalent - DAQmxCfgSampClkTiming
6364
% http://zone.ni.com/reference/en-XX/help/370471AE-01/daqmxcfunc/daqmxcfgsampclktiming/
@@ -80,7 +81,7 @@
8081
hTask.start
8182

8283

83-
fprintf('Recoding data on %s. Close window to stop.\n', devName);
84+
fprintf('Recording data on %s. Close window to stop.\n', devName);
8485

8586

8687

code/+vidrio/+sync/readme.md

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,73 @@
11
# Synchronising DAQ operations across devices
22

33
The examples in this folder relate to synchronising tasks.
4-
It's assumed you're already familiar with the information in vidrio.mixed
5-
Also see ContinuousAI.c in the DAQmx_ANSI_C_examples directory
4+
It's assumed you're already familiar with the information in `vidrio.mixed`.
5+
Also see `ContinuousAI.c` in the DAQmx_ANSI_C_examples directory.
6+
The following demo uses the class `vidrio.sync.sine_AO_AI`, which just plays a sine wave out of AO0 on the target DAQ device.
67

7-
### One
8+
### 1. Starting two tasks at the same time
89
Let's start two tasks at the same time on different DAQs from the command line.
910
Hook up the AO0 lines of each DAQ to a scope then run:
1011

1112
```
1213
>> B=vidrio.sync.sine_AO_AI('Dev1');
1314
>> R=vidrio.sync.sine_AO_AI('Dev2');
14-
>> B.startAcquisition;R.startAcquisition;
15+
>> B.startAcquisition; R.startAcquisition;
1516
```
1617

17-
Where 'Dev1' and 'Dev2' are your DAQ names.
18-
You should see two waveforms with a phase shift.
19-
Trigger off the waveform on channel 1 of the scope and change the time scale to show about one cycle of the waveform.
20-
Watch for a while. What do you notice?
18+
Where `'Dev1'` and `'Dev2'` are your DAQ names.
19+
You should see two waveforms with a phase shift, since they didn't start at the same instant.
20+
Set up the scope to trigger off the waveform on channel 1 and change the time scale to show about one cycle of the waveform.
21+
Watch for a while. See the phase shift?
2122

2223
Stop the acquisition:
2324

2425
```
2526
>> B.stopAcquisition;R.stopAcquisition;
2627
```
2728

28-
Also see `vidrio.sync.phaseMonitor('Dev1','Dev2');`
29+
You can also use `vidrio.sync.phaseMonitor('Dev1','Dev2');` to monitor the phase of the two waveforms without a scope.
30+
2931

30-
### Two
31-
Will this problem go away if start the two waveforms at exactly the same time?
32-
vidrio.sync.sine_AO_AI triggers the AO task from the AI task so we need to set this up to wait for a trigger:
32+
### 2. Triggering the tasks simultaneously
33+
Will the phase shift problem go away if start the two waveforms at exactly the same time?
34+
`vidrio.sync.sine_AO_AI` triggers the AO task from the AI task so we need to set this up to wait for a trigger:
3335

34-
Set up triggers so nothing happens until 5V goes into PFI0
36+
Set up triggers so nothing happens until 5V goes into PFI0.
37+
The tasks need to be stopped (see above) then you can run:
3538

3639
```
37-
>> B.hAITask.cfgDigEdgeStartTrig('PFI0','DAQmx_Val_Rising'); R.hAITask.cfgDigEdgeStartTrig('PFI0','DAQmx_Val_Rising');
40+
>> B.hAITask.cfgDigEdgeStartTrig('PFI0','DAQmx_Val_Rising');
41+
>> R.hAITask.cfgDigEdgeStartTrig('PFI0','DAQmx_Val_Rising');
3842
```
3943

40-
Now wire up the rack so that the two PFI0 ports are connected. If using BNC, attach a T-piece to one.
44+
Note how we can configure the start trigger properties directlty on the two objects we have already created.
45+
This is what is nice about object-oriented programming.
46+
To use the triggers, wire up the rack so that the two PFI0 ports are connected. If using BNC, attach a T-piece to one.
47+
Then start the tasks:
4148

4249
```
4350
>> B.startAcquisition;R.startAcquisition;
4451
```
4552

46-
Nothing happens on the scope until you hook up PFI0 (e.g. with your T connector) to +5 (the breakout box provides this)
53+
Nothing happens on the scope until you hook up PFI0 (e.g. with your T connector) to +5 (the breakout box provides this).
4754
You can unplug the 5V line right away, it's only needed transiently for the trigger.
55+
Of course you could also hook up PFI0 to a digital line and trigger it via MAX Test Panels or even set up a separate digital task in MATLAB.
4856

4957
What do you see on the scope? The waveforms should be in phase perfectly. Nice, huh?
50-
Keep watching. Ah.....
58+
Keep watching. Ah... They drift apart over time.
5159

5260
Stop the acquisition:
5361
```
54-
>> B.stopAcquisition;R.stopAcquisition;
62+
>> B.stopAcquisition; R.stopAcquisition;
5563
```
5664

57-
### Three
65+
### 3. Sync the clocks
5866
The clocks are drifting!
5967
Clearly we need a *shared clock* between the boards.
6068
Each class is set up such that the AI task on that device uses the AO clock of the same device.
6169
So all we need to do is have the AO clock of the DAQ in one class use the AO clock of the DAQ in the other class.
6270

63-
6471
If your cards are in a PXI chassis or linked by an RTSI cable then you simply tell DAQmx that one device should use the other's clock:
6572

6673

@@ -89,4 +96,6 @@ Wire up your DAQ remembering to use PF1 not digital port 1 on line 0.
8996
>> B.startAcquisition;R.startAcquisition;
9097
```
9198

92-
Nice synchronised waveforms!
99+
Nice synchronised waveforms!
100+
Note that the above only works when your two (or more) tasks need to run at the same rate.
101+
For more see the [NI synchronisation white paper](http://www.ni.com/white-paper/11369/en/).

code/basicConcepts/simpleOOexample.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
% For example, our simple scanning software (https://github.com/tenss/SimpleMScanner) contains
7272
% classes that inherit handle.
7373
%
74-
% For those already familiar with "references: objects that inherit handle return a *reference*
74+
% For those already familiar with "references": objects that inherit handle return a *reference*
7575
% to the object after construction. So you can pass a copy of the reference to another function
7676
% and have it modify it without creating a new copy of the object that controls the DAQ.
7777
% The handle class also allows us to create notifiers and listeners:

0 commit comments

Comments
 (0)