Changing PPM sum input pin.

This forum is dedicated to software development related to MultiWii.
It is not the right place to submit a setup problem.
Software download
Post Reply
Matt.
Posts: 26
Joined: Sat Dec 31, 2011 11:41 pm
Location: Sydney, NSW, Australia

Changing PPM sum input pin.

Post by Matt. »

Hi Guys,

I had a bad crash an managed to kill the PPM Sum input pin and now and am trying to find the place to change it in the code.
Anyone point me to the section of code where this could be done please :-)

Thanks in advance

Matt

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Changing PPM sum input pin.

Post by copterrichie »

The only other possibility would be Pin number 3 but it is used by one of the motors, so that would have to be changed also. There are only two external Interrupts on the 328. With the cost of Pro Mini at bout 10 US dollars, maybe better to just get a new one.

Matt.
Posts: 26
Joined: Sat Dec 31, 2011 11:41 pm
Location: Sydney, NSW, Australia

Re: Changing PPM sum input pin.

Post by Matt. »

I am using a Crius SE board. I have discovered int1 and tried changing the define for the PPM_PIN_INTERRUPT FROM
attachInterrupt(0, rxInt, RISING);
TO
attachInterrupt(1, rxInt, RISING);

and changed that pin to an input by changing
PORTD = (1<<2) | (1<<4) | (1<<5) | (1<<6) | (1<<7); //enable internal pull ups on the PINs of PORTD
to
PORTD = (1<<3) | (1<<4) | (1<<5) | (1<<6) | (1<<7); //enable internal pull ups on the PINs of PORTD

but it's not working. Im not a that familiar with these micros what other registers do I need to set??

Thanks in Advance

Matt

ronco
Posts: 317
Joined: Thu Aug 18, 2011 2:58 pm

Re: Changing PPM sum input pin.

Post by ronco »

Hi,

Code: Select all

   attachInterrupt(1, rxInt, RISING);


is right, but as copterrichie said pin 3 is used as an output pin to use it as input you have to change a output pin.. and that isnt so easy. because pin !=pin ;)


regards

Felix

Matt.
Posts: 26
Joined: Sat Dec 31, 2011 11:41 pm
Location: Sydney, NSW, Australia

Re: Changing PPM sum input pin.

Post by Matt. »

Hi Felix,

So after reading up and getting a little familiar with the platform and the multiwii code I have successfully moved the PPM sum input pin to Digital Pin 3.
I am now trying to enable the PWM for digitial pin 5 to replace the motor output lost 3.

So far I have:
Changed the PWM_PIN array to:
uint8_t PWM_PIN[8] = {9,10,11,5,6,8,A2,12}; //for a quad+: rear,right,left,front

Changed the ProMini section of the motor write to :

#if (NUMBER_MOTOR > 3)
#ifndef EXT_MOTOR_RANGE
OCR0B = motor[3]>>3; // pin 5
#else
OCR0B = ((motor[3]>>2) - 250) + 2;
#endif

and changed the initOutput function case to:

TCCR0A = _BV(WGM01) | _BV(WGM00);
TCCR0B = _BV(CS02);
TCCR0A |= _BV(COM0B1); // connect pin 5 to timer 0 channel B

however changing the waveform generation mode bit in the TCCR0A register seems to halt the program.

Can someone assist in how to set up and activate the PWM on Digial Pin 5 correctly please..

Matt

ronco
Posts: 317
Joined: Thu Aug 18, 2011 2:58 pm

Re: Changing PPM sum input pin.

Post by ronco »

Matt. wrote:Hi Felix,

So after reading up and getting a little familiar with the platform and the multiwii code I have successfully moved the PPM sum input pin to Digital Pin 3.
I am now trying to enable the PWM for digitial pin 5 to replace the motor output lost 3.

So far I have:
Changed the PWM_PIN array to:
uint8_t PWM_PIN[8] = {9,10,11,5,6,8,A2,12}; //for a quad+: rear,right,left,front

Changed the ProMini section of the motor write to :

#if (NUMBER_MOTOR > 3)
#ifndef EXT_MOTOR_RANGE
OCR0B = motor[3]>>3; // pin 5
#else
OCR0B = ((motor[3]>>2) - 250) + 2;
#endif

and changed the initOutput function case to:

TCCR0A = _BV(WGM01) | _BV(WGM00);
TCCR0B = _BV(CS02);
TCCR0A |= _BV(COM0B1); // connect pin 5 to timer 0 channel B

however changing the waveform generation mode bit in the TCCR0A register seems to halt the program.

Can someone assist in how to set up and activate the PWM on Digial Pin 5 correctly please..

Matt

Hi Matt,

you cant use pin 5 or 6 for it , because timer 0 runs at 976Hz .. and we need 488Hz to be able to send a 2ms dutytime. and we cant change its frequency because arduino uses it for the time functions like micros and delay.

because of this we do motor 5 & 6 with Software PWM on the Promini

so the easyer way would be to change the hexa mix (which uses this software PWM on pin 5 & 6) to fit for a quad with this pins

example:

select HEX6X and change its mix in Output.pde like this (untested)

Code: Select all

  #ifdef HEX6X // now quad x with pin 9,10,11,6
    motor[0] = 1000; // pin 3 .. not used
    motor[1] = PIDMIX(-1,+1,-1); //REAR_R -> pin 9
    motor[2] = PIDMIX(-1,-1,+1); //FRONT_R -> pin 10
    motor[3] = PIDMIX(+1,+1,+1); //REAR_L -> pin 11
    motor[4] = PIDMIX(+1,-1,-1); //FRONT_L -> pin 6
    motor[5] = 1000; // pin 5.. not used
  #endif


