2.74 Nucleo Code
Dependencies: ExperimentServer QEI_pmw MotorShield
Diff: main.cpp
- Revision:
- 10:a40d180c305c
- Parent:
- 9:97360c92666f
- Child:
- 11:4eb579687dda
--- a/main.cpp Wed Aug 26 00:24:56 2020 +0000 +++ b/main.cpp Wed Aug 26 02:44:03 2020 +0000 @@ -23,35 +23,14 @@ AnalogIn currentC(PF_13); //MOTOR C CURRENT SENSOR AnalogIn currentD(PA_4); //MOTOR D CURRENT SENSOR -//MotorShield motorA(PE_5, PE_6); //MOTOR A PWM -//MotorShield motorB(PB_14, PB_15); //MOTOR B PWM -//MotorShield motorC(PA_6, PF_9); //MOTOR C PWM -//MotorShield motorD(PF_6, PF_7); //MOTOR D PWM +MotorShield motors(1000); //initialize the motor shield with a period of 1000 ticks or xxx kHZ int main (void) { - initHardware(); // Setup PWM - wait_us(100); - - TIM12->CCR2 = 100; - TIM12->CCR1 = 200; - TIM13->CCR1 = 200; - TIM14->CCR1 = 200; - TIM15->CCR1 = 200; - TIM15->CCR2 = 200; - TIM16->CCR1 = 200; - TIM17->CCR1 = 200; - - while(1){ - } - /* // Link the terminal with our server and start it up server.attachTerminal(pc); server.init(); - // PWM period should nominally be a multiple of our control loop - motorPWM.period_us(500); - // Continually get input from MATLAB and run experiments float input_params[NUM_INPUTS]; pc.printf("%f",input_params[0]); @@ -68,17 +47,16 @@ encoderB.reset(); encoderC.reset(); encoderD.reset(); - motorFwd = 1; - motorRev = 0; - motorPWM.write(0); + + motors.motorAWrite(0, 0); //turn motor A off // Run experiment while( t.read() < 2 ) { // Perform control loop logic if (t.read() < 1) - motorPWM.write(v1); + motors.motorAWrite(v1, 0); //run motor A at "v1" duty cycle and in the forward direction else - motorPWM.write(v2); + motors.motorAWrite(v2, 0); //run motor A at "v2" duty cycle and in the forward direction // Form output to send to MATLAB float output_data[NUM_OUTPUTS]; @@ -92,9 +70,9 @@ } // Cleanup after experiment server.setExperimentComplete(); - motorPWM.write(0); + motors.motorAWrite(0, 0); //turn motor A off } // end if } // end while - */ + } // end main