Change engine to another pin.
-
- Posts: 16
- Joined: Wed Mar 14, 2012 5:16 pm
Change engine to another pin.
Hello friends, I'm Spanish.
It broke my arduino pin 5 MEGA and I broke the pin 10 of Arduino Pro Mini, they are both motor output.
I do not know MULTIWII change the code to change the pin engine, anyone know how? someone can tell me where I can read and learn?
I just need to change a motor.
Thanks, I hope to get lucky, I can fly my quadricopter.
It broke my arduino pin 5 MEGA and I broke the pin 10 of Arduino Pro Mini, they are both motor output.
I do not know MULTIWII change the code to change the pin engine, anyone know how? someone can tell me where I can read and learn?
I just need to change a motor.
Thanks, I hope to get lucky, I can fly my quadricopter.
Re: Change engine to another pin.
In Output.pde
Code: Select all
#if defined(PROMINI)
uint8_t PWM_PIN[8] = {9,10,11,3,6,5,A2,12}; //for a quad+: rear,right,left,front
#endif
#if defined(PROMICRO)
#if !defined(HWPWM6)
uint8_t PWM_PIN[8] = {9,10,5,6,4,A2,A0,A1}; //for a quad+: rear,right,left,front
#else
uint8_t PWM_PIN[8] = {9,10,5,6,11,13,A0,A1}; //for a quad+: rear,right,left,front
#endif
#endif
#if defined(MEGA)
uint8_t PWM_PIN[8] = {3,5,6,2,7,8,9,10}; //for a quad+: rear,right,left,front //+ for y6: 7:under right 8:under left
#endif
-
- Posts: 16
- Joined: Wed Mar 14, 2012 5:16 pm
Re: Change engine to another pin.
PatrikE Thanks! no one had answered this question.
The version I use is MultiWii_dev_20120203, the variable 'PWM_PIN uint8_t [8]' does not exist. Any version of multiwii is good for me, I have no sensors.
Can you tell me which version you use?
which is the version where the variable appears 'PWM_PIN uint8_t [8]'?
Thank you !!
The version I use is MultiWii_dev_20120203, the variable 'PWM_PIN uint8_t [8]' does not exist. Any version of multiwii is good for me, I have no sensors.
Can you tell me which version you use?
which is the version where the variable appears 'PWM_PIN uint8_t [8]'?
Thank you !!
Re: Change engine to another pin.
It's in the V2 pre versions.
In older realeases it's in def.pde.
In older realeases it's in def.pde.
Code: Select all
#define MOTOR_ORDER 3,5,6,2,7,8,9,10 //for a quad+: rear,right,left,front
Re: Change engine to another pin.
Hi,
it isnt that esay .. on the promini there are just 4 usable PWM pins .. if you broke pin 10 there is no real replacement .. it is possible to use software PWM on other pins but this would require a large code manipulation.
on the mega are more PWM pins .. but since we dont use analoWrite anymore its also not that easy.
the simplest way is to chose a free PWM pin on this list https://spreadsheets.google.com/pub?key ... GPkA&gid=0
witch is driven by timer 1 (pin 11, pin 12 or pin 13) or timer 5 (pin 44, pin 45 or pin 46)
and use it like this:
in output.pde
chosenPin = the free PWM Pin
regards felix
it isnt that esay .. on the promini there are just 4 usable PWM pins .. if you broke pin 10 there is no real replacement .. it is possible to use software PWM on other pins but this would require a large code manipulation.
on the mega are more PWM pins .. but since we dont use analoWrite anymore its also not that easy.
the simplest way is to chose a free PWM pin on this list https://spreadsheets.google.com/pub?key ... GPkA&gid=0
witch is driven by timer 1 (pin 11, pin 12 or pin 13) or timer 5 (pin 44, pin 45 or pin 46)
and use it like this:
in output.pde
Code: Select all
void writeMotors() { // [1000;2000] => [125;250]
#if defined(MEGA)// [1000:2000] => [8000:16000] for timer 3 & 4 for mega
#if (NUMBER_MOTOR > 0)
#ifndef EXT_MOTOR_RANGE
OCR3C = motor[0]<<3; // pin 3
#else
OCR3C = ((motor[0]<<4) - 16000) + 128;
#endif
#endif
#if (NUMBER_MOTOR > 1)
#ifndef EXT_MOTOR_RANGE
//OCR3A = motor[1]<<3; // pin 5
analogWrite(chosenPin,motor[1]>>3);
#else
//OCR3A = ((motor[1]<<4) - 16000) + 128;
analogWrite(chosenPin,((motor[1]>>2) - 250) + 2);
#endif
#endif
...
chosenPin = the free PWM Pin
regards felix
Last edited by ronco on Mon Mar 19, 2012 3:37 pm, edited 1 time in total.
-
- Posts: 16
- Joined: Wed Mar 14, 2012 5:16 pm
Re: Change engine to another pin.
I will try as soon as possible
It seems much easier than I imagined, but unknowingly ...
I'll tell you when I can prove it. I will use the V2 multiwii
PatrikE Thanks!
It seems much easier than I imagined, but unknowingly ...
I'll tell you when I can prove it. I will use the V2 multiwii
PatrikE Thanks!
-
- Posts: 16
- Joined: Wed Mar 14, 2012 5:16 pm
Re: Change engine to another pin.
PatrikE Thanks for your help, but that way I get nothing.
ooooOOOOooooOOOOOOOoo ...... thanks ronco !!! Your code by convincing. I tried several times to change, but I could not.
I'm programmer and work in Java, the language of multiwii do not know, but I see you're in control.
With your help I will be able to mount a quadricopter with MEGA
, a pity that I can not take advantage of the PRO MINI for tricopter
Thank you very much ronco !! I'll tell you when to fix it.
Good forum with good people, no one before I answered this question.
ooooOOOOooooOOOOOOOoo ...... thanks ronco !!! Your code by convincing. I tried several times to change, but I could not.
I'm programmer and work in Java, the language of multiwii do not know, but I see you're in control.
With your help I will be able to mount a quadricopter with MEGA



Thank you very much ronco !! I'll tell you when to fix it.
Good forum with good people, no one before I answered this question.
Re: Change engine to another pin.
Hi,
if you "just" want to use the promini (with the broken pin 10) for a tricopter it is more easy! because the yaw servo is still powerd with soft pwm.
and for the mega .. i have none so i cant test it .. if you tell me your setup (tri or quad or hexa...) i may give you a working code but with such changes you will have to add it in each new version you want to use...
regards felix
if you "just" want to use the promini (with the broken pin 10) for a tricopter it is more easy! because the yaw servo is still powerd with soft pwm.
and for the mega .. i have none so i cant test it .. if you tell me your setup (tri or quad or hexa...) i may give you a working code but with such changes you will have to add it in each new version you want to use...
regards felix
Re: Change engine to another pin.
... if you have some soldering skills you may connect pin 10 of the promicro direct on the chip
but be careful
but be careful

Re: Change engine to another pin.
There's a hack you can do to get PROMINI to work.
Add a mitorPin.
In def.h change to 4 motors.
And move servo to D12
In output. change to.
This will Copy Pin 10 to Pin 3.
Servo will be moved to pin 12.
/Patrik
Add a mitorPin.
In def.h change to 4 motors.
Code: Select all
#elif defined(TRI)
#define NUMBER_MOTOR 4 // Change from 3 To 4
#define PRI_SERVO_FROM 4 // Move servo from 6 to 4.
#define PRI_SERVO_TO 4
And move servo to D12
In output. change to.
Code: Select all
#ifdef TRI
motor[0] = PIDMIX( 0,+4/3, 0); //REAR
motor[1] = PIDMIX(-1,-2/3, 0); //RIGHT
motor[2] = PIDMIX(+1,-2/3, 0); //LEFT
motor[3] = motor[1]; // Copy RIGHT motor to D3
// Change servo to D12 =servo[3]
servo[3] = constrain(tri_yaw_middle + YAW_DIRECTION * axisPID[YAW], TRI_YAW_CONSTRAINT_MIN, TRI_YAW_CONSTRAINT_MAX); //REAR
#endif
This will Copy Pin 10 to Pin 3.
Servo will be moved to pin 12.
/Patrik
-
- Posts: 16
- Joined: Wed Mar 14, 2012 5:16 pm
Re: Change engine to another pin.
ronco Thanks, your solution seems a sure thing.
First I will try the solution Patrik, but if I fail, as I said welding ronco.
Patrik as you know so much code? thanks for your solution and time, I think this week I can fix it perfectly.
Good people around here willing to help ....
Thanks to all friends.
First I will try the solution Patrik, but if I fail, as I said welding ronco.
Patrik as you know so much code? thanks for your solution and time, I think this week I can fix it perfectly.
Good people around here willing to help ....
Thanks to all friends.
Re: Change engine to another pin.
I’m still not clear on how to do this.
I’m using a Crius lite board and seem to have problems with the traces for pin D11. Since the documentation for the board seems to say it supports hexcopters, I was hoping to shift the quad to use either D5 or D6 as a replacement for D11. I tried switching the order of the PWM_PIN set and it did not work. Is there something else I’m missing?
I’m using a Crius lite board and seem to have problems with the traces for pin D11. Since the documentation for the board seems to say it supports hexcopters, I was hoping to shift the quad to use either D5 or D6 as a replacement for D11. I tried switching the order of the PWM_PIN set and it did not work. Is there something else I’m missing?