Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

NI PCI-7813R GPS 1pps/10Mhz synchronization

yeah, i know we can use NTP. just the tolerance is 0.1 microseconds. i think i can only use GPS, right? i am confused as how the GPS can be used to make the synchronization. is it possible that you can give me a small example vi code to explain how the synchronization is made and how the measurement is triggered? That would be great! Thanks very much!

0 Kudos
Message 21 of 28
(1,736 Views)

Henry,

 

So if you have a local with the time in ticks (25 ns in my case), define a start time in ticks (if you have to). Then, in a loop, do your measurement, and add 10000000 ticks to the start time. The new time in ticks will be .25 s later, and that is when the next measurement is.

 

If you have a good clock reference, and you only need a well defined frequency (not exact timing), you could just wait for a pulse edge, and do 4 measurement with 10000000 ticks between them. You will have 3 intervals, so the max error is the error of the clock. E.g. if the clock is 1 ppm accurate, the maximum error will be 10X25 ns for the first, 20X25 ns for the second, and 30X25 ns for the third measurement. This is a lot easier then what I do, but you do not have time synchronisation, only matching frequencies.

 

The schema I use can also be used to correct for the error, as described earlier. That can make the timing more accurate, without the need for a more expensive clock reference. The simple variant described above can also be used to do that. Add a construction that counts the number of ticks between two 1 pps pulses, and subtract if from 40000000. That is the error you need to devide over the 4 intervals. So if you measure 40000040 ticks in one second, you need to wait 10000010 ticks in stead of 10000000. Again, the error will be reduced.

 

Did you look at the presentation link? All the timing details and examples are in there.

 

Regards,

 

Wiebe.

0 Kudos
Message 22 of 28
(1,726 Views)

Hi Wiebe,

 

I think it is a little bit difficult for me. i think i will start just by take the measurement once per second. so in that way, i can directly use the PPS, right? can i write some code so that the measurement is triggered at the rising edge of the PPS? i have looked at the presentation link you gave me, but i can't find the timing details. is it possible that you can post the timing examples here? Thanks very much!

 

Regards,

 

Henry

0 Kudos
Message 23 of 28
(1,720 Views)

Henry,

 

You can trigger something with the 1 PPS, at least if you can guarenty it is there. It won't be there if the reception is poor (I think it needs at least 4 satelites).

 

If you can use the 1 pps, it is really easy. I would even say that if your measurement is about average difficulty, the trigger part is far more easy then the measurement. Anyway, here is how to do it. I really cannot give code. The original project it is not mine, I just made it.

 

Wire the 1 pps to an input of the FPGA. In a single cycled timed loop, read the input. Put the value in a shift register. If the value is true, and the previous value is false, the result is true. So, if the result is true, do your measurement. If your measurement only takes one cycle, do it in the same loop. You might add a 'dead time', to prevent tirggers by jitter of the pulse. If the measurement takes longer, or is complex, fill a FIFO if the value is true. In another loop, do the measurement if there is a value (time out is false), or skip it if not.

 

Regards,

 

Wiebe.

0 Kudos
Message 24 of 28
(1,714 Views)

Hi Wiebe,

 

Thanks for your reply. Now i want to start at the very beginning. so i generated a signal which changes along with time. i want to set a trigger button so that every time when i press the trigger button, one measurement is performed and the value of the signal at that time is measured. do you know how can i measure the signal generated by labview itself? Thanks very much!

 

Regards

 

Henry

 

0 Kudos
Message 25 of 28
(1,711 Views)

Henry,

 

Am I right in assuming that you are a beginner? This is realy very basic. I think the original application (1 pps, etc.) might be a bridge too far, unless you get some hands on help, or follow a course or something. At some point, I'll have to stop assisting you, and probably before you're done. Also, this is getting off topic. If you need more help like this, you might get more feedback if you post in a new thread.

 

So you have a signal wired to the FPGA (from the FPGA itself, the PC, a function generator, whatever). On the FPGA, make a loop, with a case in it. The trigger (a control at first, the 1 pps later on) has to be checked for a rising edge. So you need to put the value in a shift register, and check if it was false, and is true (previous! AND current). As an alternative, you can use a point by point VI, probably called "boolean zero crossing" or "rising edge" or something. The case selector is wired to the boolean result. In the case structure, do your measurement, and put the result in a DMA FIFO to the PC.

 

This is real simple. A loop, a VI, a case, and a FIFO. If you need more help, please specify what the exact problem is. Or like mentioned before, formulate the isolated problem, and ask help in a seperate thread (after searching for the problem).

 

Regards,

 

Wiebe.

 

 

0 Kudos
Message 26 of 28
(1,708 Views)

Hi,

sorry for a relatively late reply. Well, time synchronization between some distant sites (8km) does not sound as a really easy task. Especiallyif your timing tolerances are in the nanosecond range. Using GPS time one has to be aware that the absolute accuracy of time&frequency receivers in very good case is something about 10-40ns. What I would suggest is to use for ex 10MHz comming from the GPS receiver as timig frequenc (if you can not get anything better). Use 1PPS as trigger to start both counters on both sites (in the fpga for example). It is easy if the sites are not too far apart, for ex one might use the following code:

`timescale 1ns/1ns

module triggeredenable(clk, rst, trigger, out);
    input clk;
    input rst;
    input trigger;
    output out;
    reg out;

    always @(posedge clk)
    begin
        if (rst)
            out <= 'h0;
        else
            out <= out || trigger;
    end
   
endmodule

so when first pps commes after reset it starts the counters via out for example. It is but important that same pps starts both counters on both sites. Then for example if you have 10MHz as input you have 100ns resolution and after 2500000 clock ticks you do measurement.

Something like that. Anyway, it might be so that you need 2 GPS receivers for each side one if they are too far, and you have to use some network synchronization program to get the same pps to start both counters after reset (anyway these PPS will also absolutely differ in few ns but hopefully it will fall into your measurements tolerance. But this difference further (hopefully) will be constant over time so you might also model it etc ets.... so hope this helps a bit if you need more info write so I can try to explain.

 

0 Kudos
Message 27 of 28
(1,702 Views)

Here is also code for the counter. You use the out from the module I gave you above to control the counter. here it is the count_en wire.

 

`timescale 1ns/1ns

module freerunning_gated(clk, rst, count_en, count);
    parameter NBITS = 32;
    input clk;
    input rst;
    input count_en;
    output[(NBITS-1):0] count;
   
    reg[(NBITS-1):0] count;
    reg rollover;
    always @(posedge clk)
    if (rst)
        count <= 'h0;
    else
        if (count_en) count <= count + 'h1;
        else count <= count;   //or 'h0 if it is low means reset or some other state you want
endmodule

 

next thing you can do is implement one module which monitors the count and on certain value starts the measurements you want. I do not know what kind of measurements you do and how. It does not matter anyway, so the therefore the code above is kind of general. also measurement can be done directly above in the code in the always@ block. Hopefully this helps

Kirco

 

0 Kudos
Message 28 of 28
(1,696 Views)