Hello,
I've got the problem, that pin 9 on my FC (http://www.hobbyking.com/hobbyking/stor ... ouse_.html) is broken. Now i tried to change the pin order in the output.cpp. The Image in the Gui changed but no signal is send at the pin. I read posts (this one: viewtopic.php?f=8&t=1382) about changing the pin order but not for my FC. Please tell me where i have to change what.
Thanke you, I hope its not to difficult!
Change Motor Pin Order
Re: Change Motor Pin Order
You'll likely have to change PWM_PIN and writeMotors(). Do you know what Arduino board type it is?
Re: Change Motor Pin Order
TheBum wrote:You'll likely have to change PWM_PIN and writeMotors(). Do you know what Arduino board type it is?
If you have detailed knowledge on how to do this, maybe you could write up some howto on "Change pin order" for the wiki?
This question pops up again and again, more often from users with obviously so little knowledge one is tempted to advise to buy a new board. Others only lack the easy route in the MWii code's whereabouts and are good to go with few simple pointers.
Re: Change Motor Pin Order
I've been going through the Output.cpp code to find out if I can steal one of the timers for HoTT telemetry transmission, so I'm beginning to develop an understanding for how motor and servo output works. I can understand why someone hasn't come up with clear instructions; the code is pretty intimidating. I could sure give it a shot...after I finish with my telemetry mods.
Re: Change Motor Pin Order
My board has the Atmega32u4 so i have to use leonardo in arduino. Hope you can fix it, this code is to complex and hard to read for me
Re: Change Motor Pin Order
Yeah, the PROMICRO code is especially convoluted because it has to make lemonade out of lemons (limited resources). The PROMINI code is a little less convoluted. That's one advantage I've seen to using a Mega: there aren't any special cases that depend on number of motors and number of servos; there are some dual use resources, but they're static.
Does the normal pin order start with 9, 10, 5, 6? Also, which aircraft type is it?
Does the normal pin order start with 9, 10, 5, 6? Also, which aircraft type is it?
Re: Change Motor Pin Order
yeah it starts with 9,10,5,6 and its a quadx.
Re: Change Motor Pin Order
First step, "def.h".
#elif defined(QUADP) || defined(QUADX) || defined(Y4)|| defined(VTAIL4)
#define NUMBER_MOTOR 4
Change to:
#elif defined(QUADP) || defined(QUADX) || defined(Y4)|| defined(VTAIL4)
// #define NUMBER_MOTOR 4
#define NUMBER_MOTOR 8 // Change Pin Order
Second step, "Output.cpp".
******** Specific PWM Timers & Registers for the atmega328P (Promini) ************/
#if defined(PROMINI)
#if (NUMBER_MOTOR > 0)
#ifdef EXT_MOTOR_RANGE // 490Hz
OCR1A = ((motor[0]>>2) - 250);
#elif defined(EXT_MOTOR_32KHZ)
OCR1A = (motor[0] - 1000) >> 2; // pin 9
#elif defined(EXT_MOTOR_4KHZ)
OCR1A = (motor[0] - 1000) << 1;
#elif defined(EXT_MOTOR_1KHZ)
OCR1A = (motor[0] - 1000) << 3;
#else
OCR1A = motor[0]>>3; // pin 9
#endif
Change to:
/******** Specific PWM Timers & Registers for the atmega328P (Promini) ************/
#if defined(PROMINI)
#if (NUMBER_MOTOR > 0)
#ifdef EXT_MOTOR_RANGE // 490Hz
OCR1A = ((motor[0]>>2) - 250);
#elif defined(EXT_MOTOR_32KHZ)
OCR1A = (motor[0] - 1000) >> 2; // pin 9
#elif defined(EXT_MOTOR_4KHZ)
OCR1A = (motor[0] - 1000) << 1;
#elif defined(EXT_MOTOR_1KHZ)
OCR1A = (motor[0] - 1000) << 3;
#else
#if defined(QUADX)
OCR1A = motor[3]>>3; // Change Pin
#else
OCR1A = motor[0]>>3; // pin 9
#endif
#endif
#elif defined(QUADP) || defined(QUADX) || defined(Y4)|| defined(VTAIL4)
#define NUMBER_MOTOR 4
Change to:
#elif defined(QUADP) || defined(QUADX) || defined(Y4)|| defined(VTAIL4)
// #define NUMBER_MOTOR 4
#define NUMBER_MOTOR 8 // Change Pin Order
Second step, "Output.cpp".
******** Specific PWM Timers & Registers for the atmega328P (Promini) ************/
#if defined(PROMINI)
#if (NUMBER_MOTOR > 0)
#ifdef EXT_MOTOR_RANGE // 490Hz
OCR1A = ((motor[0]>>2) - 250);
#elif defined(EXT_MOTOR_32KHZ)
OCR1A = (motor[0] - 1000) >> 2; // pin 9
#elif defined(EXT_MOTOR_4KHZ)
OCR1A = (motor[0] - 1000) << 1;
#elif defined(EXT_MOTOR_1KHZ)
OCR1A = (motor[0] - 1000) << 3;
#else
OCR1A = motor[0]>>3; // pin 9
#endif
Change to:
/******** Specific PWM Timers & Registers for the atmega328P (Promini) ************/
#if defined(PROMINI)
#if (NUMBER_MOTOR > 0)
#ifdef EXT_MOTOR_RANGE // 490Hz
OCR1A = ((motor[0]>>2) - 250);
#elif defined(EXT_MOTOR_32KHZ)
OCR1A = (motor[0] - 1000) >> 2; // pin 9
#elif defined(EXT_MOTOR_4KHZ)
OCR1A = (motor[0] - 1000) << 1;
#elif defined(EXT_MOTOR_1KHZ)
OCR1A = (motor[0] - 1000) << 3;
#else
#if defined(QUADX)
OCR1A = motor[3]>>3; // Change Pin
#else
OCR1A = motor[0]>>3; // pin 9
#endif
#endif
Re: Change Motor Pin Order
First step, "def.h".
Change to:
Second step, "Output.cpp".
Change to:
Change other pin:
#elif defined(QUADP) || defined(QUADX) || defined(Y4)|| defined(VTAIL4)
#define NUMBER_MOTOR 4
Change to:
#elif defined(QUADP) || defined(QUADX) || defined(Y4)|| defined(VTAIL4)
// #define NUMBER_MOTOR 4
#define NUMBER_MOTOR 8 // Change Pin Order
Second step, "Output.cpp".
******** Specific PWM Timers & Registers for the atmega328P (Promini) ************/
#if defined(PROMINI)
#if (NUMBER_MOTOR > 0)
#ifdef EXT_MOTOR_RANGE // 490Hz
OCR1A = ((motor[0]>>2) - 250);
#elif defined(EXT_MOTOR_32KHZ)
OCR1A = (motor[0] - 1000) >> 2; // pin 9
#elif defined(EXT_MOTOR_4KHZ)
OCR1A = (motor[0] - 1000) << 1;
#elif defined(EXT_MOTOR_1KHZ)
OCR1A = (motor[0] - 1000) << 3;
#else
OCR1A = motor[0]>>3; // pin 9
#endif
Change to:
/******** Specific PWM Timers & Registers for the atmega328P (Promini) ************/
#if defined(PROMINI)
#if (NUMBER_MOTOR > 0)
#ifdef EXT_MOTOR_RANGE // 490Hz
OCR1A = ((motor[0]>>2) - 250);
#elif defined(EXT_MOTOR_32KHZ)
OCR1A = (motor[0] - 1000) >> 2; // pin 9
#elif defined(EXT_MOTOR_4KHZ)
OCR1A = (motor[0] - 1000) << 1;
#elif defined(EXT_MOTOR_1KHZ)
OCR1A = (motor[0] - 1000) << 3;
#else
#if defined(QUADX)
OCR1A = motor[3]>>3; // Change Pin
#else
OCR1A = motor[0]>>3; // pin 9
#endif
#endif
Change other pin:
#if (NUMBER_MOTOR > 6) //note: EXT_MOTOR_RANGE not possible here
atomicPWM_PINA2_highState = ((motor[6]-1000)>>2)+5;
atomicPWM_PINA2_lowState = 245-atomicPWM_PINA2_highState;
#if defined(QUADX)
atomicPWM_PIN12_highState = ((motor[1]-1000)>>2)+5; // Change Pin
#else
atomicPWM_PIN12_highState = ((motor[7]-1000)>>2)+5;
#endif
atomicPWM_PIN12_lowState = 245-atomicPWM_PIN12_highState;
#endif
-
- Posts: 7
- Joined: Mon May 25, 2015 5:53 pm