Combining two switches for a function

More
06 Nov 2015 17:59 #39663 by justme
Hello everybody,
I'm quite a newbie on deviation and now ran into a problem where I could not find a way to make it work for me in the desired way.
I've been using deviation for my BNF Blade helis with pre-defined model configs from the forum (thanks to all contributors), but now I'd like to also use my Devo 10 for my sailplanes - and here I have a point where I cannot go further: I'd like to have crow brake or butterfly enabled with a combination of two switches, basically as an AND function: I'm using three-position switch MIX for deploying flaps in two positions, and only if they're fully deployed (MIX=2) a setting a second switch (GEAR) to 1 position shall raise both ailerons (crow brake or butterfly), mainly by moving the zero point of the aileron curve - if any of the switches is not in the defined positions ailerons shall act normally.

Bonus question: I'd also like to make full flap deployment (MIX=2) depending on THR=0 - so basically what I'm missing is a way to set multiple conditions to enable a mixer. I'm pretty sure this is possible quite easy, but after reading the manual, mwm's tutorial on writing a model.ini, mattygerman's tutorial how to setup a complex mixer/template and several other tutorials/forum posts, I still can't get it to work as desired. Could somebody please help me?

Second bonus: all this stuff shall then also be dependant on selected flight mode (FMOD switch), which I'd like to switch between a config for start/landing, one for thermal soaring and one for speed flight.

I'm using latest nightly v4.0.1.-583-c486, my transmitter is a devo 10
Thanks in advance,
Edgar

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

More
07 Nov 2015 03:04 - 07 Nov 2015 03:05 #39680 by Cereal_Killer
Replied by Cereal_Killer on topic Combining two switches for a function
I'm not totally sure what you're asking but take a look a this for combining one 2-way and one 3-way into a single "4-way" switch.

deviationtx.com/forum/model-requests/467...3-way-into-one-4-way

Taranis X9E | DEVO 10 | Devo U7E | Taranis Q7

What I do in real life: rivergoequestrian.com/
Last edit: 07 Nov 2015 03:05 by Cereal_Killer.

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

More
07 Nov 2015 07:38 #39683 by mwm
Replied by mwm on topic Combining two switches for a function
There are a number of different ways to combine switches and/or channels in an "and" condition. But in order to get normal behavior when the all the conditions aren't true, you need to use a virtual channel to do the and. Then add a mixer to the aileron mix that uses the virtual channel as a switch, with a fixed curve for the appropriate output value to deploy the crow brake. That way, when your virtual channel goes on, it deploys. Otherwise, you get the normal behavior.

The easiest way to do an and is to string together mixers with the switches as SRC and a MUX type of "max". So for MIX2 and GEAR1, you'd have two mixers with MIN/MAX curve (if you read the tutorial, you'll know I like those for switch sources) and a SRC of GEAR1 and MIX2, respectively. The first one has a mux type of REPLACE, and the second of MIN. So the only way to get a value of 100 for on is if both of the switches are on, thus having a value of 100 making it the min.

Adding THR=0 as a condition is then straightforward - add a mixer that is only on if THR=0. Are you sure you want 0? That's the mid-stick value, and -100 is the minimum value. Anyway, to get only 0 on you want an ABS curve, scale of -100 offset of 1 (from memory - you may want to check the offset). That way this mixer will only be >0 and hence on if THR=0. And the MIN mux type will get the behavior you desire.

With that, I think you can figure out how to make it also depend on FMODE.

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
07 Nov 2015 08:00 #39685 by justme
Replied by justme on topic Combining two switches for a function
Hello,
thanks for your reply! Basically, this seems to be similar to my poor results when trying to get the setup working - if I understand correctly, you needed an OR conjunction, meaning, only operating the 2-way switch would already have an effect. I'd like to have two switches AND combined - the 2-way switch itself shall not have any effect unless the 3-way-toggle is in a defined condition (which itself then shall only have an effect if THR is at 0%).

The desired effect is a landing procedure for a powered sailplane with four leaflets - first needing to power off the engine (THR=0), then deploy flaps fully (MIX=2) and last raising both ailerons (GEAR=1) for crow brake - and, in case a go-around would be necessary, raising THR shall directly set the ailerons to normal position and retract flaps to first deployed value (=MIX=1)

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

