philippedc / Arduino-Uno-Wind-Turbine-MPPT-Regulator

How to build a wind turbine MPPT regulator with an Arduino Uno rev.3 and some other unsual components
GNU General Public License v3.0
32 stars 11 forks source link

Variable type to small to hold return value of millis() #3

Open HenniePeters opened 4 years ago

HenniePeters commented 4 years ago

Hi Philippe,

I have a question about the fet drivers. Did you select the tc428 with one inverting and one non inverting driver on purpose or was it just what you had in stock? Why not the TC427 with two non inverting drivers?

And a remark about your code:

The millis() function returns an unsigned long. You store that in an unsigned int. I expect that during testing you will never notice the problem because an overflow in millis occurs after 70 hours, but at some point your code will fail. I've changed all the "tempo" variables in my instance of the code to unsigned long. Also the variables that start with "somme".

philippedc commented 4 years ago

Hi Peter I well receive notifications now ;) Yes I had in stock TC428, that is why.... About millis. I'm not an expert in C.... What happens when you add +1 to an unsigned integer of FFFF (hex)? As I know it restarts from 0. I've chosen unsigned integer instead of unsigned long because it may be quicker.

HenniePeters commented 4 years ago

I see what you mean, it will be faster. I hope that it will work correctly during the overflow of the millis() function. I will test that when I can find some time.