soft robotic fish 6 dummy test code for motors

Dependencies:   mbed

Fork of robfish_test_pwm_allmotors by jetfishteam

Committer:
alex93
Date:
Sun Mar 20 02:58:11 2016 +0000
Revision:
0:c003ab5004eb
Child:
1:1c924d93c011
initial commit;

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
alex93 0:c003ab5004eb 10 Serial pc(USBTX, USBRX);
alex93 0:c003ab5004eb 11 AnalogIn valve_current(p19);
alex93 0:c003ab5004eb 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);
alex93 0:c003ab5004eb 16 DigitalOut led2(LED2);
alex93 0:c003ab5004eb 17 DigitalOut bcu_direction1(p11);
alex93 0:c003ab5004eb 18 DigitalOut bcu_direction2(p12);
alex93 0:c003ab5004eb 19
alex93 0:c003ab5004eb 20 int main() {
alex93 0:c003ab5004eb 21 // set serial transfer rate
alex93 0:c003ab5004eb 22 pc.baud(9600);
alex93 0:c003ab5004eb 23
alex93 0:c003ab5004eb 24 valve_pwm = 0.8;
alex93 0:c003ab5004eb 25 bcu_pwm = 0.8;
alex93 0:c003ab5004eb 26 motor_pwm = 0.8;
alex93 0:c003ab5004eb 27
alex93 0:c003ab5004eb 28 led2 = 1;
alex93 0:c003ab5004eb 29 bcu_direction1 = 0; // BCU_direction1 must not equal BCU_direction2 for the BCU motor to turn
alex93 0:c003ab5004eb 30 bcu_direction2 = 1;
alex93 0:c003ab5004eb 31
alex93 0:c003ab5004eb 32 while(1) {
alex93 0:c003ab5004eb 33 pc.printf("valve current percentage: %3.3f%%\n", valve_current.read()*100.0f);
alex93 0:c003ab5004eb 34 }
alex93 0:c003ab5004eb 35 }