More
07 Nov 2015 08:26 #39686 by justme
Replied by justme on topic Combining two switches for a function

mwm wrote: There are a number of different ways to combine switches and/or channels in an "and" condition. But in order to get normal behavior when the all the conditions aren't true, you need to use a virtual channel to do the and. Then add a mixer to the aileron mix that uses the virtual channel as a switch, with a fixed curve for the appropriate output value to deploy the crow brake. That way, when your virtual channel goes on, it deploys. Otherwise, you get the normal behavior.


Thank you Mike! The idea of using a virtual channel for getting an AND combined function was what I tried yesterday - but (most probably due to my lack of experience with deviation) everything I got was some strange OR combinations where sometimes even disabling the function needed a dedicated combination of the two switches I use.
Just one remark: you mentioned applying a fixed curve to the AIL mix - wouldn't this then mean that I cannot control the ailerons with the stick any more when crow brake is enabled? I was thinking of just moving the 0 point of the normal aileron mix to a given value (say 60% up), but letting them still being controllable with their normal expo curve via stick.

mwm wrote: The easiest way to do an and is to string together mixers with the switches as SRC and a MUX type of "max". So for MIX2 and GEAR1, you'd have two mixers with MIN/MAX curve (if you read the tutorial, you'll know I like those for switch sources) and a SRC of GEAR1 and MIX2, respectively. The first one has a mux type of REPLACE, and the second of MIN. So the only way to get a value of 100 for on is if both of the switches are on, thus having a value of 100 making it the min.


Again, thanks! This seems to be the solution I did not get to figure out on my own - I'll try this as soon as my TX batteries are charged again!

mwm wrote: Adding THR=0 as a condition is then straightforward - add a mixer that is only on if THR=0. Are you sure you want 0? That's the mid-stick value, and -100 is the minimum value. Anyway, to get only 0 on you want an ABS curve, scale of -100 offset of 1 (from memory - you may want to check the offset). That way this mixer will only be >0 and hence on if THR=0. And the MIN mux type will get the behavior you desire.


You're right, I forgot the %-sign - THR dependency shall be to THR off=-100, not mid-stick position. Do I understand correctly this would require another virtual channel to be set up for replacing my currently configured MIX=2 correlating flaps=100%? And coming back to the first question, I'd then need to take this mixer's output instead of directly MIX=2 as an input for my virtual channel for the crow function, getting all the functions chained one after another? This would then imply the nice behaviour that for cancelling an approach, I'd only need to disarm my THR HOLD (I have intentionally not configured sticky throttle hold) with the gas stick remaining in full position.

mwm wrote: With that, I think you can figure out how to make it also depend on FMODE.


Yes, thank you again very much! Looks like my first try with an own config would result in a rather complex one...

Best regards,
Edgar

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

More
07 Nov 2015 14:45 #39704 by mwm
Replied by mwm on topic Combining two switches for a function

justme wrote: Just one remark: you mentioned applying a fixed curve to the AIL mix - wouldn't this then mean that I cannot control the ailerons with the stick any more when crow brake is enabled? I was thinking of just moving the 0 point of the normal aileron mix to a given value (say 60% up), but letting them still being controllable with their normal expo curve via stick.


No, but I left out the details for that because I wasn't sure what "move the zero point" meant. You'll have a mixer on the aileron channel with the switch being the virtual channel that implements the AND. I assume it's on the aileron channel because deploying the crow brake seems to involve that channel. You can set it to a fixed value with a fixed curve and a mux type of replace. You can add a fixed value (my best guess at what "move the zero point" means) with a fixed curve and a mux type of add. If the value isn't fixed, you can use the appropriate curve type. etc.

You're right, I forgot the %-sign - THR dependency shall be to THR off=-100, not mid-stick position. Do I understand correctly this would require another virtual channel to be set up for replacing my currently configured MIX=2 correlating flaps=100%? And coming back to the first question, I'd then need to take this mixer's output instead of directly MIX=2 as an input for my virtual channel for the crow function, getting all the functions chained one after another? This would then imply the nice behaviour that for cancelling an approach, I'd only need to disarm my THR HOLD (I have intentionally not configured sticky throttle hold) with the gas stick remaining in full position.