regards

Felix

User avatar
dialfonzo
Posts: 62
Joined: Sun Nov 20, 2011 3:18 pm
Location: Quebec, Canada

Re: Changing PPM sum input pin.

Post by dialfonzo »

Hi copterrichie,

Do you think the thing is doable if the motor output pin is changed ?
Since i am not a programmer, just understand basic of programmation, could you do a sample multiwii file so i can test it ?

Thanks a lot

viewtopic.php?f=15&t=2888&p=28553#p28553

Eric Nantel - DiaLFonZo

QuadBow
Posts: 532
Joined: Fri Jan 04, 2013 10:06 am

Re: Changing PPM sum input pin.

Post by QuadBow »

Hi all,

I would like to make you aware that the development release r1240 supports the change of the PPM sum input pin.
This feature can be enabled by uncommenting the line
#define PPM_ON_THROTTLE
in the file config.h.

As a result of this change, the sum input has to be made avaliable at the standard throttle pin on MEGA boards (eg. A8 for CRIUS AIO and FLYDUINO MEGA) and PROMICRO boards. Due to my obvervation, there is no big impact to cycle time. Being familiar with the code it should be possible to use another unused INT- or PCINT-pin instead of INT6_vect (PROMICOR) or PCINT2_vect (MEGA), as well (RX.INO).

I think this feature helps those who have an RX/TX issue.

Good luck

User avatar
dialfonzo
Posts: 62
Joined: Sun Nov 20, 2011 3:18 pm
Location: Quebec, Canada

Re: Changing PPM sum input pin.

Post by dialfonzo »

QuadBow wrote:Hi all,

I would like to make you aware that the development release r1240 supports the change of the PPM sum input pin.
This feature can be enabled by uncommenting the line
#define PPM_ON_THROTTLE
in the file config.h.

As a result of this change, the sum input has to be made avaliable at the standard throttle pin on MEGA boards (eg. A8 for CRIUS AIO and FLYDUINO MEGA) and PROMICRO boards. Due to my obvervation, there is no big impact to cycle time. Being familiar with the code it should be possible to use another unused INT- or PCINT-pin instead of INT6_vect (PROMICOR) or PCINT2_vect (MEGA), as well (RX.INO).

I think this feature helps those who have an RX/TX issue.

Good luck


First, thanks for trying to help.,. :)

I don't understand that "#define PPM_ON_THROTTLE" since the ppm was already originaly on the throttle pin.

Eric

QuadBow
Posts: 532
Joined: Fri Jan 04, 2013 10:06 am

Re: Changing PPM sum input pin.

Post by QuadBow »

First, thanks for trying to help.,. :)

I don't understand that "#define PPM_ON_THROTTLE" since the ppm was already originaly on the throttle pin.

Eric


Hi Eric,
The definition PPM_ON_THROTTLE is maybe misleading since we are talking about the PPM SUM input pin.
This sum pin replaces the pins of ALL channels and is usually connected to serial 1. Since the originator of this thread got an issue with this serial 1, I informed about the possibility to change the sum input pin from serial 1 to the throttle pin.

Best wishes

i3dm
Posts: 57
Joined: Tue Oct 01, 2013 4:48 pm

Re: Changing PPM sum input pin.

Post by i3dm »

Hello guys,
on one of my Crius SE boards i think i have a problem with PPM on throttle pin. if i connect there the RC signals go crazy, and in another identical board it works 100% fine with the same code.
how can i change the PPM SUM input pin to the Crius SE board to lets say A7?
i dont want to use A8 as my board only has the following sockets available:
A0
A1
A2
A3
A6
A7

Spacefish
Posts: 9
Joined: Wed Aug 07, 2013 12:26 pm

Re: Changing PPM sum input pin.

Post by Spacefish »

You are limited to some pins in the current software, as you can only use pins that generate a interrupt. This is due a hardware limitation (not all pins generate a interrupt).
Another way would be to use the ICPX pins (ICP1-ICP5 on Mega 2560). But you have to change the code / initialize the timers to capture those events..

I have done this for my CRIUS AIO Pro V2 as the PPM pin on the PCB is connected to ICP1 which can´t generate a Interrupt in a way MultiWii currently accepts.. See my Code here: viewtopic.php?f=8&t=4788

i3dm
Posts: 57
Joined: Tue Oct 01, 2013 4:48 pm

Re: Changing PPM sum input pin.

Post by i3dm »

Spacefish wrote:You are limited to some pins in the current software, as you can only use pins that generate a interrupt. This is due a hardware limitation (not all pins generate a interrupt).
Another way would be to use the ICPX pins (ICP1-ICP5 on Mega 2560). But you have to change the code / initialize the timers to capture those events..

I have done this for my CRIUS AIO Pro V2 as the PPM pin on the PCB is connected to ICP1 which can´t generate a Interrupt in a way MultiWii currently accepts.. See my Code here: viewtopic.php?f=8&t=4788


Thanks but im using a Crius SE with Atmega 328P.

denism
Posts: 17
Joined: Fri Feb 21, 2014 7:09 am

Re: Changing PPM sum input pin.

Post by denism »

What about NanoWii, Atmega 32u4 based board? Can PPM SUM be moved to another pin? If so, which one?
On my board default PPM pin (throtle) is pulled to Vcc (fried Atmega?)

Post Reply