Matlab fuzzy regulator to arduino

Hello everybody,

I have a small question. For my bachelor project, I would like to use a fuzzy regulator for my Arduino Uno R3. The question is, based on what I know so far, can Simulink code be converted to C code? Can I use this code in my Arduino as a library when I need the regulator? (It's for a small water pump to control its voltage.) Has anyone tried this, and does it work?

can't imagine any algorithm written in any language that can't be translated to C. i believe many interpreted languages are in fact written in C/C++. don't know if there is a Simulink to C interpreter.

can you just rewrite your code in C?

From what I have search on the internet, inclusive the matlab documentation, there is a tool that convert you’re simulink or matlab file to an C/C++ code, but yeah, I also have think about to discuse with my profesor to find a solution to write the little fuzzy regulator directly in C by me

doesn't fuzzy logic make a decision based on product of multiple weighted values?

instead to turning something on/off if
temperature > threshold,
it might be
Kt * temperature * Kh*humidity > threshold

Yes, that how it’s work, and I have this ideea in my mind but I have said to ask a question about the matlab code convert in C to the forum

Hi, you can try use this library (can be downloaded from the library manager):

in addition, you can export the fuzzy system from MATLAB to a FIS file, and use the C++ code generator from here

hope this can be useful for you
best,

There is a WHOLE matlab help section on this topic! :open_mouth:

hope that helps....