![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
10/25/2015
Dependencies: PID mbed MaxSonar eeprom iSerial Fork_Boss_Communication_Robot
move.cpp@12:8a06a803e373, 2016-03-03 (annotated)
- Committer:
- palmdotax
- Date:
- Thu Mar 03 09:07:22 2016 +0000
- Revision:
- 12:8a06a803e373
- Parent:
- 11:9df7ada37d31
LOL
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
palmdotax | 0:f02641e3fb91 | 1 | #include "mbed.h" |
palmdotax | 0:f02641e3fb91 | 2 | #include "move.h" |
palmdotax | 0:f02641e3fb91 | 3 | |
palmdotax | 0:f02641e3fb91 | 4 | |
palmdotax | 0:f02641e3fb91 | 5 | |
palmdotax | 11:9df7ada37d31 | 6 | DigitalOut dir1(PC_10); |
palmdotax | 11:9df7ada37d31 | 7 | DigitalOut dir2(PC_12); |
palmdotax | 9:86701fec3f79 | 8 | PwmOut speeds(PA_5); |
palmdotax | 9:86701fec3f79 | 9 | DigitalOut dirr1(PB_6); |
palmdotax | 9:86701fec3f79 | 10 | DigitalOut dirr2(PC_7); |
palmdotax | 9:86701fec3f79 | 11 | PwmOut speeds2(PA_7); |
palmdotax | 9:86701fec3f79 | 12 | DigitalOut relays(PA_8); |
palmdotax | 8:8fbc0c858875 | 13 | void move:: movespeed_1(int dir,float setpoint,float spd) |
palmdotax | 0:f02641e3fb91 | 14 | { |
palmdotax | 6:9ed82a812ece | 15 | double dc=0; |
palmdotax | 0:f02641e3fb91 | 16 | if(dir==1) |
palmdotax | 0:f02641e3fb91 | 17 | { |
palmdotax | 0:f02641e3fb91 | 18 | dir1=1; |
palmdotax | 0:f02641e3fb91 | 19 | dir2=0; |
palmdotax | 0:f02641e3fb91 | 20 | } |
palmdotax | 0:f02641e3fb91 | 21 | else |
palmdotax | 0:f02641e3fb91 | 22 | { |
palmdotax | 0:f02641e3fb91 | 23 | dir1=0; |
palmdotax | 0:f02641e3fb91 | 24 | dir2=1; |
palmdotax | 0:f02641e3fb91 | 25 | } |
palmdotax | 6:9ed82a812ece | 26 | dc=setpoint+spd; |
palmdotax | 6:9ed82a812ece | 27 | speeds.write(dc); |
palmdotax | 6:9ed82a812ece | 28 | |
palmdotax | 0:f02641e3fb91 | 29 | |
palmdotax | 8:8fbc0c858875 | 30 | } |
palmdotax | 8:8fbc0c858875 | 31 | void move:: movespeed_2(int dir,float setpoint,float spd) |
palmdotax | 8:8fbc0c858875 | 32 | { |
palmdotax | 8:8fbc0c858875 | 33 | double dc=0; |
palmdotax | 8:8fbc0c858875 | 34 | if(dir==1) |
palmdotax | 8:8fbc0c858875 | 35 | { |
palmdotax | 8:8fbc0c858875 | 36 | dirr1=1; |
palmdotax | 8:8fbc0c858875 | 37 | dirr2=0; |
palmdotax | 8:8fbc0c858875 | 38 | } |
palmdotax | 8:8fbc0c858875 | 39 | else |
palmdotax | 8:8fbc0c858875 | 40 | { |
palmdotax | 8:8fbc0c858875 | 41 | dirr1=0; |
palmdotax | 8:8fbc0c858875 | 42 | dirr2=1; |
palmdotax | 8:8fbc0c858875 | 43 | } |
palmdotax | 8:8fbc0c858875 | 44 | dc=setpoint+spd; |
palmdotax | 8:8fbc0c858875 | 45 | speeds.write(dc); |
palmdotax | 8:8fbc0c858875 | 46 | |
palmdotax | 8:8fbc0c858875 | 47 | |
palmdotax | 9:86701fec3f79 | 48 | } |
palmdotax | 9:86701fec3f79 | 49 | void move::pump(int on_off) |
palmdotax | 9:86701fec3f79 | 50 | { |
palmdotax | 9:86701fec3f79 | 51 | relays=on_off; |
palmdotax | 0:f02641e3fb91 | 52 | } |