Motion controll board test program
Dependencies: Motor mbed eeprom
Revision 1:5a5abae3748b, committed 2016-03-26
- Comitter:
- sunarin
- Date:
- Sat Mar 26 07:50:05 2016 +0000
- Parent:
- 0:be4a5e3ebb41
- Commit message:
- motor active
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/eeprom.lib Sat Mar 26 07:50:05 2016 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/FRA221_2015/code/eeprom/#c648c5e93d5e
--- a/main.cpp Tue Dec 22 15:02:04 2015 +0000 +++ b/main.cpp Sat Mar 26 07:50:05 2016 +0000 @@ -1,14 +1,105 @@ #include "mbed.h" #include "Motor.h" -#include "pinconfig.h" +#include "pinconfig.h" +#include "eeprom.h" -int main() +Serial rd(D1,D0); +Serial pc(D8,D2); +AnalogIn Ain1(PC_2); +AnalogIn Ain2(PC_3); +DigitalIn enable(PB_7); +DigitalIn enable1(PC_13); +EEPROM memory(PB_4,PA_8,0); +DigitalOut dout(LED1); + +int main(void) { - Motor Upper(PWM_LU,A_LU,B_LU ); - Upper.period(0.001); - while(1) - { - Upper.speed(-1); + Motor Upper1(PWM_LU,A_LU,B_LU ); + Motor Upper2(PWM_LL,A_LL,B_LL ); + Upper1.period(0.00001); + Upper2.period(0.00001); + uint8_t data; + // uint8_t sw= Switch.read(); + + float x,j; + float y,j1; + int k; + rd.printf("Hello World !\n"); + + while(1) { + data = pc.getc(); + rd.printf("%c",data); + rd.printf("\n"); + wait_ms(100); + + switch(data) { + + case'u': + pc.printf("Motor up left\n"); + Upper1.speed(1); + break; + + case'd': + Upper1.speed(-1); + pc.printf("Motor down left\n"); + /* + if(enable==1) { + Upper1.speed(0); + //printf("stop\n"); + } else if(enable==0) { + Upper1.speed(-1); + //printf("down left\n"); + } + */ + break; + + case'l': + pc.printf("Motor up right\n"); + Upper2.speed(1); + break; + + case'k': + Upper2.speed(-1); + pc.printf("Motor down right\n"); + /* + + if(enable1==1) { + Upper2.speed(0); + //printf("stop\n"); + } else if(enable1==0) { + Upper2.speed(-1); + //printf("down right\n"); + } + */ + break; + + case's': + //printf("Motor stop\n"); + pc.printf("Motor stop\n"); + Upper1.speed(0); + Upper2.speed(0); + break; + + case'w': + j = (Ain1.read()*3.3); + pc.printf("memory = %3.3f\n",j); + memory.write(14,j); + wait_ms(1); + j1 = (Ain2.read()*3.3); + pc.printf("memory = %3.3f\n",j1); + memory.write(11,j1); + wait_ms(1); + break; + + case'e': + + memory.read(14,x); + wait_ms(1); + pc.printf("display = %3.3f\n",j); + memory.read(11,y); + wait_ms(1); + pc.printf("diplay = %3.3f\n",j1); + break; + } } - -} \ No newline at end of file +} \ No newline at end of file
--- a/pinconfig.h Tue Dec 22 15:02:04 2015 +0000 +++ b/pinconfig.h Sat Mar 26 07:50:05 2016 +0000 @@ -14,14 +14,16 @@ #define B_LL PC_9 //limit switch -#define Lim_LU1 PB_7 +/*#define Lim_LU1 PB_7 #define Lim_LU2 PC_13 #define Lim_LL1 PC_14 -#define Lim_LL2 PC_15 +#define Lim_LL2 PC_15*/ #define Lim_RU1 D2 #define Lim_RU2 D3 #define Lim_RL1 D8 #define Lim_RL2 D9 +#define Lim_IR1 PC_2 + //encoder mode1 #define Emosi PC_12 @@ -34,5 +36,8 @@ #define Tx PA_2 #define Rx PA_3 #define Dir PB_5 +//eeprom +#define I2C_SDA D14 +#define I2C_SCL D15 #endif