voglio anche acquisire dall' encoder
Dependencies: mbed
Revision 1:266fc31c687d, committed 2016-04-30
- Comitter:
- capriele
- Date:
- Sat Apr 30 13:37:03 2016 +0000
- Parent:
- 0:e0090efd109d
- Commit message:
- Conto impulsi
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sat Apr 30 13:27:08 2016 +0000 +++ b/main.cpp Sat Apr 30 13:37:03 2016 +0000 @@ -3,24 +3,26 @@ PwmOut motor1(PWM_OUT); //Serial encoder(D0,D1); //DigitalIn encoder(D0); - +int impulsi = 0; +int numero_tick = 64;//numero di tacche nell encoder Timer period; InterruptIn encoder(D0); // serve per avviare il timer che conterà il tempo -float stopandreset() +void stopandreset() { - float T = period.read_ms(); - period.stop(); - period.reset(); - return T; + impulsi++; + //float T = period.read_ms(); + //period.stop(); + //period.reset(); + //return T; } int main() { - encoder.rise(&period.start); - float T = encoder.fall(&stopandreset); + encoder.rise(&stopandreset); + //float T = encoder.fall(&stopandreset); motor1.period_ms(10); float val = 0.6; @@ -28,8 +30,8 @@ while(true) { - - int v = encoder.read(); + float gradi = ((float)impulsi) / ((float)numero_tick) * 360.0f; + //int v = encoder.read();