11-13-2018 04:37 PM
I am really confused about the myRIO Analog Out (AO) sampling rate. If anyone has any insights into the following please let me know.
Here is what I did:
If I change the update rate from 250kSa to 125kSa, then I get the right frequency, 15.625Hz, although the peak is slightly distorted.
Does it take a certain amount of cycles to update the analog out? What am I missing?
Thanks for your help.
Regards,
mcduff
PS Below is the simple test case
11-13-2018 06:24 PM
Maybe this is an answer.
Took 100s of data, did an FFT to get an accurate frequency. I got 31.24915kHz, instead of 31.25kHz. This implies the 40 MHz clock is running at 39.9989 MHz, this is greater than 10ppm. Is that value typical? (do not see in on spec sheet)
Cheers,
mcduff
11-13-2018 07:09 PM
What if you used a timed while loop rather than a regular while loop with the delay timer in it?
11-13-2018 07:27 PM
@RavensFan wrote:
What if you used a timed while loop rather than a regular while loop with the delay timer in it?
Excuse my ignorance/stupidity, but you can use a timed loop in FPGA? I thought they we only for SCTL in FPGA. I'm at home now without LabVIEW, but I will try tomorrow. Thanks.
11-13-2018 09:24 PM
I know that I have.
11-13-2018 10:31 PM - edited 11-13-2018 10:33 PM
Writing the AO won't work in a timed loop, so the loop timer is the only option.
The 345kS/s rate is probably derived from the 40MHz clock using a method like this, and because there's no exact combination of multipliers and divisors it isn't an exact result. After running that VI the closest approximation is 345.0025k with a 0.000735% error, so I'm guessing that's what the DAC is actually running at. So this might account for the differences you're seeing.
11-14-2018 10:12 AM
@MichaelBalzer wrote:
Writing the AO won't work in a timed loop, so the loop timer is the only option.
You might be right, and I was mistaken. I did use a timed loop in my FPGA code, but it was just to maintain an onboard counter based off the 40 MHz clock. I don't know if it was effectively a single cycle timed loop or not. My other loops in the code, including the one outputting analog data, were regular while loops and used the blue "metronome" to do waits based on the 40 MHz base clock.
11-14-2018 11:29 AM
I think you're going to get some issues using the delay like that. Outputting to AO takes some finite amount of time, so with the sequence structure you'll be waiting 8 µs, then [AO write time], then looping. You're guaranteed to get something slower than your desired loop rate. It may not be significant (I don't know how many clock cycles it takes to perform an AO) but it may be worth looking into.
11-14-2018 12:01 PM - edited 11-14-2018 12:09 PM
@MichaelBalzer wrote:
Thanks for the link, quite honestly I am too stupid to know how to utilize it. I have tried creating derived clocks and the multiplier and divisor is fixed, I cannot change it.
Anyway, tried a bunch of different things, made a SCTL at 40MHz, that would generate an occurrence that I tried to use to trigger AO at a lower rate, but still my frequency was off.
I went back to my original thought, the 40MHz clock in the FPGA is off, that is, not really 40MHz. Luckily I have 2 additional myRIOs in a box to test. The first replacement gave the correct frequency with my original simple program. See below.
The peak is still not symmetric, but better than before.
If anyone from NI is reading this, what is your return policy?? Where are the clock specs for the FPGA?
Thanks for everybody's help and advice, I could have saved everybody's time and effort if I just tried a different myRIO earlier.
Cheers,
mcduff
EDIT: Just did a 10s FFT got 31.2498kHz instead of 31.250kHz, only off by 0.2Hz, instead of ~1Hz.
11-14-2018 07:20 PM
@BertMcMahan wrote:
I think you're going to get some issues using the delay like that. Outputting to AO takes some finite amount of time, so with the sequence structure you'll be waiting 8 µs, then [AO write time], then looping. You're guaranteed to get something slower than your desired loop rate. It may not be significant (I don't know how many clock cycles it takes to perform an AO) but it may be worth looking into.
Writing to the AO will take some time but the Loop Timer function should handle that, just so long as the entire loop execution takes no longer than 8µs. For example if the AO write takes 1µs the loop timer should only wait 7µs, keeping the loop running at the correct rate.