Strange behavior of FDwfDigitalOutDividerSet()
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
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://github.com/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??
BTW, I never use FDwfDigitalOutCounterInitSet, so you might just try eliminating that line. Maybe it's messing something up.
Exactly, the blink has a frequency of 5 Hz, not 2!
FDwfDigitalOutCounterInitSet works properly...