
Originally Posted by
cncmachineguy
Couple questions:
when freq = 10, var = 112000 so:
reload = -46457
This is ok?
Next question:
Assuming freq comes from A/D, seems like there should be a way to "scale" the A/D to get your reload value. What is the reload span? for instance,
freq = 10, reload = ??
freq = 1200, reload = ??
are the answers -46457 and 64609?
In reality, the reload var shouldn't go below 0. So, for me, -46457 equals 0.
But 64609 is correct.
My min. frequency is 1Hz (freq=10), reload value=about 0
and my max. frequency is 120Hz (freq=1200), reload value=about 64600
And I don't directly use the 0-1023 potentiometer value, first I convert it to the "freq" variable :
Code:
potsense=(potsense<<6)**maxfreq
"maxfreq" correspond to the maximum frequency defined by the user. Here, "maxfreq"=1200. So here "freq" variable varies between 0 and 1200. Note I'm using an additional number to have the 0.1Hz accuracy (for exemple, 50.2Hz frequency equals freq=502).
I will try longs. But I only need one long.
Bookmarks