Programming 3-way switches

More
27 Jul 2015 06:37 #36127 by SiXPaX
Programming 3-way switches was created by SiXPaX
Hey everyone!!!!!

I know most people will respond to read the manual.. well I DID!!!!
I have long ago installed 2x 3-way switches as well as an NRF module and I have also done the range mod on my Devo 7e!!!

It works absolutely awesome so far with one exception.... I can not figure out how to actually USE my 3 way switches!!! :(

I wired them with diodes and everything, they show up fine as SWA and SWB with 0, 1 and 2 positions working properly!!
(yes I properly configured them in the hardware.ini file)

One thing I have NEVER found is this.....

What do I need to do to use them????? Are they completely different than the stock 2 way switches????

For example, on my EOX I already have a model.ini file working great, but I would love to use the 3 way switches for flight modes etc. but I simply cannot figure out how to do this..... It works fine for the stock 2 way switches but after many attempts I cannot figure out how to set it up to use the 3 way switches....

Example.. this is my Ch5......
Works fine for switching between Sport and Expert modes....

[channel5]
max=100
min=0
template=simple
[mixer]
src=HOLD1
dest=Ch5
curvetype=min/max
points=0

In order to use the SWA and SWB switches, do I have to set up a mixer for each position of the switch???
What I mean is have a mixer for each position like this....

[channel5]
src=SWA0
max=100
min=-100
[mixer]
src=SWA0
dest=Ch5
curvetype=min/max
points=-100
[mixer]
src=SWA1
dest=Ch5
curvetype=min/max
points=0
[mixer]
src=SWA2
dest=Ch5
curvetype=min/max
points=100

If someone could PLEASE help me learn how to program these switches I would be VERY grateful!!!!!!
The HOLD and FMODE work absolutely fine but I cannot figure out the programming to use my 3 way switches.....

:oops: :( :angry:

Please Log in or Create an account to join the conversation.

More
27 Jul 2015 09:40 #36132 by dc59
Replied by dc59 on topic Programming 3-way switches
Here is my DEVO8S setting for EOX ch5.
You can change it into 7E format.

[channel5]
template=expo_dr
[mixer]
src=FMODE0
dest=Ch5
scalar=-100
curvetype=fixed
[mixer]
src=FMODE0
dest=Ch5
switch=FMODE1
scalar=0
curvetype=fixed
[mixer]
src=FMODE0
dest=Ch5
switch=FMODE2
curvetype=fixed

Please Log in or Create an account to join the conversation.

More
27 Jul 2015 15:33 #36157 by mwm
Replied by mwm on topic Programming 3-way switches
You need to use them as SWITCHES, not SRC's.

Try reading my tutorial on writing model files .

Do not ask me questions via PM. Ask in the forums, where I'll answer if I can.

My remotely piloted vehicle ("drone") is a yacht.

Please Log in or Create an account to join the conversation.

More
27 Jul 2015 17:22 - 27 Jul 2015 17:23 #36170 by SiXPaX
Replied by SiXPaX on topic Programming 3-way switches

dc59 wrote: Here is my DEVO8S setting for EOX ch5.
You can change it into 7E format.

[channel5]
template=expo_dr
[mixer]
src=FMODE0
dest=Ch5
scalar=-100
curvetype=fixed
[mixer]
src=FMODE0
dest=Ch5
switch=FMODE1
scalar=0
curvetype=fixed
[mixer]
src=FMODE0
dest=Ch5
switch=FMODE2
curvetype=fixed


So, technically if I replace all of the FMODE in this with SWA or SWB, in theory this should replace my FMODE 2-way switch with my added 3-way switch?
As I stated above, my HOLD and FMODE switches transmit just fine to the RX and FCB and I can see the inputs change in Cleanflight and can use them for switching modes etc. but 2x 2-way switches is quite insufficient for setting up flight modes and AH, PH and RTH... This is why I need to change Ch5 and 6 to my 3-way switches.

Actually, this is the exact mixer that enables HOLD and FMODE switch perfectly fine...

[channel5]
template=simple
[mixer]
src=HOLD0
dest=Ch5

[channel6]
template=simple
[mixer]
src=FMODE0
dest=Ch6

It registers them as about 1900 when in "0" position and about 1100 in "1" position in cleanflight GUI. I have seen 3-way switches on a different TX used for 1100-1500-1900 quite well and this is what I am attempting to do....


mwm wrote: You need to use them as SWITCHES, not SRC's.

Try reading my tutorial on writing model files .


MWM... I am already reading your guide thanks for doing all that work!!! But honestly I have had my 3-way switches installed for a few months now and I dont think I have been able to locate even one single "working" mixer for the new switches... Even in your tutorial the switches are being used quite differently, they are used to modify scalars for stick inputs to change the rates or AIL etc. For flight modes on my 2 quads I only need the switch position to be sent to the RX and the programming is done on the FCB side. So a simple mixer setup for this is what I am looking for, I understand how to program it to change RUD to an expo curve when FMODE1 is active and normal straight line curve at FMODE0, but this really does me no good for my setup.
Last edit: 27 Jul 2015 17:23 by SiXPaX.

Please Log in or Create an account to join the conversation.

More
27 Jul 2015 18:08 - 27 Jul 2015 18:10 #36174 by SiXPaX
Replied by SiXPaX on topic Programming 3-way switches
PROBLEM SOLVED!!!!! B)

After messing around for hours I finally got it figured out!!! Long story short, you cannot use "SWA0" and "SWA1", you must use a space between them like this... "SW A0" and "SW A1"!!!

Here is my final code and it works PERFECTLY!!!!! I get @1900 on SW A0, @1500 on SW A1, and @1100 on SW A2..... This opens up a LOT of programming choices for flight modes etc...

Again, I am using a fully modified Devo 7e TX, with a Naze32 FCB, Orange RX 6 channel R615X, and I am using cleanflight 1.9....

[channel5]
template=complex
[mixer]
src=SW A0
dest=Ch5
switch=SW A0
curvetype=fixed
[mixer]
src=SW A0
dest=Ch5
switch=SW A1
scalar=0
usetrim=0
curvetype=fixed
[mixer]
src=SW A0
dest=Ch5
switch=SW A2
scalar=-100
usetrim=0
curvetype=fixed

[channel6]
template=complex
[mixer]
src=SW B0
dest=Ch6
switch=SW B0
curvetype=fixed
[mixer]
src=SW B0
dest=Ch6
switch=SW B1
scalar=0
usetrim=0
curvetype=fixed
[mixer]
src=SW B0
dest=Ch6
switch=SW B2
scalar=-100
usetrim=0
curvetype=fixed


Thanks for all the help and hopefully this will help a lot of other people like myself in the future!!!!!!
Last edit: 27 Jul 2015 18:10 by SiXPaX.

Please Log in or Create an account to join the conversation.

More
27 Jul 2015 19:17 #36180 by DoubleQuad
Replied by DoubleQuad on topic Programming 3-way switches
Awesome!

Works for me too :)

