Romain Ame
/
Stressed
coucou
Fork of Robot2016_2-0 by
ControlleurPince/ControlleurPince.cpp@58:02dc8328975a, 2016-05-04 (annotated)
- Committer:
- Jagang
- Date:
- Wed May 04 19:55:03 2016 +0000
- Revision:
- 58:02dc8328975a
- Child:
- 71:5590dbe8393a
Adding ControlleurPince
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Jagang | 58:02dc8328975a | 1 | |
Jagang | 58:02dc8328975a | 2 | #include "defines.h" |
Jagang | 58:02dc8328975a | 3 | #include "ControlleurPince.h" |
Jagang | 58:02dc8328975a | 4 | |
Jagang | 58:02dc8328975a | 5 | ControlleurPince::ControlleurPince(Stepper &p_RMot, Stepper &p_ZMot, Stepper &p_LMot, DigitalIn &p_EnR, DigitalIn &p_EnZ, DigitalIn &p_EnL): |
Jagang | 58:02dc8328975a | 6 | RMot(p_RMot), ZMot(p_ZMot), LMot(p_LMot), EnR(p_EnR), EnZ(p_EnZ), EnL(p_EnL) |
Jagang | 58:02dc8328975a | 7 | { |
Jagang | 58:02dc8328975a | 8 | pos_r = 0; |
Jagang | 58:02dc8328975a | 9 | pos_z = 0; |
Jagang | 58:02dc8328975a | 10 | pos_l = 0; |
Jagang | 58:02dc8328975a | 11 | } |
Jagang | 58:02dc8328975a | 12 | |
Jagang | 58:02dc8328975a | 13 | |
Jagang | 58:02dc8328975a | 14 | void ControlleurPince::home(bool r, bool z, bool l) |
Jagang | 58:02dc8328975a | 15 | { |
Jagang | 58:02dc8328975a | 16 | if(r) |
Jagang | 58:02dc8328975a | 17 | { |
Jagang | 58:02dc8328975a | 18 | while(EnR==true) RMot.step(1, BAS, DELAY); |
Jagang | 58:02dc8328975a | 19 | pos_r = 0; |
Jagang | 58:02dc8328975a | 20 | } |
Jagang | 58:02dc8328975a | 21 | if(z) |
Jagang | 58:02dc8328975a | 22 | { |
Jagang | 58:02dc8328975a | 23 | while(EnZ==true) ZMot.step(1, BAS, DELAY); |
Jagang | 58:02dc8328975a | 24 | pos_z = 0; |
Jagang | 58:02dc8328975a | 25 | } |
Jagang | 58:02dc8328975a | 26 | if(l) |
Jagang | 58:02dc8328975a | 27 | { |
Jagang | 58:02dc8328975a | 28 | while(EnL==true) LMot.step(1, BAS, DELAY); |
Jagang | 58:02dc8328975a | 29 | pos_l = 0; |
Jagang | 58:02dc8328975a | 30 | } |
Jagang | 58:02dc8328975a | 31 | } |
Jagang | 58:02dc8328975a | 32 | |
Jagang | 58:02dc8328975a | 33 | void ControlleurPince::setPos(float z, float delta, float center) |
Jagang | 58:02dc8328975a | 34 | { |
Jagang | 58:02dc8328975a | 35 | if(z > 0.f && z < 100.f) |
Jagang | 58:02dc8328975a | 36 | { |
Jagang | 58:02dc8328975a | 37 | logger.printf("Move by %f \n\r",z-pos_z); |
Jagang | 58:02dc8328975a | 38 | ZMot.mm(z-pos_z); |
Jagang | 58:02dc8328975a | 39 | |
Jagang | 58:02dc8328975a | 40 | pos_z = z; |
Jagang | 58:02dc8328975a | 41 | } |
Jagang | 58:02dc8328975a | 42 | } |