Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange behavior of FDwfDigitalOutDividerSet() #21

Open
micheledellaciana1 opened this issue Apr 14, 2020 · 3 comments
Open

Strange behavior of FDwfDigitalOutDividerSet() #21

micheledellaciana1 opened this issue Apr 14, 2020 · 3 comments

Comments

@micheledellaciana1
Copy link

Hi,
I'm not understanding how it works FDwfDigitalOutDividerSet(). From the C doc I saw that It sets the divider of the internal clock for the counter. Here it sets the frequency in Hz of the counter?
If it's so, it works properly only is you set as frequency the maximum frequency (i.e. 1e8 Hz). With lower frequency, It behaves differently.

For example, if you put the frequency of the counter to 10 kHz, and low and high counter to 5 and 5, I expect to see a square wave with a period of 1 ms, (0.1 * 5 + 0.1 *5 = 1), but I get a square wave of period 2ms.

    FDwfDigitalOutEnableSet(pin, true);
    FDwfDigitalOutDividerSet(pin, (int) 1e4); // Frequency of counter
    FDwfDigitalOutCounterInitSet(pin, true, 0);
    FDwfDigitalOutCounterSet(pin, 5, 5);
    FDwfDigitalOutConfigure(true);

By the way, If I set the counter frequency to the max, everything works fine, but the sum of the values of the counters cannot exide unsigned int maximum (I think because c function has that limitation).

am I missing something about FDwfDigitalOutDividerSet() ?

Thk in advance,

Michele

@timmolter
Copy link
Member

I'm not quite sure as I haven't used this is quite a long time now. Did you read the SDK docs page 69: https://reference.digilentinc.com/_media/waveforms_sdk_reference_manual.pdf?

Check out my Blink1 class here: https:/knowm/waveforms4j/blob/develop/src/test/java/org/knowm/waveforms4j/ad2/Blink1.java. You can see it's setting the frequency. BTW is my comment then false on line 53? Is it actually set to 5 Hz??

@timmolter
Copy link
Member

BTW, I never use FDwfDigitalOutCounterInitSet, so you might just try eliminating that line. Maybe it's messing something up.

@micheledellaciana1
Copy link
Author

Exactly, the blink has a frequency of 5 Hz, not 2!

FDwfDigitalOutCounterInitSet works properly...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants