Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed Servo filter
Revision 2:0d6718386397, committed 2019-12-03
- Comitter:
- helderoshiro
- Date:
- Tue Dec 03 02:05:28 2019 +0000
- Parent:
- 1:3d924dfe29d6
- Commit message:
- projeto com media;
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Nov 27 18:13:30 2019 +0000
+++ b/main.cpp Tue Dec 03 02:05:28 2019 +0000
@@ -59,7 +59,7 @@
}
int main() {
- float janela[4] = {0, 0, 0, 0};
+ float janela;//[4] = {0, 0, 0, 0};
float angulo_degree = 0;
float angulo_media;
float P = 0.002; //v4 3*0.001;//3*0.00001;
@@ -102,6 +102,7 @@
{
loopFlag = 0;
int k = 0;
+ janela = 0;
while (k < 4){
angle = encoder.read_u16()>>4; //Tensão em 12 bits
/******
@@ -110,11 +111,11 @@
************/
angulo_V = 0.000806*angle;
angulo_degree = 27.779*angulo_V - 41.1;
- janela[k] = angulo_degree;
+ janela = janela + angulo_degree;
k++;
}
- angulo_media = (janela[0]+janela[1]+janela[2]+janela[3])/4;
+ angulo_media = janela/k; //(janela[0]+janela[1]+janela[2]+janela[3])/4;
e_anterior = e_atual;
e_atual = -(angulo_media - ref);
CP = P * e_atual;