Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Sync Reference clock and Sample clock (not LabView but Daqmx, Sync and C)

Solved!
Go to solution

Well I found an example that did look similar to what I wanted...in LabView: http://zone.ni.com/devzone/cda/tut/p/id/9308

 

Now the issue is all about synchronizing Timestamps and sample:

 

Here is a brieft list of what I called...

  1. DAQmxCreateTask

  2. DAQmxCreateAIVoltageChan

  3. DAQmxSetRefClkSrc (used NISYNC_VAL_CLK10 = "PXI_CLK10")

  4. DAQmxRegisterEveryNSamplesEvent

  5. niSync_init (Used a PXI-6682)

  6. niSync_SetAttributeViInt32 (used Terminal = NISYNC_VAL_PXISTAR0 and NISYNC_ATTR_1588_TIMESTAMP_BUF_SIZE = 3000)

  7. niSync_CreateClock (used Terminal = NISYNC_VAL_PXISTAR0)

  8. niSync_EnableTimeStampTrigger (used Terminal = NISYNC_VAL_PXISTAR0)

Now this list makes me able to create a timestamp everytime the clock triggers a RISING edge...

 

Now how do I synchronise those timestamps to be useful for my sampling? (I mean I need to sync my timing card with the PXI_CLK10) because for now the rates will not match the sampling rate.

 

ALSO...another weird bit....

 

some of my cards will accept DAQmxSetRefClkSrc but others must use DAQmxSetMasterTimebaseSrc.

 

Now I can't use DAQmxSetMasterTimebaseSrc with PXI_CLK10...no clue why....

 

So how would I sync THOSE cards....

 

Alright I might be totaly wrogn with my approach...but I'm new with NI stuff and using C is not exactly the most documented piece of NI.

 

Thanks in advance,

Seb

 
0 Kudos
Message 1 of 9
(7,817 Views)

Hello Seb,

 

It might be more fruitful if we take a step back here to address what you are trying to synchronize and what timing rates you are hoping to work with.  From there, maybe we can find the proper approach to what you are trying to do.  How tight of syncronization are you hoping to have?  Is there any particular reason that you are using a timing card?

ColeR
Field Engineer
0 Kudos
Message 2 of 9
(7,802 Views)

First of all thanks for the reply,

 

1) How tight of syncronization are you hoping to have?

 

Well I guess as tight as possible...but for now I'm trying to link stuff like this:

 

1) Create tasks (for my 3 card types: S, M and Signal Acquisition

2) Create a clock linked to a Timing card vie a PXI_Trigger (like PXI_Trigger0)

3) Link the start trigger of every task to the MASTER task

4) Link the start trigger of the MASTER task to PXI_Trigger0

5) Start every SLAVE task

6) Start Master task

 

Now that sounds simple enough...but because I'm using a M, S and Signal Acquisition I ran in a few problems:

1) I can't seem to sync my timestamps....they keep overflowing and stuff

//Timestamp configuration ViInt32 t_NanoSecPerPulse; MACRO_SyncErrRep(aSyncSession, niSync_GetAttributeViInt32(aSyncSession, "", NISYNC_ATTR_1588_CLK_RESOLUTION, &t_NanoSecPerPulse)) //Get half the ticks of this time card in 1 NS int t_TimeStampHalfRate = S_TO_1NS / t_NanoSecPerPulse; niSync_CreateClock(aSyncSession, NISYNC_VAL_PXITRIG0, t_TimeStampHalfRate, t_TimeStampHalfRate, 0, 0, 0, 0, 0, 0); niSync_EnableTimeStampTrigger(aSyncSession, NISYNC_VAL_PXITRIG0, NISYNC_VAL_UPDATE_EDGE_RISING);

 

2) When my MASTER task is anything BUT an S serie this call doesn't work:

 

DAQmxCfgDigEdgeStartTrig(t_MasterHandle, NISYNC_VAL_PXITRIG0, DAQmx_Val_Rising);

 

So it works for the S serie but nothing else

 

3) Well after reading this I got a better idea on how to sync them all:

http://forums.ni.com/ni/board/message?board.id=250&message.id=11689

 

4) So now I'm able to link the M Serie with the S Serie......but the SIGNAL  ACQUISITION though...

ISo if the S is a master it connects its Ref Clock to NISYNC_VAL_RTSI7 and in turn I connect the  NISYNC_VAL_RTSI7 to the M series

 

but if I try that on the Signal Acquisition it returns that the hardware can't do that...

Also you can't set the reference rate on the signal Acquisition...are they trying to tell me I shouldn't sync that PXI-4496 or something?

 

Well yea those are the issues that are bugging me at the moment

0 Kudos
Message 3 of 9
(7,799 Views)

Hello Seb,

 

Due to the timing engines with each of these cards, it will be slightly difficult to make all of these match up.   Offhand I do not know of the names of all of the timing engines in this system so I will have to do some digging.  However, I am still a little confused as to why you would be using the timing card.  If you are not sharing external triggers between all of  the cards or bringing in an outside clock (or sharring the clock between chassis), then you really do not need the timing card in your system.

ColeR
Field Engineer
0 Kudos
Message 4 of 9
(7,785 Views)

There is indeed an external clock linked to the timing card using the 1588 protocol.

 

See this for more details:
http://forums.ni.com/ni/board/message?board.id=40&message.id=7906#M7906

 

Yes that post also needs an answer ^^;

 

Thank you for your time once again 🙂

 

As for timing issue...yea I'm starting to think maybe there is no unversal PXI clock....:(

0 Kudos
Message 5 of 9
(7,778 Views)

Hello Seb,

 

I am not sure as to what you are referring to with the universal PXI clock.  The problem comes down to (I think this is our root problem) is that the S series does not PLL to the 10 MHz backplane clock and the fact that we are trying to sync M-Series, S-Series, and DSA which all have their own reference and sample clocks. 

 

This is tricky with just the M-Series, DSA, and S-series on their own, but gets even a little hairier with the 1588 communication thrown in.  I would like to verify some tests before giving you something to try to make sure that I don't lead us down a bad road.

ColeR
Field Engineer
0 Kudos
Message 6 of 9
(7,756 Views)

Well on the good news, we managed to accept not using S series with DSA...

 

So now it will only be M and DSA or S and M....

 

that helps simplify things... because now I can just ignore the limitations of working with DSA and S series... (our client didn't seem comfortable with not having a reference clock and only using the sample clock as a timebase)

 

 

Well this solves my issue...although I can't say this thread is solved until someone tell me: there's no way to sync a reference clock with a time base

 

But thanks for all the work, and if someoene do say it's impossible, then I'll solve the thread 🙂

 

Thanks again,

Seb

0 Kudos
Message 7 of 9
(7,752 Views)
Solution
Accepted by Sebastien Dupere

So,

 

We can have the same sample clock for all of these devices, but we are not PLL'ing with the S-Series card, we cannot ensure that they will all be in phase.  However, since all of these devices would be based on the same reference clock, we would not get any drift once we started the task.  Would that work? 

 

An alternative would also be to use the new X-Series card which can also do simultaneous sampling, but I don't know if that's feesible within your application.

ColeR
Field Engineer
0 Kudos
Message 8 of 9
(7,729 Views)

No, I can't use the X series, but this answers my question quiote nicely none the less 🙂

 

I'll know for future reference ^^

 

thanks,

Seb

0 Kudos
Message 9 of 9
(7,723 Views)