Stephanie Liu
/
APS_ME_STEPHANIE_1
aps de maquinas eletricas stephanie liu
Revision 0:4e66272535f2, committed 2021-09-14
- Comitter:
- stephanie_liu
- Date:
- Tue Sep 14 02:00:01 2021 +0000
- Commit message:
- aps 1 - stephanie liu;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Sep 14 02:00:01 2021 +0000 @@ -0,0 +1,42 @@ +#include "mbed.h" +//configuração de portas +AnalogIn POT(A5); +PwmOut ENA(D2); +DigitalOut IN1A(D5); +DigitalOut IN2A(D4); +InterruptIn ENCONDER(D3); + +Timer tempo; +int pulsos =0; +const int HIGH = 1; +const int LOW = 0; +const int fonte = 12; + +//abertura de porta serial com a conexão USB +Serial pc(USBTX, USBRX); + + +void Contador_BD(){pulsos++;} + +void Motor_A(float duty_cyle){ + IN1A = LOW; + IN2A = HIGH; + ENA.write(duty_cyle); +} + +int main(){ + pc.baud(9600); + tempo.start(); + ENCONDER.fall(&Contador_BD); + while(true){ + float velocidade = POT.read(); + Motor_A(velocidade); + if(tempo.read_ms() >= 1000){ + pc.printf("TENSAO ARMADURA: %f\n\r", fonte*velocidade); + pc.printf("RPM: %d\n\r",pulsos*2); + pulsos=0; + tempo.reset(); + } + + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Sep 14 02:00:01 2021 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file