Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

Designing self triggered counter in FPGA

Hi

 

I have an Rseries 7841R I am trasfering code to (from DAQmx). I am having particular difficulty in getting an internally triggered counter output to behave. Please see attached VI where I made a tickcount loop based on internal 40MHz counter. The frequency of the timer I am aiming for is 10Hz ond/or 60 Hz. So I changed the period and upstate values respectively.

 

It tourns out that the counter has errors, I have added a plot to show the actual output and also an LED. The Period varies by quite a bit (irregular pulses) and my rise is kind of triangular. Someone please help if you can either:

tell me of a simpler way to go about making a counter that is at a period, wherein the up and down states occupy the same time,

or help in identifying where i screwed up on my block diagram. I didn;t really comple onto FPGA, I have been simulating on development computer.

 

Anything will help, Counters are owning me!

Thanks ArifH

0 Kudos
Message 1 of 2
(4,023 Views)

Hello ArifH,

 

There are two issues with your VI:

 

1. Your Time VIs are set to use milliseconds as opposed to microseconds.

2. The "triangles" you are seeing is due to the default interpolation mode of the waveform chart. If you right click the plot legend (the small image on the top-right corner of your chart) and choose one that's more appropriate for a digital waveform.

 

There is also a timing consideration which is that when you run the FPGA VI in simulation, the timing is not accurate. The loop will actually run as fast as possible with no timing. Your waveform, however, should still look approximately correct, but the actual up and down time will not always be exact. There are a couple of ways to address this. One way is to make your counter a sub VI and stick into a while loop or timed loop in a desktop VI that serves as a "testbench" where you control the timing. You can then capture the output of the subVI and check it against your expected results to see if it matches. 

 

As for examples, it appears to me that you want to generate a pulse train at a particular frequency with a 50% duty cycle (i.e. rise time and low time are equal). Check out this page that has a PWM output VI: http://zone.ni.com/devzone/cda/tut/p/id/5963

 

Since you will have a constant duty cycle, you can remove some of the unnecessary code.

 

Gerardo

0 Kudos
Message 2 of 2
(4,016 Views)