Please Log in or Create an account to join the conversation.

More
27 Jul 2015 19:31 #36182 by mwm
Replied by mwm on topic Programming 3-way switches

SiXPaX wrote: [MWM... I am already reading your guide thanks for doing all that work!!! But honestly I have had my 3-way switches installed for a few months now and I dont think I have been able to locate even one single "working" mixer for the new switches... Even in your tutorial the switches are being used quite differently, they are used to modify scalars for stick inputs to change the rates or AIL etc. For flight modes on my 2 quads I only need the switch position to be sent to the RX and the programming is done on the FCB side.


Just for the record, there is a section on doing that. It coverts a number of ways to select from the three flight modes on the 200QX with the FMODE switch. Given what you just posted, you might want to read through it. For instance, the SRC on all your mixes is ignored because the curve type is fixed.

But yeah, it's hard to get the switches to work right if you don't have the names right. But if you look at the names on the Tx, they are "SW A0", SW A1", and so on, with the space. At least, they are with the latest nightly build.

Do not ask me questions via PM. Ask in the forums, where I'll answer if I can.

My remotely piloted vehicle ("drone") is a yacht.

Please Log in or Create an account to join the conversation.

More
27 Jul 2015 20:35 - 27 Jul 2015 20:42 #36187 by SiXPaX
Replied by SiXPaX on topic Programming 3-way switches

mwm wrote:

SiXPaX wrote: [MWM... I am already reading your guide thanks for doing all that work!!! But honestly I have had my 3-way switches installed for a few months now and I dont think I have been able to locate even one single "working" mixer for the new switches... Even in your tutorial the switches are being used quite differently, they are used to modify scalars for stick inputs to change the rates or AIL etc. For flight modes on my 2 quads I only need the switch position to be sent to the RX and the programming is done on the FCB side.


Just for the record, there is a section on doing that. It coverts a number of ways to select from the three flight modes on the 200QX with the FMODE switch. Given what you just posted, you might want to read through it. For instance, the SRC on all your mixes is ignored because the curve type is fixed.

But yeah, it's hard to get the switches to work right if you don't have the names right. But if you look at the names on the Tx, they are "SW A0", SW A1", and so on, with the space. At least, they are with the latest nightly build.


Perhaps that is my problem as I still am using a much older nightly build from May I believe!!! My other problem was that I was trying to do everything using notepad+ instead of using the mixers tab on the TX as it was very confusing to me!!! After spending the time to figure it out and testing it while plugged into the FCB I was then able to actually see the code that the TX made for me....

I guess I was trying to do it backwards......

I trust you that the SRC is ignored but seeing as I am still learning the mixers I thought it made sense the way I did it.... either way, it works perfectly for what I need it to do. I would rather have TOO much info in it than not enough.....

FWIW, I will continue reading through your instructional write up when I am done with this quad!!! :)


Lastly I wanted to add this......

I know it is always best to actually KNOW what you are doing and why, but I have seen a lot of people looking for help on this topic, yet the only answers anyone ever got was "READ the manual" or "READ this or that, blah blah blah". While it does not really TEACH them anything, why would absolutely NO ONE, including yourself simply post a quick code similar to the one I just posted???????

Again, it doesnt teach them anything, but it would actually get their TX working with the new 3-way switches, it would allow people in the future to use the code and not post another question on the same topic, and it would also be a starting point to actually learning how and why it works the way it does... At least for me, knowing quite a few different programming languages, actually seeing the code helps me understand it better!!!!
Last edit: 27 Jul 2015 20:42 by SiXPaX.

Please Log in or Create an account to join the conversation.

More
27 Jul 2015 22:23 #36190 by mwm
Replied by mwm on topic Programming 3-way switches
I have in the past posted short things. And I will probably keep doing that.

But I don't have a 7E, and have never had one with any extra switches, or had one after deviation had support for the extra switches in the standard build. So I can't post a simple example and know that it would work. I could post an example I know worked on my 10, and an explanation of why it works in hopes that would help you. But I did that so often I decided to write it up and put it all in one place. That way, I can correct it as time changes, let other people contribute, and not have to type it in over and over again with possible new errors each time.

Of course, none of that would have helped you because your problem wasn't from not understanding the mixers, but because you got the switch names wrong. That possibility never even occurred to me. Nuts, if you looked at the Wiki page listing the switch names, I got them wrong there myself (fixed now, and you deserve some thanks for that!). So I may have contributed to your problem. I don't remember where I got them from, though...

Do not ask me questions via PM. Ask in the forums, where I'll answer if I can.

My remotely piloted vehicle ("drone") is a yacht.

Please Log in or Create an account to join the conversation.

More
29 Jul 2015 03:48 #36284 by SiXPaX
Replied by SiXPaX on topic Programming 3-way switches

mwm wrote: I have in the past posted short things. And I will probably keep doing that.

But I don't have a 7E, and have never had one with any extra switches, or had one after deviation had support for the extra switches in the standard build. So I can't post a simple example and know that it would work. I could post an example I know worked on my 10, and an explanation of why it works in hopes that would help you. But I did that so often I decided to write it up and put it all in one place. That way, I can correct it as time changes, let other people contribute, and not have to type it in over and over again with possible new errors each time.

Of course, none of that would have helped you because your problem wasn't from not understanding the mixers, but because you got the switch names wrong. That possibility never even occurred to me. Nuts, if you looked at the Wiki page listing the switch names, I got them wrong there myself (fixed now, and you deserve some thanks for that!). So I may have contributed to your problem. I don't remember where I got them from, though...


Its all good!!!! I just found it really strange that I have only ever seen people asking questions on how to use the added 3-way switches, but I have never come across an actual answer.... And I have become quite good at google searching!!!

As I said, hopefully this thread will help many others as it has already helped DoubleQuad!!!

I have absolutely no problems with anyone "streamlining" the code I posted to do the same thing with less lines etc...

Please Log in or Create an account to join the conversation.

More
01 Aug 2015 13:20 #36430 by Mynci
Replied by Mynci on topic Programming 3-way switches
hi all
I am having the same issue.

I am using a devo10 with RX1002 receiver and CC3D atom FC for a mini 250 sized quad

when I use open pilot the auto setup sticks on the flight mode switch.

I read the manual but as I have updated to deviation firmware the menu's appear different and I can't find the "device" option to select and set up the flight mode switch.

I have tried several amended .ini files and none seem to work sometimes even causing the auto set up to stall at the rudder stage.

I'm clearly doing something wrong so any help or suggestions would be great, below is my .ini file WITHOUT any modifications, I know I need to add a section for [channel5] but what and where are driving me insane. this is my first build so struggling slightly with how to move on.
name=Model1
[radio]
protocol=DEVO
num_channels=8
fixed_id=574952
tx_power=10mW

[channel1]
template=simple
[mixer]
src=ELE
dest=Ch1

[channel2]
template=simple
[mixer]
src=AIL
dest=Ch2

[channel3]
template=simple
[mixer]
src=THR
dest=Ch3

[channel4]
template=simple
[mixer]
src=RUD
dest=Ch4

[trim1]
src=LEFT_V
pos=TRIMLV+
neg=TRIMLV-
[trim2]
src=RIGHT_V
pos=TRIMRV+
neg=TRIMRV-
[trim3]
src=LEFT_H
pos=TRIMLH+
neg=TRIMLH-
[trim4]
src=RIGHT_H
pos=TRIMRH+
neg=TRIMRH-
[timer2]
type=countdown
time=10
[safety]
Auto=min

Please Log in or Create an account to join the conversation.

More
01 Aug 2015 14:55 - 01 Aug 2015 14:56 #36432 by robocog
Replied by robocog on topic Programming 3-way switches
This is the one I use with my CC3D on a 250 FPV quad with a Devo 7E
the 2 x 3 way switches I have configured
left one is currently used for turning the lost vehicle alarm on and off (have to configure the extra output in OpenPilot for it to work)
right hand one is for selecting the 3 flight modes on the CC3D FC - switch up is mode 1, switch center is mode 2 and switch to the bottom is mode 3

They are set to output -125 0 and +125 for each position using a 3 way complex mix deadband for the 3 values

The pertinent bit is

[channel5]
failsafe=125
template=complex
[mixer]
src=SW A0
dest=Ch5
switch=SW A0
scalar=-125
curvetype=fixed
[mixer]
src=SW A0
dest=Ch5
switch=SW A1
scalar=0
curvetype=fixed
[mixer]
src=SW A0
dest=Ch5
switch=SW A2
scalar=125
curvetype=fixed

[channel6]
failsafe=125
template=complex
[mixer]
src=SW B0
dest=Ch6
switch=SW B0
scalar=-125
curvetype=fixed
[mixer]
src=SW B0
dest=Ch6
switch=SW B1
scalar=0
curvetype=fixed
[mixer]
src=SW B0
dest=Ch6
switch=SW B2
scalar=125
curvetype=fixed
end of file

For completeness - here is the full ini I use

name=FPV250
mixermode=Advanced
icon=FPV250.BMP
type=plane
[radio]
protocol=DSM2
num_channels=7
tx_power=150mW

[channel1]
safetysw=Virt1
safetyval=-100
failsafe=-125
template=simple
[mixer]
src=THR
dest=Ch1

[channel2]
template=simple
[mixer]
src=ELE
dest=Ch2

[channel3]
failsafe=0
template=simple
[mixer]
src=AIL
dest=Ch3

[channel4]
template=simple
[mixer]
src=RUD
dest=Ch4

[channel5]
failsafe=125
template=complex
[mixer]
src=SW A0
dest=Ch5
switch=SW A0
scalar=-125
curvetype=fixed
[mixer]
src=SW A0
dest=Ch5
switch=SW A1
scalar=0
curvetype=fixed
[mixer]
src=SW A0
dest=Ch5
switch=SW A2
scalar=125
curvetype=fixed

[channel6]
failsafe=125
template=complex
[mixer]
src=SW B0
dest=Ch6
switch=SW B0
scalar=-125
curvetype=fixed
[mixer]
src=SW B0
dest=Ch6
switch=SW B1
scalar=0
curvetype=fixed
[mixer]
src=SW B0
dest=Ch6
switch=SW B2
scalar=125
curvetype=fixed

[virtchan1]
name=T HOLD
template=complex
[mixer]
src=Virt1
dest=Virt1
usetrim=0
curvetype=min/max
points=0
[mixer]
src=Ch1
dest=Virt1
offset=-1
usetrim=0
muxtype=add
[mixer]
src=AIL
dest=Virt1
switch=HOLD1
usetrim=0
curvetype=fixed

[virtchan2]
name=CH5
template=complex
[mixer]
src=AIL
dest=Virt2
usetrim=0
curvetype=expo
points=0,0

[trim1]
src=LEFT_V
pos=TRIMLV+
neg=TRIMLV-
[trim2]
src=RIGHT_V
pos=TRIMRV+
neg=TRIMRV-
[trim3]
src=LEFT_H
pos=TRIMLH+
neg=TRIMLH-
value=-1,0,0
[trim4]
src=RIGHT_H
pos=TRIMRH+
neg=TRIMRH-
[timer1]
type=countdown
[timer2]
type=countdown
src=Ch1
time=300
[telemalarm2]
source=Loss
value=0
[telemalarm3]
source=Volt2
value=0
[telemalarm4]
source=FadesB
value=0
[safety]
Auto=min
[gui-128x64]
V-trim=59,10,1
H-trim=5,59,3
V-trim=65,10,2
H-trim=74,59,4
Small-box=2,22,Ch1
Small-box=2,31,Timer1
Small-box=2,40,Timer2
Model=75,20
Battery=102,1
Toggle=4,10,0,9,0,HOLD
Toggle=13,10,1,64,128,SW A
Toggle=22,10,2,65,129,SW B
Toggle=31,10,0,6,0,FMODE
Toggle=40,10,0,0,0,None
TxPower=102,7
quickpage1=Telemetry monitor


Regards
Rob
Attachments:
Last edit: 01 Aug 2015 14:56 by robocog.

Please Log in or Create an account to join the conversation.

More
01 Aug 2015 17:12 #36438 by Mynci
Replied by Mynci on topic Programming 3-way switches
thanks, unfortunately I am not 100% sure what to change from the devo7 to make applicable to the devo 10. I have tried adding the [channel5] code from another source but it still wouldn't work and I must have done something wrong as the set up stuck at the rudder input 1 earlier :(
I can tell you it's been driving me mad today.
This is my first build and set up so have limited knowledge but trying to learn albeit slowly

Please Log in or Create an account to join the conversation.

More
01 Aug 2015 18:27 #36442 by mwm
Replied by mwm on topic Programming 3-way switches
+Mynci, what you're doing wrong is using the Standard gui. It's designed for dealing with CP heli's with flybars instead of flight controllers, and doesn't have any facilities for dealing with a modern flight controller. Which is why you can't find the switch you're looking for.

if you really want to use the standard GUI, you can use the "gyro" facilities for it. Use "Switch assignment" to set the Gyro sense switch to whatever switch you want to use. Make sure that NOTHING ELSE is using that switch. The default is "MIX" which should work fine, but feels odd to me. Then go to "Gyro Sense" and set the channel - looks like you want "GEAR/Ch5" - and then set the values to 100%, 0, and -100% as you like.

Frankly, if your current model isn't working, I'd throw it out and start over using the advanced GUI. The tutorial I referenced earlier will walk you through setting up a 200QX, which uses the channel five for flight mode like you're trying to do. You might not be able (or want) to use the "stagility mode" and automatic in initialization, but that much should work. It's done with a Devo 10 as well.

Do not ask me questions via PM. Ask in the forums, where I'll answer if I can.

My remotely piloted vehicle ("drone") is a yacht.

Please Log in or Create an account to join the conversation.

More
24 Apr 2016 23:04 #47124 by hudibras
Replied by hudibras on topic Programming 3-way switches

robocog wrote: This is the one I use with my CC3D on a 250 FPV quad with a Devo 7E
the 2 x 3 way switches I have configured
left one is currently used for turning the lost vehicle alarm on and off (have to configure the extra output in OpenPilot for it to work)
right hand one is for selecting the 3 flight modes on the CC3D FC - switch up is mode 1, switch center is mode 2 and switch to the bottom is mode 3

They are set to output -125 0 and +125 for each position using a 3 way complex mix deadband for the 3 values


The pertinent bit is

[channel5]
failsafe=125
template=complex
[mixer]
src=SW A0
dest=Ch5
switch=SW A0
scalar=-125
curvetype=fixed
[mixer]
src=SW A0
dest=Ch5
switch=SW A1
scalar=0
curvetype=fixed
[mixer]
src=SW A0
dest=Ch5
switch=SW A2
scalar=125
curvetype=fixed

[channel6]
failsafe=125
template=complex
[mixer]
src=SW B0
dest=Ch6
switch=SW B0
scalar=-125
curvetype=fixed
[mixer]
src=SW B0
dest=Ch6
switch=SW B1
scalar=0
curvetype=fixed
[mixer]
src=SW B0
dest=Ch6
switch=SW B2
scalar=125
curvetype=fixed
end of file

Regards
Rob


Thanks, just what I needed

Please Log in or Create an account to join the conversation.

More
26 Apr 2016 11:17 #47225 by Fernandez
Replied by Fernandez on topic Programming 3-way switches
Take care when using with a Frsky ppm receiver d4r-ii, the ppm can overflow and can crash your vehicle, when all inputs at max range or close to max range.

So channel 1-4, set to 125% throw, 1000-2000ms, 1500neutral. (required for Betaflight/Cleanfligtht, otherwise can't arm)
Switches set them to 50% throw, -50-0-+50%, it does not harm to make range smaller, as in the Flight controller you have to set the switch detections. plenty of resolution.

Please Log in or Create an account to join the conversation.

More
27 Apr 2016 00:06 #47278 by hudibras
Replied by hudibras on topic Programming 3-way switches

Fernandez wrote: Take care when using with a Frsky ppm receiver d4r-ii, the ppm can overflow and can crash your vehicle, when all inputs at max range or close to max range.

So channel 1-4, set to 125% throw, 1000-2000ms, 1500neutral. (required for Betaflight/Cleanfligtht, otherwise can't arm)
Switches set them to 50% throw, -50-0-+50%, it does not harm to make range smaller, as in the Flight controller you have to set the switch detections. plenty of resolution.


I'm using AR7700 1-4 at 100% it ARM's allright. You are right I'll change the scale just in case. Thanks

Please Log in or Create an account to join the conversation.

More
04 Dec 2016 15:13 #56513 by jr128128
Replied by jr128128 on topic Programming 3-way switches
Then there is this. Best explanation of tx switch programming i have found.

Please Log in or Create an account to join the conversation.

Time to create page: 0.057 seconds
Powered by Kunena Forum