Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
DC Motors: They are working in reverse
07-27-2019, 10:04 PM
Post: #1
DC Motors: They are working in reverse
Hello all,

I am not asking a question here. I just wanted to post this for the novice level engineering students in case they ran into a motor direction problem. The code for the Blimpduino 2 caused my motors to spin in the opposite direction as they were supposed to. But this was an easy fix, here is what I did on the "Motor" script (comments on the side with two asteriks "**" will denote my comments what was originally there:
[Code]

//DON NOT CHANGE!!! Values are matched to BLimpduino hardware.
void m_set_direct(int motor, int value) { //The same as m_set below but with DeadZone control.

//**PINS ARE SWITCHED FROM ORIGINAL FILE, SINCE MY MOTORS ARE RUNNING IN REVERSE

switch (motor) {
case 0: //Motor 0
#if m0_rev == 0 //if m0_rev is set to 1 it will reverse the motors
output_motor_direct(value, 6, 5); //**Originally 5,6
#else
output_motor_direct(value, 5, 6); //**Originally 6,5
#endif
break;
case 1:
#if m1_rev == 0
output_motor_direct(value, 10, 9); //Motor 1 ; //**Originally 9,10
#else
output_motor_direct(value, 9, 10); //Reversed; // **Originally 10,9
#endif
break;
case 2:
#if m2_rev == 0
output_motor_direct(value, 8, 7); //Motor 2 ; //**Originally 7,8
#else
output_motor_direct(value, 7, 8); //Reversed ; //**Originally 8,7
#endif
break;
case 3:
#if m3_rev == 0
output_motor_direct(value, 12, 11); //Motor 3 ; // **Originally 11,12
#else
output_motor_direct(value, 11, 12); //Reversed // **Originally 12,11
#endif
break;
case 5: //Will set all motor at the same time. WARNING Reverse not working yet.
output_motor_direct(value, 6, 5); //**Originally 5,6
output_motor_direct(value, 10, 9); //**Originally 9,10
output_motor_direct(value, 8, 7); // **Originally 7,8
output_motor_direct(value, 12, 11); // **Originally 11,12
break;
default:

break;
}

}
Find all posts by this user
Quote this message in a reply
07-29-2019, 01:52 PM
Post: #2
RE: DC Motors: They are working in reverse
(07-27-2019 10:04 PM)atouhidi Wrote:  Hello all,

I am not asking a question here. I just wanted to post this for the novice level engineering students in case they ran into a motor direction problem. The code for the Blimpduino 2 caused my motors to spin in the opposite direction as they were supposed to. But this was an easy fix, here is what I did on the "Motor" script (comments on the side with two asteriks "**" will denote my comments what was originally there:
[Code]

//DON NOT CHANGE!!! Values are matched to BLimpduino hardware.
void m_set_direct(int motor, int value) { //The same as m_set below but with DeadZone control.

//**PINS ARE SWITCHED FROM ORIGINAL FILE, SINCE MY MOTORS ARE RUNNING IN REVERSE

switch (motor) {
case 0: //Motor 0
#if m0_rev == 0 //if m0_rev is set to 1 it will reverse the motors
output_motor_direct(value, 6, 5); //**Originally 5,6
#else
output_motor_direct(value, 5, 6); //**Originally 6,5
#endif
break;
case 1:
#if m1_rev == 0
output_motor_direct(value, 10, 9); //Motor 1 ; //**Originally 9,10
#else
output_motor_direct(value, 9, 10); //Reversed; // **Originally 10,9
#endif
break;
case 2:
#if m2_rev == 0
output_motor_direct(value, 8, 7); //Motor 2 ; //**Originally 7,8
#else
output_motor_direct(value, 7, 8); //Reversed ; //**Originally 8,7
#endif
break;
case 3:
#if m3_rev == 0
output_motor_direct(value, 12, 11); //Motor 3 ; // **Originally 11,12
#else
output_motor_direct(value, 11, 12); //Reversed // **Originally 12,11
#endif
break;
case 5: //Will set all motor at the same time. WARNING Reverse not working yet.
output_motor_direct(value, 6, 5); //**Originally 5,6
output_motor_direct(value, 10, 9); //**Originally 9,10
output_motor_direct(value, 8, 7); // **Originally 7,8
output_motor_direct(value, 12, 11); // **Originally 11,12
break;
default:

break;
}

}

Thanks for this! quite useful. I am creating a larger blimp controlled using the same control board and needed to change the spinning direction
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)