You don't need another virtual channel. You need one virtual channel to act as a switch. That virtual channel needs one mixer for each condition: one for the MIX switch, one for the GEAR switch, one for THR, one for FMODE. The first mixer uses a muxtype of MIX, the rest of REPLACE. You can think of it as:
(((MIX2 and GEAR1) and THR = -100%) and FMODE2)

where each and is done by one mixer.

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
08 Nov 2015 12:09 - 08 Nov 2015 12:10 #39733 by justme
Replied by justme on topic Combining two switches for a function

mwm wrote: No, but I left out the details for that because I wasn't sure what "move the zero point" meant. You'll have a mixer on the aileron channel with the switch being the virtual channel that implements the AND. I assume it's on the aileron channel because deploying the crow brake seems to involve that channel. You can set it to a fixed value with a fixed curve and a mux type of replace. You can add a fixed value (my best guess at what "move the zero point" means) with a fixed curve and a mux type of add. If the value isn't fixed, you can use the appropriate curve type. etc.


Thank you very much again - programmed my VIRT01 yesterday the way you suggested and it works exactly like I wanted to!
Yes, it's on the AIL channels as crow brake simply means 'ailerons up, flaps down' to have a maximum amount of drag combined with highest possible camber to avoid stall - the effect on my Radian Pro is that you could simply grab the plane with you hands out of the air as it's nearly standing still.
What I meant with 'moving the zero point' is that what I did was a mux=replace on activation with my normal curve of EXPO 30, but Offset -80 resp +80 for the two aileron channels, so it's mainly as if I'd change the middle position of the servos (esp. with expo active around the new middle position)

You don't need another virtual channel. You need one virtual channel to act as a switch. That virtual channel needs one mixer for each condition: one for the MIX switch, one for the GEAR switch, one for THR, one for FMODE. The first mixer uses a muxtype of MIX, the rest of REPLACE. You can think of it as:

(((MIX2 and GEAR1) and THR = -100%) and FMODE2)

where each and is done by one mixer.


But here I'm a little bit lost again - how can I use just one mixer for all my combinations if I'd need the intermediate results also for activating functions?
I'd like to have the following
(FMODE0 and THR= -100% and MIX2) = FLAPS100% (only deploy flaps (on channel 5) fully if flight mode is normal and engine is off)
FLAPS=100% AND GEAR1 =CROW (only activate crow brake (raising ailerons on channel 2 and 6) if flaps are already fully deployed)

As you can see, although my understanding of deviation gets better day to day, I'm still at the very beginning of the learning process...

But now, I'll get outside and go flying - currently, we have a return of spring in the mid of November here in Germany - about 68° daytime temperature and still around 64° at 11PM yesterday evening, the roses in my garden are blooming, bees and butterflies fly around, it's time for preparing a BBQ and enjoy the sun ;)

Best regards,
Edgar
Last edit: 08 Nov 2015 12:10 by justme.

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

More
08 Nov 2015 17:58 #39743 by mwm
Replied by mwm on topic Combining two switches for a function

justme wrote: But here I'm a little bit lost again - how can I use just one mixer for all my combinations if I'd need the intermediate results also for activating functions?
I'd like to have the following


That's my bad. I hadn't realized you needed the intermediate results. Yes, you'll needed a virtual channel for each result you need. Note that you can get extra "virtual" channels by setting the number of output channels to higher than you actually use and using those extras. You have to do that to get to them in the mixer. After you get them set up, you can turn the number of output channels back down.

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
09 Nov 2015 06:59 - 09 Nov 2015 07:00 #39764 by justme
Replied by justme on topic Combining two switches for a function

mwm wrote:
That's my bad. I hadn't realized you needed the intermediate results. Yes, you'll needed a virtual channel for each result you need. Note that you can get extra "virtual" channels by setting the number of output channels to higher than you actually use and using those extras. You have to do that to get to them in the mixer. After you get them set up, you can turn the number of output channels back down.


OK, thanks again - then I think now I got the idea how to do it.

BTW, I saw in one of the development boards that you were thinking of a principle to define flight modes independently and make mixers depending on the selected flight mode directly - this would be something I'd appreciate indeed as it would really reduce the amount of needed virtual channels when you want to define functions depending on the flight mode, as far as I understand until now. Is this something you still follow up or is it more a dead idea?

