Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

measuring pulse width using labview fpga

Hello All,

 

apologies for the double posting, I'm trying to measure the width of a digital input pulse (0 - 3.3V) and have run into problems, I'm using the PWM decoder here in figure 3 (http://www.ni.com/white-paper/5963/en)

 

however I'm finding that my pulse measurements are 'jumping' from one value to an other even when driven with a constant function gen output, I can accept a bit of drift, but the value jumps by tens (or hundreds) of ticks, and as I slowly ramp the frequency up, it tends to 'stick' at a value then jump to the next one

 

I'm using an NI-9403 card and a NI-9113 chassis, currently running in 'scan' mode (I think) without a RT layer (I've not done any RT training so I'd be poking in the dark somewhat)

 

I can't get it to work with a SCTL so I'm using a loop timer of 4 ticks.... can anyone offer any suggestions?

0 Kudos
Message 1 of 5
(6,616 Views)

Hi,

 

I think you will want to have the target in FPGA mode to use the code provided, scan mode can only sample at 1kHz, so I imagine it may not pick up your PWM correctly. I'm not sure how you are managing without an RT layer, you need to program something on the cRIO even if you see the front panel on the host.

 

Here are some useful things to get you a bit more understanding of how the cRIO works, it may be worth scanning through that to see if some of it will help you.

 

Don't be scared of programming the RT layer! The programming is the same, there's just a few new concepts for those who need the deterministic functionality, but it sounds like you just want to read back the PWM for now. The VI libary you found is useful for solving this task, so you're well on the way.

Ian S
Applications Engineer CLA
National Instruments UK&Ireland
0 Kudos
Message 2 of 5
(6,589 Views)

so if I've understood this correctly, what I essentially need to do is transplant my PC/front panel code to a RT vi, then output the RT data to shared variable FIFOs which can be opened and read and saved to a file by the PC?

 

Currently I'm opening the FPGA reference in my PC vi, doing some maths on the numbers, then saving those to a file.

 

I can take the 'open the FPGA reference and do some maths on the numbers' section and add it to a RT vi (with a little fiddling, I understand it's not cut-and-paste!), then extract the numbers from THAT to my PC vi where I can log them to a file and see nice numbers displayed onscreen?

0 Kudos
Message 3 of 5
(6,554 Views)

I have added an RT layer and am transferring the counts via FIFO to my RT layer, I am still encountering the issue of the pulse measurement 'sticking' then jumping.... can anyone please advise? I can share my code if required

0 Kudos
Message 4 of 5
(6,445 Views)

Your "PC vi" is usually referred to as Host vi and yes, you seem to have setup the FPGA and the Host. By opening the Host vi, the FPGA should be called through your program through your FPGA reference in the Host vi. You can then indeed trabsfer the data acquired to a file from the Host vi.

 

 

0 Kudos
Message 5 of 5
(6,381 Views)