José Antônio Bechara
/
APS1-Maquinas_e_Acionamentos
APS 1
Revision 0:d08ae309693f, committed 2021-09-13
- Comitter:
- zezo
- Date:
- Mon Sep 13 22:08:15 2021 +0000
- Commit message:
- oi;
Changed in this revision
diff -r 000000000000 -r d08ae309693f .gitignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.gitignore Mon Sep 13 22:08:15 2021 +0000 @@ -0,0 +1,4 @@ +.build +.mbed +projectfiles +*.py*
diff -r 000000000000 -r d08ae309693f main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Sep 13 22:08:15 2021 +0000 @@ -0,0 +1,49 @@ +#include "mbed.h" + +PwmOut EN_A(D2); +DigitalOut IN1A(D5); +DigitalOut IN2A(D4); +AnalogIn pot(A5); + +InterruptIn Encoder_interrupt(D3); + +float DC; +float Va; + +int up; +float w; + +Timer t; + +void contador() +{ + up++; +} + +int main() +{ + while(1) { + DC = pot.read(); + EN_A.write(DC); + IN1A = 1; + IN2A = 0; + Va = 12*DC; + + t.start(); + Encoder_interrupt.rise(&contador); + Encoder_interrupt.fall(&contador); + + if(t.read()>=0.5 ) { + w = up/t.read(); + printf("W = %1.2f rpm\n\r",w); + printf("DC = %1.2f\n\r",DC,"V\n\r"); + printf("Va = %1.2f V\n\r",Va); + printf("\n\r"); + up =0; + t.reset(); + } + + wait(0.001); + } +} +
diff -r 000000000000 -r d08ae309693f mbed-os.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Mon Sep 13 22:08:15 2021 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#cf4f12a123c05fcae83fc56d76442015cb8a39e9