Best regards,
Edgar
Last edit: 09 Nov 2015 07:00 by justme.

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

More
09 Nov 2015 13:22 - 09 Nov 2015 13:23 #39768 by mwm
Replied by mwm on topic Combining two switches for a function

justme wrote: I saw in one of the development boards that you were thinking of a principle to define flight modes independently and make mixers depending on the selected flight mode directly - this would be something I'd appreciate indeed as it would really reduce the amount of needed virtual channels when you want to define functions depending on the flight mode, as far as I understand until now. Is this something you still follow up or is it more a dead idea?


I moved it to the back burner because I never figured out a way to do that that I thought worked noticeably better than what we have now. I tinker with it every now and then, but haven't even gotten close enough to start writing code. There are a number of alternative ways of doing this that become possible if some of the things on the horizon ever get done.

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.
Last edit: 09 Nov 2015 13:23 by mwm.

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

More
09 Nov 2015 16:02 #39775 by justme
Replied by justme on topic Combining two switches for a function

mwm wrote:
I moved it to the back burner because I never figured out a way to do that that I thought worked noticeably better than what we have now. I tinker with it every now and then, but haven't even gotten close enough to start writing code. There are a number of alternative ways of doing this that become possible if some of the things on the horizon ever get done.


If this would come back on the agenda, it would be something I'd really appreciate much - maybe also the copter flyers could find the useful? As far as I know (I don't own any copters, I'm more a scale-flyer), especially when using on-board cameras there might be a need to completely change a transmitter's functional layout depending on flight mode, and as I just learned this would need heavy usage of virtual channels ATM for getting the flight mode dependency.
I would think of something like a general configuration item 'Flight Mode Configuration' where number and activation of chosen Flight Modes could be set, and then in the mixer setup an additional field 'Use in Flight mode xx-yy'.

BTW, one more question: with the virtual channel setup, it should be also possible to get an edge-triggered switch (meaning, a switch where not BEING in a defined state but BEING SWITCHED INTO a defined state would trigger a function), if I understand correctly the examples of switching flight modes in your tutorial?

Best regards,
Edgar

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

More
10 Nov 2015 00:23 #39792 by mwm
Replied by mwm on topic Combining two switches for a function
Yeah, keeping multiple things synced up on flight modes was what prompted me to propose that in the first place.

And yes, you ought to be able to have an edge-triggered switch. I generally just use buttons instead of switches for those, and have never figured out exactly how to make it work with switches.

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
15 Nov 2015 22:22 #40093 by justme
Replied by justme on topic Combining two switches for a function

mwm wrote:

justme wrote: But here I'm a little bit lost again - how can I use just one mixer for all my combinations if I'd need the intermediate results also for activating functions?
I'd like to have the following


That's my bad. I hadn't realized you needed the intermediate results. Yes, you'll needed a virtual channel for each result you need. Note that you can get extra "virtual" channels by setting the number of output channels to higher than you actually use and using those extras. You have to do that to get to them in the mixer. After you get them set up, you can turn the number of output channels back down.


Sorry to come back again to this topic, but I still have a little problem here: I have programmed the second virtual channel for the dependency of the full flap deployment to engine stopped, and here I cannot get it to work fully: I chose CH1 (not THR) as source for the second page of the complex mixer, but regardless if safety switch is set to on or off, I can see the value of CH1 changing here, leading to the problem that the dependency always exists to the stick position, not to the real output of CH1. Is there a chance to get the real output value as mixer input without the need of setting up another complex mixer for THR safety or is this maybe even a bug in deviation? I do not understand why at this place not the real channel output is taken into account (which stays on it's safety value of -100 all the time in channel monitor when safety switch is on).

Best regards, Edgar

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

More
16 Nov 2015 02:47 #40104 by mwm
Replied by mwm on topic Combining two switches for a function
I believe (but can't check right now) that channel values used in other channels is the channel value before the final set of checks: channel min/max, trim and safety values. Since the latter can be simulated in the mixer, I'd say it's not a bug but a feature.

What you need to do is add a mixer to channel one. Fixed curve, value is the safety value, switch is the safety switch. You can then turn off the safety switch in the channel settings.

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.

Time to create page: 0.060 seconds
Powered by Kunena Forum