I'm green as grass, but I'm trying to learn how to program. I want to fly a tricopter using MulitWii firmware which will run on a atmega 328. There is a specific board sold by a vendor, but I have a different board that is laidout a little differently. My board is the ArduIMU sold by 3DRobotics. This board is labeled with pins D8, A0, A1, A2, A3 available. The MultiWii code is setup to read PPM on pin labeled D2, but I only have D8 available for reading a Rx.
This is the line in the Rx sketch where PPM is started:
/**************************************************************************************/
/*************** PPM SUM RX Pin reading ********************/
/**************************************************************************************/
// attachInterrupt fix for promicro
#if defined(PROMICRO) && defined(SERIAL_SUM_PPM)
ISR(INT6_vect){rxInt();}
#endif
If I want to use pin D8, should I change that to ISR(INT8_vect) ?
I am able to Rx a single channel by turning off PPM and uncommenting this line:
/********************************* Aux 2 Pin **********************************/
/ possibility to use PIN8 or PIN12 as the AUX2 RC input (only one, not both)
it deactivates in this case the POWER PIN (pin 12) or the BUZZER PIN (pin 8) */ #define RCAUXPIN8
I'm under the impression that pin D8 on my board is actually PIN 0
I am able to Rx a single channel on my board's pin D8 if I use the #define RCAUXPIN8 , but I cant Rx it as PPM. I'm thinking the #define RX_PC_INTERRUPT needs to be PCINT0 or PCINT8_vect. It's confusing me big time.
Yeah I can understand that little error... But you know, I've been in the electronics business since 1970... And I've Never seen an IC with a Pin 0... Something you'd have understood at a glance (I hope) had you looked at a schematic or a board itself (Uno)... or the Atmel ATMega data sheet. I do have to give you third credit... The 0 part is right... Just which one PB0?, PC0? or PD0? PB0, pin 14 isn't even on your short list of pins used or available. D8 is really pin 14
If I uncomment the #define RCAUXPIN8 and hook my PPM input to Pin labeled D8 on my board, nothing. If I turn off PPM and just hook one Rx channel to D8, i get PWM coming through.
I dont know how to figure out how to reassign everything to match my board. The MultiWii code defines that PPM is to be used, then it gets confusing with ports, ISR, Pins, rising edges, falling edges, timers. I'm hoping to understand that, then maybe I can understand where changes need to be made.
I think I'm going to cry. OK, I cant login to this site on the computer that has the code or schematics I have looked at. I log in and the forum page is just a blank.
I looked at the schematic for the ArduIMU and the pin labeled on the board as D8 and schematic says PB0/12.
[pre/**************************************************************************************/
/*************** PPM SUM RX Pin reading ********************/
/**************************************************************************************/
// attachInterrupt fix for promicro
#if defined(PROMICRO) && defined(SERIAL_SUM_PPM)
ISR(INT6_vect){rxInt();}
#endif
// PPM_SUM at THROTTLE PIN on MEGA boards
#if defined(PPM_ON_THROTTLE) && defined(MEGA) && defined(SERIAL_SUM_PPM)
ISR(PCINT2_vect) { if(PINK & (1<<0)) rxInt(); }
#endif
// Read PPM SUM RX Data
#if defined(SERIAL_SUM_PPM)
void rxInt() {
uint16_t now,diff;
static uint16_t last = 0;
static uint8_t chan = 0;
#if defined(FAILSAFE)
static uint8_t GoodPulses;
#endif][/pre]
So, if this is starting to make any sense, then when my board uses attachInterrupt(0, rxInt, RISING) it will listen for changes on the interrupt pin and send whatever it reads to execute rxInt(). If the edge is detected as RISING, that triggers the ISR?
I guess I'm trying to figure out what is the right ISR(INT????) if my pin is D8/PB0 ??
I did this to see if I can figure out the mapping of some of the pins on my board. I just cant figure out how to get it to recognize PPM on D8/PB0. I'm not writing anything new( somebody else already wrote MultiWii), just trying to adapt it to a different board with the same processor.
Here's some more that I changed to suit my layout:
From: #define SERVO_6_PINMODE pinMode(A3,OUTPUT); // TRI REAR - BI RIGHT #define SERVO_6_PIN_HIGH PORTD|= 1<<3; #define SERVO_6_PIN_LOW PORTD &= ~(1<<3);
To: #define SERVO_6_PINMODE pinMode(A3,OUTPUT); // TRI REAR - BI RIGHT #define SERVO_6_PIN_HIGH PORTC|= 1<<3; #define SERVO_6_PIN_LOW PORTC &= ~(1<<3);
I made this change because the info I have on my board says A3 is C3
I'm not saying I remotely understand any of this, but I managed to get the PPM signal to atleast cause some kind of output. The PPM is all Rx channels wrapped into one and that's what I see. The PWM display for the channel I have PPM connected jumps around from about 900 us to 2100 us. I think the problem is now how do I read that and break it up into individual channels?
now = micros();
sei();
diff = now - last;
last = now;
if(diff>3000) chan = 0;
else {
if(900<diff && diff<2200 && chan<RC_CHANS ) { //Only if the signal is between these values it is valid, otherwise the failsafe counter should move up
rcValue[chan] = diff; #if defined(FAILSAFE)
if(chan<4 && diff>FAILSAFE_DETECT_TRESHOLD) GoodPulses |= (1<<chan); // if signal is valid - mark channel as OK
if(GoodPulses==0x0F) { // If first four chanells have good pulses, clear FailSafe counter
GoodPulses = 0;
if(failsafeCnt > 20) failsafeCnt -= 20; else failsafeCnt = 0;
} #endif
}
chan++;
}
} #endif