02-08-2013 10:28 AM - edited 02-08-2013 10:29 AM
With the Matlab DAQ toolbox it is possible to export a scanclock via addClockConnection() (See http://www.mathworks.de/de/help/daq/ref/daq.session.addclockconnection.html for a basic code example).
However, I could not find any information on the properties of the exported signal on the NI USB 6229 (BNC) , for instance frequency, amplitude, duty cycle etc., neither in the documentation, nor in the web or in this forum.
I would be very happy if someone point me to some documentation concerning the properties of scanclock.
Solved! Go to Solution.
02-15-2013 09:31 AM
Hi,
I may be able to help you, but I need to know more about what you're trying to do.
Can you please provide more details about your use case and what you are trying to do with the clock connection?
Regards,
Wael Hemdan
MathWorks
02-18-2013 03:08 AM
Many thanks for your reply.
I intended to use the NI USB 6229 to export a clock to synchronize the device with an EEG amplifyer. The aquisition software of the amplifyer offers the possibility to import a clock, but asks to specify the frequency of the clock signal and prefers clock signals with a duty cycle of 0.5. My problem is (or better, it was; see below why) that the properties of a clock exported via addClockConnection() are not documented (at least I did not find any information).
Meanwhile I solved this problem by exporting a counter channel using addCounterOutputChannel(). Fortunately, the counter output allows for specifiying frequency and duty cycle of the counter output.
Nevertheless, I would be grateful if you could point me to resources commenting on the properties of the clock.exported via addClockConnection().
Best,
user2456
02-18-2013 10:44 AM
Hi user2456,
I recommend you to post your question on the MathWorks forum (http://www.mathworks.de/support/),
thus it is a Toolbox supported by MathWorks that uses the National Instruments DAQmx driver.
This way you might get more information on this topic.
Best Regards,
Martin L.
National Instruments
02-19-2013 10:26 AM
Hi,
All channels in a MATLAB session run at the same rate. So if you create a session 's', s.Rate would be the rate of your acquisition or generation. the 's.addClockConnection' method allows you to import or export a scan clock for synchronization purposes.The syntax below allows you to export the session clock from 'PFI0' to an external device. You can probably find documentation on the NI website for properties of the onboard clock signal, but it appears to be a 5 volt pulse running at the session rate - which is typical to synchronize devices together.
s.addClockConnection('dev2\pfi0', 'external', 'ScanClock');
If you need 50% duty cycle, you would create your own clock using a counter output channel as you did above. If you connect that clock to the EEG, it can use it; and if you need your NI device to run off the counter output clock (instead of the onboard clock), you would also import the counter output signal back into the session and make sure to set the session rate to match the counter output frequency. Assuming s.Channels(2) is your counter output channel, the code below imports the scan clock on the same terminal as the counter output channel, so no extra wiring is needed.
s.Rate = s.Channels(2).Frequency;
s.addClockConnection('external', ['dev2\' s.Channels(2).Terminal], 'ScanClock');
This allows both the NI device and your EEG to run on the same clock. You can also have your session export a start trigger using simillar syntax to the above to ensure both devices start on the same clock edge.
s.addTriggerConnection('dev2\pfi0', 'external', 'StartTrigger');
I hope this helps,
Regards,
whemdan
MathWorks
02-20-2013 03:23 AM - edited 02-20-2013 03:25 AM
Hi whemdan,
many thanks for your reply.
@whemdan wrote:
Hi,
All channels in a MATLAB session run at the same rate. So if you create a session 's', s.Rate would be the rate of your acquisition or generation. the 's.addClockConnection' method allows you to import or export a scan clock for synchronization purposes.The syntax below allows you to export the session clock from 'PFI0' to an external device. You can probably find documentation on the NI website for properties of the onboard clock signal, but it appears to be a 5 volt pulse running at the session rate - which is typical to synchronize devices together.
s.addClockConnection('dev2\pfi0', 'external', 'ScanClock');
Thank you, with these directions I was able to "find" the clock signal using an oscilloscope. It's frequency indeed matches the session rate, but the pulses are so short that they weren't recognizable in the oscilloscope unless you set the session rate quite low and at the same time zoom in the time axis of the oscilloscope.
If you need 50% duty cycle, you would create your own clock using a counter output channel as you did above. If you connect that clock to the EEG, it can use it; and if you need your NI device to run off the counter output clock (instead of the onboard clock), you would also import the counter output signal back into the session and make sure to set the session rate to match the counter output frequency. Assuming s.Channels(2) is your counter output channel, the code below imports the scan clock on the same terminal as the counter output channel, so no extra wiring is needed.
s.Rate = s.Channels(2).Frequency;
s.addClockConnection('external', ['dev2\' s.Channels(2).Terminal], 'ScanClock');
This allows both the NI device and your EEG to run on the same clock. You can also have your session export a start trigger using simillar syntax to the above to ensure both devices start on the same clock edge.
s.addTriggerConnection('dev2\pfi0', 'external', 'StartTrigger');
So far it did not occur to me that I need to feed the counter signal back into the NI device. I thought that, although session rate and counter frequency might differ, they still are in synchrony since they are both generated by the same onboard clock. To illustrate this thought by an abstract example, imagine the following:
After one second, the analog port has put out 10 square pulses and the counter channel 10000, that is, a ratio of 1:1000. Since both signals are created based on the same onboard clock, I would expect this ratio to be constant until eternity, that is, they are synchronized. This would not necessarily be the case if both signals are created based on different clocks (i.e., by two different devices).
If the logic of this example holds, there would be no need to feed the counter signal back into the NI device, right?
Best
user2458
02-20-2013 09:29 AM
Hi,
The session does not know what you are usig the counter output channel for... so when you create a counter output channel with a certain frequency and duty cycle, the analog subsystems are still running off of the onboard clock. In our example, we happen to be using the counter output as a clock, but the session does not know that. We import an external clock (which happens to be the same one we created using the counter output), and tell the session the rate of this external clock (since it has no way of knowing that) and this way the analog subsystem and the EEG are both using the same clock that was generated using the counter output.
Regards,
whemdan
MathWorks
02-20-2013 09:34 AM
Many thanks for your explanations.