stewartplatform

Dependencies:   mbed

Fork of PwmOut_HelloWorld by Mbed

src/motor.cpp

Committer:
wheels
Date:
2016-08-20
Revision:
3:c5ea5b6a7460
Parent:
2:50062ac8646d

File content as of revision 3:c5ea5b6a7460:

#include "motor.h"

PwmOut motor[6] = {PwmOut(PA_6), PwmOut(PA_0), PwmOut(PA_2), PwmOut(PB_0), PwmOut(PA_1), PwmOut(PB_9)};
extern char position[6];

void motor_drive() {
    for(int index = 0; index < 6; index++) {
        float duty = (0.000417 * position[index] + 0.05);
        motor[index] = duty;            
    }
}

void motor_init() {
        for (int index = 0; index < 6; index++) {
                motor[index].period(0.020);                                 //cycle period is 20ms
                motor[index] = 0.075;                                               //control pulse width is 1ms~2ms? should be confirmed!!
        }
//      motor[0].period(0.020);
//      motor[0] = 0.05;
}