{"id":235,"date":"2018-07-12T09:57:07","date_gmt":"2018-07-12T12:57:07","guid":{"rendered":"http:\/\/www.professores.uff.br\/lbertini\/?page_id=235"},"modified":"2018-07-12T09:57:07","modified_gmt":"2018-07-12T12:57:07","slug":"controlador-fuzzy-em-c","status":"publish","type":"page","link":"https:\/\/www.professores.uff.br\/lbertini\/controlador-fuzzy-em-c\/","title":{"rendered":"Controlador Fuzzy em C"},"content":{"rendered":"<p>O controlador apresentado abaixo foi testado no controle de velocidade de um motor BLDC de CDROM, no controle de velocidade. Foi comparado com um controlador PID implementado utilizando transformada Z e testado com diferentes par\u00e2metros de integra\u00e7\u00e3o. O resultado do controle e um caso de ativa\u00e7\u00e3o de regras podem ser vistos nas figuras anbaixo:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-237 size-full\" src=\"http:\/\/www.professores.uff.br\/lbertini\/wp-content\/uploads\/sites\/108\/2018\/07\/resposta-controle.png\" alt=\"\" width=\"1650\" height=\"375\" srcset=\"https:\/\/www.professores.uff.br\/lbertini\/wp-content\/uploads\/sites\/108\/2018\/07\/resposta-controle.png 1650w, https:\/\/www.professores.uff.br\/lbertini\/wp-content\/uploads\/sites\/108\/2018\/07\/resposta-controle-300x68.png 300w, https:\/\/www.professores.uff.br\/lbertini\/wp-content\/uploads\/sites\/108\/2018\/07\/resposta-controle-768x175.png 768w, https:\/\/www.professores.uff.br\/lbertini\/wp-content\/uploads\/sites\/108\/2018\/07\/resposta-controle-1024x233.png 1024w\" sizes=\"auto, (max-width: 1650px) 100vw, 1650px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-236 size-full\" src=\"http:\/\/www.professores.uff.br\/lbertini\/wp-content\/uploads\/sites\/108\/2018\/07\/fuzzy.png\" alt=\"\" width=\"1003\" height=\"372\" srcset=\"https:\/\/www.professores.uff.br\/lbertini\/wp-content\/uploads\/sites\/108\/2018\/07\/fuzzy.png 1003w, https:\/\/www.professores.uff.br\/lbertini\/wp-content\/uploads\/sites\/108\/2018\/07\/fuzzy-300x111.png 300w, https:\/\/www.professores.uff.br\/lbertini\/wp-content\/uploads\/sites\/108\/2018\/07\/fuzzy-768x285.png 768w\" sizes=\"auto, (max-width: 1003px) 100vw, 1003px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><strong>C\u00f3digo:<\/strong><\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff;overflow: auto;width: auto;border: solid gray;border-width: .1em .1em .1em .8em;padding: .2em .6em\">\n<pre style=\"margin: 0;line-height: 125%\"><span style=\"color: #888888\">\/*<\/span>\r\n<span style=\"color: #888888\">Codigo de um controlador Fuzzy com dois precedentes conectados pelo operador AND.<\/span>\r\n<span style=\"color: #888888\">SISTEMAS EMBARCADOS E COMPUTA\u00c7\u00c3O UB\u00cdQUA<\/span>\r\n<span style=\"color: #888888\">MESTRADO EM ENGENHARIA DE PRODU\u00c7\u00c3O E SISTEMAS COMPUTACIONAIS \u2013 MESC<\/span>\r\n<span style=\"color: #888888\">Luciano Bertini *\/<\/span>\r\n\r\n\r\n<span style=\"color: #557799\">#include &lt;stdio.h&gt;<\/span>\r\n\r\n<span style=\"color: #888888\">\/\/ Define a estrutura para um conjunto fuzzy triangular, sendo que a ou c podem ser +infinito ou -infinito (INF)<\/span>\r\n<span style=\"color: #008800;font-weight: bold\">struct<\/span> membership{\r\n    <span style=\"color: #333399;font-weight: bold\">float<\/span> a;\r\n    <span style=\"color: #333399;font-weight: bold\">float<\/span> b;\r\n    <span style=\"color: #333399;font-weight: bold\">float<\/span> c;\r\n};\r\n\r\n<span style=\"color: #888888\">\/\/Defini\u00e7\u00e3o de infinito<\/span>\r\n<span style=\"color: #557799\">#define INF 1e+6<\/span>\r\n\r\n<span style=\"color: #557799\">#define NUM1 5  <\/span><span style=\"color: #888888\">\/\/Numero de conjuntos na variavel de entrada 1<\/span>\r\n<span style=\"color: #557799\">#define NUM2 5  <\/span><span style=\"color: #888888\">\/\/Numero de conjuntos na variavel de entrada 2<\/span>\r\n<span style=\"color: #557799\">#define NUM3 5  <\/span><span style=\"color: #888888\">\/\/Numero de conjuntos na variavel de saida<\/span>\r\n\r\n<span style=\"color: #557799\">#define MIN(a,b) (((a)&lt;(b))?(a):(b))<\/span>\r\n<span style=\"color: #557799\">#define MAX(a,b) (((a)&gt;(b))?(a):(b))<\/span>\r\n\r\n<span style=\"color: #888888\">\/\/ Fun\u00e7\u00e3o membership de entrada. r[] \u00e9 o vetor de pertinencias que ser\u00e1 preenchido.<\/span>\r\n<span style=\"color: #888888\">\/\/ x \u00e9 o valor sendo fuzificado. z[] \u00e9 o vetor de conjuntos fuzzy em todo universo de discurso X<\/span>\r\n<span style=\"color: #888888\">\/\/ n \u00e9 o tamanho do vetor<\/span>\r\n<span style=\"color: #333399;font-weight: bold\">void<\/span> <span style=\"color: #0066bb;font-weight: bold\">test_membership_in<\/span>(<span style=\"color: #333399;font-weight: bold\">float<\/span> r[], <span style=\"color: #333399;font-weight: bold\">float<\/span> x, <span style=\"color: #008800;font-weight: bold\">struct<\/span> membership z[], <span style=\"color: #333399;font-weight: bold\">int<\/span> n)\r\n{\r\n    <span style=\"color: #333399;font-weight: bold\">int<\/span> i;\r\n    <span style=\"color: #008800;font-weight: bold\">for<\/span>(i<span style=\"color: #333333\">=<\/span><span style=\"color: #0000dd;font-weight: bold\">0<\/span>;i<span style=\"color: #333333\">&lt;<\/span>n;i<span style=\"color: #333333\">++<\/span>)\r\n    {\r\n         <span style=\"color: #008800;font-weight: bold\">if<\/span>(x<span style=\"color: #333333\">&lt;=<\/span>z[i].a<span style=\"color: #333333\">||<\/span>x<span style=\"color: #333333\">&gt;=<\/span>z[i].c)\r\n            r[i] <span style=\"color: #333333\">=<\/span> <span style=\"color: #6600ee;font-weight: bold\">0.0<\/span>;\r\n         <span style=\"color: #008800;font-weight: bold\">else<\/span> <span style=\"color: #008800;font-weight: bold\">if<\/span>(x<span style=\"color: #333333\">&gt;<\/span>z[i].a<span style=\"color: #333333\">&amp;&amp;<\/span>x<span style=\"color: #333333\">&lt;=<\/span>z[i].b)\r\n            r[i] <span style=\"color: #333333\">=<\/span> (x<span style=\"color: #333333\">-<\/span>z[i].a)<span style=\"color: #333333\">\/<\/span>(z[i].b<span style=\"color: #333333\">-<\/span>z[i].a);\r\n         <span style=\"color: #008800;font-weight: bold\">else<\/span> <span style=\"color: #008800;font-weight: bold\">if<\/span>(x<span style=\"color: #333333\">&gt;<\/span>z[i].b<span style=\"color: #333333\">&amp;&amp;<\/span>x<span style=\"color: #333333\">&lt;<\/span>z[i].c)\r\n            r[i] <span style=\"color: #333333\">=<\/span> (z[i].c<span style=\"color: #333333\">-<\/span>x)<span style=\"color: #333333\">\/<\/span>(z[i].c<span style=\"color: #333333\">-<\/span>z[i].b);\r\n    }\r\n}\r\n\r\n\r\n<span style=\"color: #888888\">\/\/ Obtem o valor da membership de saida ap\u00f3s a infer\u00eancia fuzzy. O vetor r[] \u00e9 entrada e cada valor \u00e9 <\/span>\r\n<span style=\"color: #888888\">\/\/ o n\u00edvel de ativa\u00e7\u00e3o de cada conjunto fuzzy, obtido na inferencia. Variando-se x em todo universo de discurso, <\/span>\r\n<span style=\"color: #888888\">\/\/ obtem-se a membership de saida<\/span>\r\n<span style=\"color: #333399;font-weight: bold\">float<\/span> <span style=\"color: #0066bb;font-weight: bold\">test_membership_out<\/span>(<span style=\"color: #333399;font-weight: bold\">float<\/span> r[],<span style=\"color: #333399;font-weight: bold\">float<\/span> x, <span style=\"color: #008800;font-weight: bold\">struct<\/span> membership z[], <span style=\"color: #333399;font-weight: bold\">int<\/span> n)\r\n{\r\n    <span style=\"color: #333399;font-weight: bold\">float<\/span> v, ret<span style=\"color: #333333\">=<\/span><span style=\"color: #6600ee;font-weight: bold\">0.0<\/span>;\r\n    <span style=\"color: #333399;font-weight: bold\">int<\/span> i;\r\n    <span style=\"color: #008800;font-weight: bold\">for<\/span>(i<span style=\"color: #333333\">=<\/span><span style=\"color: #0000dd;font-weight: bold\">0<\/span>;i<span style=\"color: #333333\">&lt;<\/span>n;i<span style=\"color: #333333\">++<\/span>)\r\n    {\r\n         <span style=\"color: #008800;font-weight: bold\">if<\/span>(x<span style=\"color: #333333\">&lt;=<\/span>z[i].a<span style=\"color: #333333\">||<\/span>x<span style=\"color: #333333\">&gt;=<\/span>z[i].c)\r\n            v <span style=\"color: #333333\">=<\/span> <span style=\"color: #6600ee;font-weight: bold\">0.0<\/span>;\r\n         <span style=\"color: #008800;font-weight: bold\">else<\/span> <span style=\"color: #008800;font-weight: bold\">if<\/span>(x<span style=\"color: #333333\">&gt;<\/span>z[i].a<span style=\"color: #333333\">&amp;&amp;<\/span>x<span style=\"color: #333333\">&lt;=<\/span>z[i].b)\r\n            v <span style=\"color: #333333\">=<\/span> MIN((x<span style=\"color: #333333\">-<\/span>z[i].a)<span style=\"color: #333333\">\/<\/span>(z[i].b<span style=\"color: #333333\">-<\/span>z[i].a),r[i]); <span style=\"color: #888888\">\/\/ seleciona o minimo entre o nivel de ativa\u00e7\u00e3o e o triangulo do conjunto fuzzy<\/span>\r\n         <span style=\"color: #008800;font-weight: bold\">else<\/span> <span style=\"color: #008800;font-weight: bold\">if<\/span>(x<span style=\"color: #333333\">&gt;<\/span>z[i].b<span style=\"color: #333333\">&amp;&amp;<\/span>x<span style=\"color: #333333\">&lt;<\/span>z[i].c)\r\n            v <span style=\"color: #333333\">=<\/span> MIN((z[i].c<span style=\"color: #333333\">-<\/span>x)<span style=\"color: #333333\">\/<\/span>(z[i].c<span style=\"color: #333333\">-<\/span>z[i].b),r[i]); <span style=\"color: #888888\">\/\/ seleciona o minimo entre o nivel de ativa\u00e7\u00e3o e o triangulo do conjunto fuzzy<\/span>\r\n         ret<span style=\"color: #333333\">=<\/span>MAX(ret,v); <span style=\"color: #888888\">\/\/ O maximo aqui faz o OU entre dois conjuntos fuzzy i-1 e i<\/span>\r\n    }\r\n    <span style=\"color: #008800;font-weight: bold\">return<\/span> ret;\r\n}\r\nmain()\r\n{\r\n    <span style=\"color: #333399;font-weight: bold\">int<\/span> i,j;\r\n    <span style=\"color: #333399;font-weight: bold\">float<\/span> de<span style=\"color: #333333\">=<\/span><span style=\"color: #6600ee;font-weight: bold\">1.7<\/span>, e<span style=\"color: #333333\">=-<\/span><span style=\"color: #6600ee;font-weight: bold\">1.4<\/span>;\r\n    <span style=\"color: #333399;font-weight: bold\">float<\/span> x,sum1<span style=\"color: #333333\">=<\/span><span style=\"color: #6600ee;font-weight: bold\">0.0<\/span>,sum2<span style=\"color: #333333\">=<\/span><span style=\"color: #6600ee;font-weight: bold\">0.0<\/span>, val, v;\r\n    <span style=\"color: #333399;font-weight: bold\">float<\/span> mi1[NUM1],mi2[NUM2],out[NUM3]<span style=\"color: #333333\">=<\/span>{<span style=\"color: #0000dd;font-weight: bold\">0<\/span>,<span style=\"color: #0000dd;font-weight: bold\">0<\/span>,<span style=\"color: #0000dd;font-weight: bold\">0<\/span>,<span style=\"color: #0000dd;font-weight: bold\">0<\/span>,<span style=\"color: #0000dd;font-weight: bold\">0<\/span>};\r\n\r\n   <span style=\"color: #888888\">\/\/ Defini\u00e7\u00e3o dos conjuntos fuzzy<\/span>\r\n   <span style=\"color: #008800;font-weight: bold\">struct<\/span> membership e1[NUM1]<span style=\"color: #333333\">=<\/span>{\r\n        { <span style=\"color: #333333\">-<\/span>INF, <span style=\"color: #333333\">-<\/span><span style=\"color: #6600ee;font-weight: bold\">8.0<\/span>, <span style=\"color: #333333\">-<\/span><span style=\"color: #6600ee;font-weight: bold\">4.0<\/span>},\r\n        { <span style=\"color: #333333\">-<\/span><span style=\"color: #6600ee;font-weight: bold\">5.0<\/span>, <span style=\"color: #333333\">-<\/span><span style=\"color: #6600ee;font-weight: bold\">3.0<\/span>, <span style=\"color: #333333\">-<\/span><span style=\"color: #6600ee;font-weight: bold\">1.0<\/span>},\r\n        { <span style=\"color: #333333\">-<\/span><span style=\"color: #6600ee;font-weight: bold\">2.0<\/span>,  <span style=\"color: #6600ee;font-weight: bold\">0.0<\/span>,  <span style=\"color: #6600ee;font-weight: bold\">2.0<\/span>},\r\n        {  <span style=\"color: #6600ee;font-weight: bold\">1.0<\/span>,  <span style=\"color: #6600ee;font-weight: bold\">3.0<\/span>,  <span style=\"color: #6600ee;font-weight: bold\">5.0<\/span>},\r\n        {  <span style=\"color: #6600ee;font-weight: bold\">4.0<\/span>,  <span style=\"color: #6600ee;font-weight: bold\">8.0<\/span>,  INF}};\r\n\r\n    <span style=\"color: #008800;font-weight: bold\">struct<\/span> membership e2[NUM2]<span style=\"color: #333333\">=<\/span>{\r\n        { <span style=\"color: #333333\">-<\/span>INF, <span style=\"color: #333333\">-<\/span><span style=\"color: #6600ee;font-weight: bold\">8.0<\/span>, <span style=\"color: #333333\">-<\/span><span style=\"color: #6600ee;font-weight: bold\">4.0<\/span>},\r\n        { <span style=\"color: #333333\">-<\/span><span style=\"color: #6600ee;font-weight: bold\">5.0<\/span>, <span style=\"color: #333333\">-<\/span><span style=\"color: #6600ee;font-weight: bold\">3.0<\/span>, <span style=\"color: #333333\">-<\/span><span style=\"color: #6600ee;font-weight: bold\">1.0<\/span>},\r\n        { <span style=\"color: #333333\">-<\/span><span style=\"color: #6600ee;font-weight: bold\">2.0<\/span>,  <span style=\"color: #6600ee;font-weight: bold\">0.0<\/span>,  <span style=\"color: #6600ee;font-weight: bold\">2.0<\/span>},\r\n        {  <span style=\"color: #6600ee;font-weight: bold\">1.0<\/span>,  <span style=\"color: #6600ee;font-weight: bold\">3.0<\/span>,  <span style=\"color: #6600ee;font-weight: bold\">5.0<\/span>},\r\n        {  <span style=\"color: #6600ee;font-weight: bold\">4.0<\/span>,  <span style=\"color: #6600ee;font-weight: bold\">8.0<\/span>,  INF}};\r\n\r\n    <span style=\"color: #008800;font-weight: bold\">struct<\/span> membership s[NUM3]<span style=\"color: #333333\">=<\/span>{\r\n        {<span style=\"color: #333333\">-<\/span><span style=\"color: #6600ee;font-weight: bold\">20.0<\/span>, <span style=\"color: #333333\">-<\/span><span style=\"color: #6600ee;font-weight: bold\">10.0<\/span>, <span style=\"color: #333333\">-<\/span><span style=\"color: #6600ee;font-weight: bold\">6.0<\/span>},\r\n        { <span style=\"color: #333333\">-<\/span><span style=\"color: #6600ee;font-weight: bold\">7.0<\/span>,  <span style=\"color: #333333\">-<\/span><span style=\"color: #6600ee;font-weight: bold\">4.0<\/span>, <span style=\"color: #333333\">-<\/span><span style=\"color: #6600ee;font-weight: bold\">1.0<\/span>},\r\n        { <span style=\"color: #333333\">-<\/span><span style=\"color: #6600ee;font-weight: bold\">2.0<\/span>,   <span style=\"color: #6600ee;font-weight: bold\">0.0<\/span>,  <span style=\"color: #6600ee;font-weight: bold\">2.0<\/span>},\r\n        {  <span style=\"color: #6600ee;font-weight: bold\">1.0<\/span>,   <span style=\"color: #6600ee;font-weight: bold\">4.0<\/span>,  <span style=\"color: #6600ee;font-weight: bold\">7.0<\/span>},\r\n        {  <span style=\"color: #6600ee;font-weight: bold\">6.0<\/span>,  <span style=\"color: #6600ee;font-weight: bold\">10.0<\/span>, <span style=\"color: #6600ee;font-weight: bold\">20.0<\/span>}};\r\n\r\n\r\n    <span style=\"color: #888888\">\/\/ Mapa de regras<\/span>\r\n    <span style=\"color: #333399;font-weight: bold\">int<\/span> regras[NUM1][NUM2]<span style=\"color: #333333\">=<\/span>{ <span style=\"color: #888888\">\/\/horizontal Delta do erro<\/span>\r\n        {<span style=\"color: #0000dd;font-weight: bold\">4<\/span>,<span style=\"color: #0000dd;font-weight: bold\">4<\/span>,<span style=\"color: #0000dd;font-weight: bold\">3<\/span>,<span style=\"color: #0000dd;font-weight: bold\">3<\/span>,<span style=\"color: #0000dd;font-weight: bold\">2<\/span>},         <span style=\"color: #888888\">\/\/vertical erro<\/span>\r\n        {<span style=\"color: #0000dd;font-weight: bold\">4<\/span>,<span style=\"color: #0000dd;font-weight: bold\">3<\/span>,<span style=\"color: #0000dd;font-weight: bold\">3<\/span>,<span style=\"color: #0000dd;font-weight: bold\">2<\/span>,<span style=\"color: #0000dd;font-weight: bold\">1<\/span>},\r\n        {<span style=\"color: #0000dd;font-weight: bold\">3<\/span>,<span style=\"color: #0000dd;font-weight: bold\">3<\/span>,<span style=\"color: #0000dd;font-weight: bold\">2<\/span>,<span style=\"color: #0000dd;font-weight: bold\">1<\/span>,<span style=\"color: #0000dd;font-weight: bold\">1<\/span>},\r\n        {<span style=\"color: #0000dd;font-weight: bold\">3<\/span>,<span style=\"color: #0000dd;font-weight: bold\">2<\/span>,<span style=\"color: #0000dd;font-weight: bold\">1<\/span>,<span style=\"color: #0000dd;font-weight: bold\">1<\/span>,<span style=\"color: #0000dd;font-weight: bold\">0<\/span>},\r\n        {<span style=\"color: #0000dd;font-weight: bold\">2<\/span>,<span style=\"color: #0000dd;font-weight: bold\">1<\/span>,<span style=\"color: #0000dd;font-weight: bold\">1<\/span>,<span style=\"color: #0000dd;font-weight: bold\">0<\/span>,<span style=\"color: #0000dd;font-weight: bold\">0<\/span>}};\r\n\r\n    <span style=\"color: #888888\">\/\/ Inicializa\u00e7\u00e3o<\/span>\r\n    sum1<span style=\"color: #333333\">=<\/span><span style=\"color: #0000dd;font-weight: bold\">0<\/span>;\r\n    sum2<span style=\"color: #333333\">=<\/span><span style=\"color: #0000dd;font-weight: bold\">0<\/span>;\r\n    <span style=\"color: #008800;font-weight: bold\">for<\/span>(i<span style=\"color: #333333\">=<\/span><span style=\"color: #0000dd;font-weight: bold\">0<\/span>;i<span style=\"color: #333333\">&lt;<\/span>NUM3;i<span style=\"color: #333333\">++<\/span>)out[i]<span style=\"color: #333333\">=<\/span><span style=\"color: #0000dd;font-weight: bold\">0<\/span>;\r\n\r\n    <span style=\"color: #888888\">\/\/ Fuzifica\u00e7\u00e3o<\/span>\r\n    test_membership_in(mi1,e,e1,NUM1);\r\n    test_membership_in(mi2,de,e2,NUM2);\r\n\r\n    <span style=\"color: #888888\">\/\/ Inferencia Fuzzy<\/span>\r\n    <span style=\"color: #888888\">\/\/ O minimo aqui pega o menor dos graus de pertinencias, supondo regras com dois precedentes conectados pelo operador AND<\/span>\r\n    <span style=\"color: #888888\">\/\/ O m\u00e1ximo aqui \u00e9 util quando um certo conjunto fuzzy de sa\u00edda j\u00e1 foi ativado antes por outra regra e neste caso deve-se selecionar o maior (OR).<\/span>\r\n    <span style=\"color: #008800;font-weight: bold\">for<\/span>(i<span style=\"color: #333333\">=<\/span><span style=\"color: #0000dd;font-weight: bold\">0<\/span>;i<span style=\"color: #333333\">&lt;<\/span>NUM1;i<span style=\"color: #333333\">++<\/span>)\r\n        <span style=\"color: #008800;font-weight: bold\">for<\/span>(j<span style=\"color: #333333\">=<\/span><span style=\"color: #0000dd;font-weight: bold\">0<\/span>;j<span style=\"color: #333333\">&lt;<\/span>NUM2;j<span style=\"color: #333333\">++<\/span>)\r\n            <span style=\"color: #008800;font-weight: bold\">if<\/span>(mi1[i]<span style=\"color: #333333\">&gt;<\/span><span style=\"color: #0000dd;font-weight: bold\">0<\/span><span style=\"color: #333333\">&amp;&amp;<\/span>mi2[j]<span style=\"color: #333333\">&gt;<\/span><span style=\"color: #0000dd;font-weight: bold\">0<\/span>)\r\n                out[regras[i][j]] <span style=\"color: #333333\">=<\/span> MAX(MIN(mi1[i],mi2[j]), out[regras[i][j]]); \r\n\r\n    <span style=\"color: #888888\">\/\/ Defuzifica\u00e7\u00e3o<\/span>\r\n    <span style=\"color: #888888\">\/\/ Calculo do centroide<\/span>\r\n    <span style=\"color: #008800;font-weight: bold\">for<\/span>(x<span style=\"color: #333333\">=-<\/span><span style=\"color: #6600ee;font-weight: bold\">10.0<\/span>;x<span style=\"color: #333333\">&lt;=<\/span><span style=\"color: #6600ee;font-weight: bold\">10.01<\/span>;x<span style=\"color: #333333\">+=<\/span><span style=\"color: #6600ee;font-weight: bold\">0.05<\/span>)\r\n    {\r\n        val<span style=\"color: #333333\">=<\/span>test_membership_out(out, x, s, NUM3);\r\n        sum1<span style=\"color: #333333\">+=<\/span>x<span style=\"color: #333333\">*<\/span>val;\r\n        sum2<span style=\"color: #333333\">+=<\/span>val;\r\n    }\r\n    x<span style=\"color: #333333\">=<\/span>sum1<span style=\"color: #333333\">\/<\/span>sum2;\r\n    printf(<span style=\"background-color: #fff0f0\">\"saida=%f<\/span><span style=\"color: #666666;font-weight: bold;background-color: #fff0f0\">\\n<\/span><span style=\"background-color: #fff0f0\">\"<\/span>,x);\r\n}\r\n<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>O controlador apresentado abaixo foi testado no controle de velocidade de um motor BLDC de CDROM, no controle de velocidade. Foi comparado com um controlador PID implementado utilizando transformada Z e testado com diferentes par\u00e2metros de integra\u00e7\u00e3o. O resultado do controle e um caso de ativa\u00e7\u00e3o de regras podem ser vistos nas figuras anbaixo: &nbsp; [&hellip;]<\/p>\n","protected":false},"author":168,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[],"tags":[],"class_list":["post-235","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.professores.uff.br\/lbertini\/wp-json\/wp\/v2\/pages\/235","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.professores.uff.br\/lbertini\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.professores.uff.br\/lbertini\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.professores.uff.br\/lbertini\/wp-json\/wp\/v2\/users\/168"}],"replies":[{"embeddable":true,"href":"https:\/\/www.professores.uff.br\/lbertini\/wp-json\/wp\/v2\/comments?post=235"}],"version-history":[{"count":1,"href":"https:\/\/www.professores.uff.br\/lbertini\/wp-json\/wp\/v2\/pages\/235\/revisions"}],"predecessor-version":[{"id":238,"href":"https:\/\/www.professores.uff.br\/lbertini\/wp-json\/wp\/v2\/pages\/235\/revisions\/238"}],"wp:attachment":[{"href":"https:\/\/www.professores.uff.br\/lbertini\/wp-json\/wp\/v2\/media?parent=235"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.professores.uff.br\/lbertini\/wp-json\/wp\/v2\/categories?post=235"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.professores.uff.br\/lbertini\/wp-json\/wp\/v2\/tags?post=235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}