Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Communication_Robot QEI iSerial mbed motion_control
Fork of dog_V3_2_testmotor by
Diff: main.cpp
- Revision:
- 8:8d30ce9a9463
- Parent:
- 7:6a99be179329
- Child:
- 9:0de6ce956985
--- a/main.cpp Fri Jul 17 07:11:46 2015 +0000 +++ b/main.cpp Fri Jul 17 12:07:19 2015 +0000 @@ -4,6 +4,8 @@ #include "communication.h" #include "protocol.h" +#include "motor_relay.h" + //set frequancy unit in Hz #define F_UPDATE 10.0f #define TIMER_UPDATE 1.0f/F_UPDATE @@ -12,6 +14,7 @@ #define TIMEOUT_RESPONE_COMMAND 5 //define pin class +/* DigitalOut dirA_LU(INA_L_U); DigitalOut dirB_LU(INB_L_U); @@ -23,7 +26,13 @@ DigitalOut dirA_RL(INA_R_L); DigitalOut dirB_RL(INB_R_L); +*/ +MOTOR_RELAY leg_left_upper(INA_L_U,INB_L_U); +MOTOR_RELAY leg_left_lower(INA_L_L,INB_L_L); +MOTOR_RELAY leg_right_upper(INA_R_U,INB_R_U); +MOTOR_RELAY leg_right_lower(INA_R_L,INB_R_L); +/* DigitalIn sw_LU_U(LIMIT_LU_U,PullUp); DigitalIn sw_LU_D(LIMIT_LU_D,PullUp); @@ -35,6 +44,7 @@ DigitalIn sw_RL_U(LIMIT_RL_U,PullUp); DigitalIn sw_RL_D(LIMIT_RL_D,PullUp); +*/ AnalogIn position_LU(VR_LU); AnalogIn position_LL(VR_LL); @@ -88,7 +98,7 @@ uint16_t vr_lu,vr_ru; uint16_t vr_ll,vr_rl; pc.printf("wait\n"); - motor_stop(0); + //motor_stop(0); // wait(10); /* while(1) { @@ -104,6 +114,12 @@ wait(1); } */ + while(1) { + leg_left_upper.SetMotor(1); + leg_left_lower.SetMotor(1); + leg_right_upper.SetMotor(1); + leg_right_lower.SetMotor(1); + } /* while(1) { @@ -301,7 +317,7 @@ } - +/* void motor_set(uint8_t id, uint8_t direct) { //direct: Should be between 0 and 3, with the following result @@ -408,9 +424,9 @@ break; } } - +*/ - +/* uint8_t limit_motor(uint8_t id, uint8_t dirction) { switch(id) { @@ -581,7 +597,7 @@ motor_stop(id); wait_ms(500); pc.printf("motor[3] stop down\n"); - + do { motor_set(id,1); } while(sw_RU_D); @@ -625,6 +641,10 @@ } } + +*/ + + /* uint16_t convert(uint16_t data) {