Jump to content

Synchronizing digital and analog waveforms


Recommended Posts

Hi all, 

I am new to using LabVIEW and I was hoping to get some help with the issues I am having with my VI. I am working with a myDAQ that I have set to produce an analog output and also acquire data from a digital and analog input. I am then graphing that data on a mixed signals graph, which is working properly. However, the two waveforms on the graph are not synced. It seems that the digital input is off by approximately 0.05 seconds and I'm not quite sure how to fix this. I've tried using two separate DAQs but this didn't make a difference. I also thought that maybe I needed to use sample clocks for each of the inputs, however when I try using a sample clock with the digital input I get an error. 

Does anyone have any suggestions on how to approach this issue? I've attached a photo of my current VI. 

Anything would help, thanks!

post-51848-0-30781500-1399331447_thumb.p

Link to comment

Welcome to the forums.  And congratulations on using a myDAQ with the DAQmx API instead of DAQ Assistant, or some other myDAQ express VI.

 

What you need to do is as you suggested, create a common clock that is shared between both tasks.  So you would make an analog task, and for the timing source provide an internal clock channel.  Depending on your hardware there are several and some are more flexible then others.  You then make a digital reading task that uses the same clock source, then you start your analog and digital task.  Neither one will take samples until the clock source you created has started, but when it does it will take samples from both, at the same time.  So the third task you need to start, is the one associated with the common clock source.

 

Another method that I just found by searching I've never tried but looks like it creates the analog task, then uses that clock from that task to read from the digital task.  It can be found here.

 

https://decibel.ni.com/content/docs/DOC-12185

 

Also notice in that example how they only create the tasks once, and close once.  This is a better way of programming because there is overhead from opening and closing the task over and over.  Also you are doing finite reads so your data won't be continuous, it will have breaks between loop iterations and data will be lost where the example I linked to will continue reading where the last read left off.

 

EDIT: For any of this to work your hardware needs to support providing the internal clock to both tasks.  I think myDAQ should be able to do this but I have never done this with that hardware.

  • Like 1
Link to comment

I also came across that example and tried using it will my setup but I continue to get an error when using the sample clock with the digital input. I also just tried setting up a really simply VI with a digital input and sample clock but it never seems to work. I'm not sure if I am making a mistake or if the issue is my hardware. 

 

The error that i get is, "Error -200077 occurred at Property Node DAQmx Timing" and the possible reasons was "requested value is not a supported value of this property"

Link to comment

All I can do is simulate a myDAQ in MAX but the testing I did kept giving errors stating the the route for the timing source to the digital read wasn't allowed.  The easiest way to do this is to provide the DI with a sample clock of the built in 100KHz timer.  I also tried using the single counter the myDAQ provides, and the FREQ OUT which can be configured to have different rates where 6250Hz is the slowest it can run, and it also reported an error with the route being attempted.

 

I haven't used the hardware enough, but it appears it doesn't support what you are trying.  You should get the opinion of someone with more experience with this hardware before giving up.

Link to comment
  • 3 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.