Updated for the next revision of the motor board
Revision 8:e8985e8e9146, committed 2022-09-16
- Comitter:
- adimmit
- Date:
- Fri Sep 16 01:20:50 2022 +0000
- Parent:
- 7:e3a2ade56b79
- Commit message:
- updated for the new board;
Changed in this revision
MotorShield.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/MotorShield.cpp Wed Aug 26 23:42:07 2020 +0000 +++ b/MotorShield.cpp Fri Sep 16 01:20:50 2022 +0000 @@ -9,6 +9,20 @@ #include "MotorShield.h" #include "HardwareSetup.h" +//MotorA pins +DigitalOut enableA(PG_7); +DigitalOut disableA(PG_4); +//MotorB pins +DigitalOut enableB(PE_4); +DigitalOut disableB(PE_2); +//MotorC pins +DigitalOut enableC(PB_13); +DigitalOut disableC(PB_4); +//MotorD pins +DigitalOut enableD(PA_14); +DigitalOut disableD(PA_15); + + MotorShield::MotorShield(int periodTicks) { periodTickVal = periodTicks; init(); @@ -19,7 +33,20 @@ initHardware(periodTickVal); // Setup PWM wait_us(100); - + + //enable the motor A driver + enableA.write(1); + disableA.write(0); + //enable the motor B driver + enableB.write(1); + disableB.write(0); + //enable the motor C driver + enableC.write(1); + disableC.write(0); + //enable the motor D driver + enableD.write(1); + disableD.write(0); + wait_us(100); } void MotorShield::motorAWrite(float duty_cycle, int direction) { @@ -28,12 +55,11 @@ if (direction){ TIM15->CCR2 = tick; - TIM15->CCR1 = 0; - + TIM15->CCR1 = tick; } else { TIM15->CCR2 = 0; - TIM15->CCR1 = tick; + TIM15->CCR1 = tick; } } @@ -43,7 +69,7 @@ if (direction){ TIM12->CCR2 = tick; - TIM12->CCR1 = 0; + TIM12->CCR1 = tick; } else { TIM12->CCR2 = 0; @@ -56,7 +82,7 @@ int tick = (int)(periodTickVal * duty_cycle); if (direction){ - TIM13->CCR1 = 0; + TIM13->CCR1 = tick; TIM14->CCR1 = tick; } else { @@ -68,12 +94,12 @@ int tick = (int)(periodTickVal * duty_cycle); if (direction){ + TIM17->CCR1 = tick; TIM16->CCR1 = tick; - TIM17->CCR1 = 0; } else { + TIM17->CCR1 = tick; TIM16->CCR1 = 0; - TIM17->CCR1 = tick; } } @@ -94,4 +120,3 @@ periodTickVal = periodTicks; init(); } -