soft robotic fish 6 dummy test code for motors

Dependencies:   mbed

Fork of robfish_test_pwm_allmotors by jetfishteam

Committer:
rkk
Date:
Wed Mar 30 17:39:42 2016 +0000
Revision:
1:1c924d93c011
Parent:
0:c003ab5004eb
dummy code to test all motors

Who changed what in which revision?

UserRevisionLine numberNew contents of line
alex93 0:c003ab5004eb 1 /*********************************************************************************
alex93 0:c003ab5004eb 2 * This code simply creates a pwm value for the BCU motor, valve motor, and pump
alex93 0:c003ab5004eb 3 * motor. The BCU motor direction is governed by BCU_direction1 and
alex93 0:c003ab5004eb 4 * BCU_direction2. If connected to a PC terminal, it prints out current readings.
alex93 0:c003ab5004eb 5 *********************************************************************************/
alex93 0:c003ab5004eb 6
alex93 0:c003ab5004eb 7 #include "mbed.h"
alex93 0:c003ab5004eb 8 using namespace std;
alex93 0:c003ab5004eb 9
rkk 1:1c924d93c011 10 //Serial pc(USBTX, USBRX);
rkk 1:1c924d93c011 11 //AnalogIn valve_current(p19);
rkk 1:1c924d93c011 12 //AnalogIn bcu_current(p20);
alex93 0:c003ab5004eb 13 PwmOut valve_pwm(p21);
alex93 0:c003ab5004eb 14 PwmOut bcu_pwm(p22);
alex93 0:c003ab5004eb 15 PwmOut motor_pwm(p23);
rkk 1:1c924d93c011 16 //PwmOut led1(LED1);
rkk 1:1c924d93c011 17 //PwmOut led2(LED2);
rkk 1:1c924d93c011 18 PwmOut led3(LED3);
rkk 1:1c924d93c011 19 //DigitalOut bcu_direction1(p11);
rkk 1:1c924d93c011 20 //DigitalOut bcu_direction2(p12);
alex93 0:c003ab5004eb 21
alex93 0:c003ab5004eb 22 int main() {
alex93 0:c003ab5004eb 23 // set serial transfer rate
rkk 1:1c924d93c011 24 //pc.baud(9600)//;
rkk 1:1c924d93c011 25 //
rkk 1:1c924d93c011 26 valve_pwm = 0.0;
rkk 1:1c924d93c011 27 // led1 = 0.3;
rkk 1:1c924d93c011 28 // wait(4);
rkk 1:1c924d93c011 29 // valve_pwm = 0.0;
rkk 1:1c924d93c011 30 // led1 = 0.0;
rkk 1:1c924d93c011 31 //
rkk 1:1c924d93c011 32 bcu_pwm = 0.0;
rkk 1:1c924d93c011 33 // led2 = 0.3;
rkk 1:1c924d93c011 34 // bcu_direction1 = 0; // BCU_direction1 must not equal BCU_direction2 for the BCU motor to turn
rkk 1:1c924d93c011 35 // bcu_direction2 = 1;
rkk 1:1c924d93c011 36 //
rkk 1:1c924d93c011 37 // wait(4);
rkk 1:1c924d93c011 38 // bcu_direction1 = 1; // BCU_direction1 must not equal BCU_direction2 for the BCU motor to turn
rkk 1:1c924d93c011 39 // bcu_direction2 = 0;
rkk 1:1c924d93c011 40 //
rkk 1:1c924d93c011 41 // wait(4);
rkk 1:1c924d93c011 42 //
rkk 1:1c924d93c011 43 // bcu_pwm = 0.0;
rkk 1:1c924d93c011 44 // led2 = 0.0;
alex93 0:c003ab5004eb 45
rkk 1:1c924d93c011 46
rkk 1:1c924d93c011 47 motor_pwm = 0.7;
rkk 1:1c924d93c011 48 led3 = 0.7;
rkk 1:1c924d93c011 49 wait(20);
rkk 1:1c924d93c011 50 motor_pwm = 0.0;
rkk 1:1c924d93c011 51 led3 = 0.0;
rkk 1:1c924d93c011 52
rkk 1:1c924d93c011 53 // led2 = 1;
rkk 1:1c924d93c011 54 //
rkk 1:1c924d93c011 55 // while(1) {
rkk 1:1c924d93c011 56 // //pc.printf("valve current percentage: %3.3f%%\n", valve_current.read()*100.0f);
rkk 1:1c924d93c011 57 // wait(1);
rkk 1:1c924d93c011 58 // }
alex93 0:c003ab5004eb 59 }