Even more Fuzzy Logic!

I did a how-to for a forum-user for fuzzy logic with a function of “activate when BOTH rudder and elevator is over 90%, deactivate when BOTH rudder and elevator is under 90%” in the previous fuzzy logic yesterday. You can find it here.

He did not mention he needed somewhat different function of “activate when BOTH rudder and elevator is over 90%, deactivate when BOTH rudder and elevator is under 50%”.

The difference is the different %-values on activating and deactivating the switch. I first thought this would make it very hard but after a small moment of brain-teasing it came apparent that this is not the case, it’s pretty simple actually. Let’s get to it.

Requirements?

We need to think a second what we need, fairly simple actually:

  • Push elevator-stick over 90% and use that as a switch.
  • Push rudder-stick over 90% and use that as a switch.
  • Push elevator-stick over 50% and use that as a switch.
  • Push rudder-stick over 50% and use that as a switch.
  • Logical switch active when first two conditions apply
  • Logical switch active when last two condition apply
  • Logical switch to tie it all up to one function

It’s pretty clear we need a lot of logical switches here, if only LUA would be here already…

How to

Note: I’m using a Mode 2 radio, your switch numbering (P2/P3)may be different!

First, make a  logical switch, name it as “Snap1” with the function “if rudder stick is over 90% positive or negative”. This translates to “P3 less than -90% proportional, centralized and reversed” OR “P3 less than -90% proportional and centralized”. Note that the first is reversed!

Screen000

Control 1 is reversed:

Screen001

Control 2 is not:

Screen002

You can verify correct settings by moving rudder over 90% to left or right, logical switch “Snap1” is active.

Note: The definition of “more” or “less” depends on the direction of stick when you activate the function.

Ok, that was Snap 1. We need more. Make another logical switch, name it “Snap2”. This needs to be active “If elevator stick is over 90% positive or negative”. This translates to “P2 more than -90% proportional, centralized and reversed” OR “P2 more than -90% proportional and centralized”. Note that the first is again reversed!

Screen003

Control 1 is again reversed:

Screen004

Control 2 is not:

Screen005

You can verify correct settings by moving elevatorover 90% to left or right, logical switch “Snap2” is active.

Now comes the part where this how-to is different from the first part. We need two logical switches but with 50% activation point. User needed activation on 90% but deactivation on 50% remember?

So, just as above, make two more logical switches, only difference is the percentage, it’s 50% here.

First the rudder, exactly same as the one above, just the 90% changed to 50%:

Screen006

Then the elevator in same fashion:

Screen007

You can verify correct settings by moving rudder over 90% to left or right, logical switch “Snap3” is active, moving elevator over 50% makes “Snap4” active.

Let’s get fuzzy!

This is where we are beginning to put things together.

We need three fuzzy conditions:

  • When BOTH sticks are over 90%
  • When BOTH sticks are over 50%
  • When BOTH stick have been over 90% and come down below 50%

Might be confusing but actually it’s not. Let’s get on with it.

Make a logical switch with condition of “both sticks over 90% in any combination”, since we need it to remain active until BOTH stick are below the point we need to use MULTI instead of AND or OR statement. That results in condition of “Snap1 centralized and proportional over 0% MULTI Snap2 centralized and proportional over 0%”:

Screen008

Now you can test this. Move your rudder all the way to either direction, you’ll see the value change from X to 0, same should happen if you move your elevator all the way up or down. If you move BOTH stick to over 90% at the same time you’ll notice this logical switch goes to ON instead of 0 or OFF.

Ok, that was the 90% part, we need exactly the same for 50% done in the same way.

Make a logical switch with condition of “both sticks over 50% in any combination”, since we need it to remain active until BOTH stick are below the point we need to use MULTI instead of AND or OR statement. That results in condition of “Snap3 centralized and proportional over 0% MULTI Snap4 centralized and proportional over 0%”:

Screen009

Now you can test this. Move your rudder over 50% to either direction, you’ll see the value change from X to 0, same should happen if you move your elevator 50% up or down. If you move BOTH stick to over 50% at the same time you’ll notice this logical switch goes to ON instead of 0 or OFF.

Make the fuzzy magic!

Ok, where are we now? We have a working solution for 90% and 50%, what we need to tie those two together, in a warm and fuzzy way of course. User needed “activate over 90% and deactivate under 50%”. Simply put, this translates to “activate over 90% MULTI activate over 50%”, right?

Make yet another logical switch with the already fuzzy logical switches Snap5 and Snap6, both centralized and proportional, both with the condition of X>0%

Screen010

Now make a few tests, this logical switch is OFF when stick are centered. Both stick over 50% makes the switch to be ZERO, stick over 90% makes it to ON.

As a last thing, make the last logical switch, having only the logical switch above as control, again proportional and centralized, with condition “X over 0%”:

Screen011

Now test the function. This last switch can be only ON or OFF. The ON-state is activated when BOTH sticks are over 90%, the OFF-state activates when BOTH sticks are under 50%, just as user requested. This last logical switch is the one to be used to control whatever function needed, this switch can only be ON or OFF.

It’s not magic, it’s just nicely warm and fuzzy logic :)

Leave a Reply

Your email address will not be published. Required fields are marked *