I found a discussion for getting 5 switch positions out of channel 5 on a DX6i and it also works on my JR XP6102. What I want to do is add 2 more switchable modes to Ardupilot 2.7.1 which currently uses these 3 position outputs from channel 5. I looked in Ardupilot and see it uses a Case statement to switch between 3 modes, but I cant find anywhere where the low level stuff for channel 5 is even described.
It'd be nice if all I had to do was add 2 more #defines and 2 more case statements, but I get the feeling that the PWM values of the additional switch positions need to be stated somewhere.
Any clues where I need to make some changes.?
Tags:
Permalink Reply by Harry on July 16, 2012 at 10:04am Is this written into the code that goes into the ATtiny chip? That would be an obstacle if so.
Permalink Reply by Harry on July 16, 2012 at 11:19am What I'm thinking is come up with a way to read a sequence of switch positions. If you switch from position_3 to position_2 and not to position_1 then position_2 takes on a new mode definition. If it then switches again to position_3 then position_3 is a new mode. Switching to position_1 starts it all over.
If this seems possible and sounds like a standard kind of code structure, then I could use the input.
Permalink Reply by Jake Stew on July 16, 2012 at 12:26pm If the legacy gear doesn't support the current mode method then just adding it in would be the easiest solution.
You're over complicating things. All you have to do is mix your 2 position switch with your 3 position switch. That way you get 6 different PWM values based on the 6 possible switch combinations. You don't need to write complicated code or waste 2 channels for something this simple.
Permalink Reply by Harry on July 16, 2012 at 12:46pm I mix my 2 channels on the Tx just fine. The code for Ardupilot 2.7.1 only recognizes 3 positions. That's a code issue. It's legacy hardware and software and only someone who wants to continue using it will even care about the issue. The ATtiny plays a role. I dont have a way to rewrite attiny code that is only available as a .hex, so I'm looking for a way to interpret the switch position without going into the Attiny code. It's not a waste of channels or time to me.
You might not have a use and if so then I dont understand why you even respond in a way that ignores the facts or is just plain wrong.
Permalink Reply by Jake Stew on July 16, 2012 at 1:03pm It seems like you don't understand what you're trying to do. That could be because I don't understand the legacy problem. You're talking about 2 generation old hardware, so you probably know more about it than me.
In any case you asked for advice and I gave you some. If it wasn't helpful I'm sorry. At least I bumped your post a couple times.
You seem like you're worried about not being able to change code in the PWM encoder? You shouldn't have to do that and the source is available anyways.
Permalink Reply by Harry on July 16, 2012 at 1:33pm I understand that the little chip only does what it's told. Ardupilot 2.7.1 only knows about 3 positions on the switch the way it is currently written. I'm looking for a way to tell it what the other positions on channel 5 represent. I cant find the source code for ATtiny and I dont read .hex.
If someone already wrote 6 positions into the ATtiny, it's unknown to me. That would make it easy. That isnt the case(pun intended) though.
Ardupilot_2_7.cpp: In function 'void read_control_switch()':
control_modes:32: error: 'POSITION_4' was not declared in this scope
Permalink Reply by Harry on July 16, 2012 at 3:59pm I was right that it only knows what you tell it. My first instinct was correct, add some #defines and add two more case statements. I still dont know where in the 2.7.1 code the channel 5 PWM gets defined. Is POSITION_ a reserved word or something and some library handles it by seeing how many POSITION_# you have defined?
Permalink Reply by Jake Stew on July 16, 2012 at 10:40pm AFAIK the tiny is just a PPM encoder. It doesn't do anything other than take the PWM inputs and feed them in PPM format to the processor. That's why I've never heard of anyone messing with the code for it. Those old source versions still exist though if you wanted to mess with them.
This might shed some light on the issue...
http://diydronesafety.com/content/118-history-paparazzi-ppm-encoder...
Permalink Reply by Harry on July 17, 2012 at 1:28pm Here's the switch statement from the ATtiny code. It has a comment that says it can be changed as wanted, but I dont know what to change it to. What stands out to me is there are only 3 cases that depend on 3 positions of the channel 5 switch. I also dont know exactly what it sends back to the Atmega.
switch(state)//System state, you can change this as you desire
{
case 0: //This switch pulled down...
MUX_RADIO_CONTROL; //Puts the pins low in state 0
MODE_LED_OFF;
timer_toggle=0;
break;
case 1: //This switch middle position
if(timer_toggle>=2000)
{
MODE_LED_OFF;//Put just the mux pin HIGH
MUX_ATMEGA_CONTROL;
timer_toggle=3000; //Just void an overflow
}
break;
case 2: //Switch Up position...
if(timer_toggle>=2000)
{
MODE_LED_ON; //Puts both pins high
MUX_ATMEGA_CONTROL;
timer_toggle=3000;//Just void an overflow
}
break;
Permalink Reply by Adam smith on January 17, 2013 at 1:34am thanks for sharing this nice information here friends. it really help me. and i found the answer for what i came for.
adam smith
adam.smith402@hotmail.com
Season Two of the Trust Time Trial (T3) Contest has now begun. The fourth round is an accuracy round for multicopters, which requires contestants to fly a cube. The deadline is April 14th.48 members
51 members
1299 members
24 members
111 members
© 2013 Created by Chris Anderson.
Powered by
