Special Aircraft Service

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: logic gates and switches  (Read 831 times)

0 Members and 1 Guest are viewing this topic.

SAS~Skylla

  • SAS Team
  • member
  • Offline Offline
  • Posts: 1511
  • Flying Ass Clown N°24
logic gates and switches
« on: May 26, 2018, 08:16:14 AM »

Hi Gents,

what until now has been missing badly in the BoX ME were some kind of logic components. I have created a few switch and gate groups that should help to get around this.
All these groups are based on a query principle. That means, incoming links set the status of a switch or gate and this status gets saved within the group. The outgoing signal only gets produced on request.
This is due to the fact that incoming signals will only very seldom come in at the exact same time. Also this way you have to chance to "remember" in your mission if a certain signal was already sent or not.

Download:
Below you can find a description of the components and how to use them. I hope they will be as useful for your missioneering as they are for my ;)



1. Boolean switch
2. Ten way switch
3. Switch concatenation
4. Logic gates
   4.1 General structure
   4.2 Gate concatenation



1. Boolean switch:

The basic idea behind it is pretty simple: When you are building a mission, you might want to base some decisions about what is going to happen next on wheter a certain signal was already sent in the past. For this there is the boolean switch that can either result in a true or a false output.
The switch looks like this:



As you can see, the switch has three inputs and two outputs:
  • IN: set true: Will set the switch to state true, but will produce no output signal
  • IN: set false: Will set the switch to state false, but will produce no output signal
  • IN: query: Triggering this will query the state of the switch and will either lead to a false or a true output signal
  • OUT: true: Indicates that the switch state is true
  • OUT: false: Indicates that the switch state is false
The switch is based on the fact that in the BoX ME a Timer Trigger can have two states: it can either be activated or deactivated. When the switch is queried and the testfalse timer is active, it will deactivate the true output and trigger a false output. If it got deactivated, the waittrue timer will produce a true output after 10 ms. Cool, huh? 8)
Please note that the switch will lead to a false output by default.



2. Ten way switch:

Sometimes just two states might not be sufficient to trace what's going on in a mission. That's where the next group, the ten way switch might come in handy (sorry, but I had to leave out the MCU names because it would get messy otherwise):



The switch has eleven inputs and eleven outputs. The topmost row of timer MCUs are the inputs, the lowest row are the outputs.
The leftmost timer queries the switch state and will lead to one of the outputs to fire, depending on the switch state. The other inputs will set the switch state to state 1 ... 10, beginning from the second timer MCU. Please note that those will only set the switch state and will not trigger an output singal.

The lowest MCU row are the outputs. If the switch got queried, they will show the switch state from 0 (leftmost) to 10 (rightmost).
As you may have noticed it is impossible to set the switch state to 0. In fact this state shows that the switch has not yet been used. It will only be active if none of the states 1 to 10 has been set during the mission yet.

The idea behind the switch is again based on timer (de)activation: If a status is active, it's check state timer (middle row) will be activated, all other check state timers will be deactivated and therefore cannot produce an output signal.



3. Switch concatenation:

If you should ever come around an occasion where even ten switch states are not enough, you can also concatenate two (or more ...) ten way switches. It works like this:



We sacrifice the state 10 of switch 1. It's output gets target linked to the query input of switch 2. All set state inputs of switch two get an additional target link pointing to the set state 10 input of switch 1.
Now if you choose a state of switch two and query the overall state (with the query input of switch 1!), switch 1 will lead to a state ten output. This one will query the state of switch 2 which will then lead to the desired state output.
Please note that in- and outputs of state 10 / switch 1 must not be used for any further signal processing!



4. Logic gates:

Now that we have the possibility to save a signal or a signal state, we will also like to process them further. If you make a dynamic mission you will soon come to the point where you will want to base your decisions on whether certain signals have been sent and others haven't, or whether some switch is in one position or  not in another ..
That's where logic gates come into play. Depending on two input signals (each is either false or true) they produce one output signal which can be  false or true.
I have created six logic gate groups: AND, OR, NOT-AND (NAND), NOT-OR (NOR), exclusive OR (XOR) and exclusive NOT-OR (XNOR). You can find their truth tables below:

       

       



4.1 General structure:

The signal processing in the logic gates is a little more complex and differs from gate to gate, therefore I will just discuss their structure in general here:



The basis of each logic gate are two boolean switches as introduced earlier.
Therefore each logic gate has five inputs and two outputs:
  • IN: State 1 TRUE: Will set the state of input signal 1 to true, but will produce no output signal
  • IN: State 1 FALSE: Will set the state of input signal 1 to false, but will produce no output signal
  • IN: State 2 TRUE: Will set the state of input signal 2 to true, but will produce no output signal
  • IN: State 2 FALSE: Will set the state of input signal 2 to false, but will produce no output signal
  • IN: query: Triggering this will start the query process and will either lead to a false or a true output signal
  • OUT: TRUE: Gets triggered if the result is true
  • OUT: FALSE: Gets triggered if the result is false


4.2 Gate concatenation:

Just like the switches the gates can also be concatenated - may it be to just allow more input signals for "one" gate or in order to combine different gates with each other. Below you can see how it is done:



The outputs of gate 1 are connected to the corresponding signal inputs of gate 2. Furthermore they are connected to a 5 ms timer which will start the query process in gate 2. In this example we therefore get an AND gate that allows three input signals.



Credits
  • Idea and implementation: SAS~Skylla
  • Many thanks to SAS~Storebror for beta testing!


Readme

Code: (!README_logic_gates_and_switches.txt) [Select]
+---------------------------------------------------------------------------------------------
| Logic gates and switches for BoX ME, v1.0
+---------------------------------------------------------------------------------------------

Contents:

- boolean switch group
- ten way switch group
- AND gate group
- OR gate group
- NAND gate group
- NOR gate group
- XOR gate group
- XNOR gate group

+---------------------------------------------------------------------------------------------
| Installation:
+---------------------------------------------------------------------------------------------

Import the groups via ME.

+---------------------------------------------------------------------------------------------
| How To Use It:
+---------------------------------------------------------------------------------------------

1. Boolean switch:

   The switch has three inputs and two outputs:
    - IN: set true: Will set the switch to state true, but will produce no output signal.
    - IN: set false: Will set the switch to state false, but will produce no output signal.
    - IN: query: Triggering this will query the state of the switch and will either lead to
      a false or a true output signal.
    - OUT: true: Indicates that the switch state is true.
    - OUT: false: Indicates that the switch state is false.

2. Ten way switch:

   The switch has eleven inputs and eleven outputs:
    - IN: query: Triggering this will query the state of the switch and will lead to an
      output signal.
    - IN: set state 1 .. 10: will set the switch state, but will produce no output signal.
    - OUT: state 0: This output will only get triggered if no state has been set on the
      switch yet.
    - OUT: state 1 .. 10: Indicates the switch state.
   You can concatenate two (or more) then way switches in order to get more possible states.
   In order to do this, target link the state 10 output of switch 1 to the query input of
   switch 2. All set state inputs of switch 2 get an additional target link pointing to the
   set state 10 input of switch 1. Now if you choose a state of switch two and query the
   overall state (with the query input of switch 1!), switch 1 will lead to a state ten
   output. This one will query the state of switch 2 which will then lead to the desired
   state output.
   Please note that in- and outputs of state 10 / switch 1 must not be used for any further
   signal processing!

3. Logic gates:

   In general each logic gate has five inputs and two outputs:
    - IN: State 1 TRUE: Will set the state of input signal 1 to true, but will produce no
      output signal.
    - IN: State 1 FALSE: Will set the state of input signal 1 to false, but will produce no
      output signal.
    - IN: State 2 TRUE: Will set the state of input signal 2 to true, but will produce no
      output signal.
    - IN: State 2 FALSE: Will set the state of input signal 2 to false, but will produce no
      output signal.
    - IN: query: Triggering this will start the query process and will either lead to a false
      or a true output signal.
    - OUT: TRUE: Gets triggered if the result is true.
    - OUT: FALSE: Gets triggered if the result is false.
   You can find the truth tables for the switches below. "0" stands for false, "1" for true.

      AND           OR           NAND           NOR           XOR          XNOR
   A | B | AB    A | B | AB    A | B | AB    A | B | AB    A | B | AB    A | B | AB   
   0 | 0 | 0     0 | 0 | 0     0 | 0 | 1     0 | 0 | 1     0 | 0 | 0     0 | 0 | 1     
   0 | 1 | 0     0 | 1 | 1     0 | 1 | 1     0 | 1 | 0     0 | 1 | 1     0 | 1 | 0   
   1 | 0 | 0     1 | 0 | 1     1 | 0 | 1     1 | 0 | 0     1 | 0 | 1     1 | 0 | 0   
   1 | 1 | 1     1 | 1 | 1     1 | 1 | 0     1 | 1 | 0     1 | 1 | 0     1 | 1 | 1

   You can also concatenate logic gates. For this, the outputs of gate 1 are connected to
   the corresponding signal inputs of gate 2 (true to true, false to false).
   Furthermore they are connected to a 5 ms timer which will start the query process in
   gate 2.   

+---------------------------------------------------------------------------------------------
| Versions:
+---------------------------------------------------------------------------------------------

- v1.0: initial public release

+---------------------------------------------------------------------------------------------
| Credits:
+---------------------------------------------------------------------------------------------

- Idea and implementation: SAS~Skylla
- Many thanks to SAS~Storebror for beta testing!

+---------------------------------------------------------------------------------------------
| Bug reports:
+---------------------------------------------------------------------------------------------
The only spot I will look out for bug reports are this Mod's release topics
on www.sas1946.com and on www.forum.il2sturmovik.com

I will NOT care for bug reports that do not contain both of the following:
- a DETAILED description of the problem and how it can be reproduced (minimal working example)
- the acknowledgment that you have read this readme. This means you should literally write
  "I have read and understood the readme" somewhere in your post.

I repeat, bug reports missing any of these points will get ignored.

To those who may think of writing a help request via PM to me: Don't you dare!
Use the forum so others can benefit from the answer as well ;)

       >>>>> I hope you'll have a blast with this! See you in the skies! <<<<<

______________________________________________________________________________________________
26.05.2018, SAS~Skylla @ www.sas1946.com



Best Regards,
skylla
Logged
When all else fails: read the instructions!

SAS~Skylla

  • SAS Team
  • member
  • Offline Offline
  • Posts: 1511
  • Flying Ass Clown N°24
Re: logic gates and switches
« Reply #1 on: May 26, 2018, 08:16:26 AM »

reserved
Logged
When all else fails: read the instructions!

SAS~Storebror

  • Editor
  • member
  • Offline Offline
  • Posts: 16340
  • Ask me if I care.
    • Friendly Fire isn't.
Re: logic gates and switches
« Reply #2 on: May 26, 2018, 11:14:20 AM »

These are extremely useful Groups and they're very well crafted.
Thanks a lot for sharing your work with us 8)

]cheers[
Mike
Logged
Learn. Challenge. Improve. In loving memory of the times when I cared...

SAS~Storebror

  • Editor
  • member
  • Offline Offline
  • Posts: 16340
  • Ask me if I care.
    • Friendly Fire isn't.
Re: logic gates and switches
« Reply #3 on: July 07, 2018, 12:53:51 AM »

One question (I'm on the run, that's why I didn't test myself):
Say I want to set/reset the logic gate with output.
The logical way would be to trigger both the "set" input (true or false) and the "query" input from an MCU or whatever else at the same time.
Will this generate a race condition (i.e. will I have to introduce a further timer before triggering the "query" input) or will it work well?

]cheers[
Mike
Logged
Learn. Challenge. Improve. In loving memory of the times when I cared...

SAS~Storebror

  • Editor
  • member
  • Offline Offline
  • Posts: 16340
  • Ask me if I care.
    • Friendly Fire isn't.
Re: logic gates and switches
« Reply #4 on: July 07, 2018, 11:47:55 AM »

Alright, now I've had time to test.
Turns out that indeed there is a race condition, so in order to set/query at the same time, add a 100ms timer in front of the query input or change the query input properties (which is a timer itself) to 100ms delay.

]cheers[
Mike
Logged
Learn. Challenge. Improve. In loving memory of the times when I cared...

SAS~Skylla

  • SAS Team
  • member
  • Offline Offline
  • Posts: 1511
  • Flying Ass Clown N°24
Re: logic gates and switches
« Reply #5 on: July 08, 2018, 02:00:17 AM »

sorry, was not on the PC yesterday ..

you are right, on the logic gates this will not work without an extra timer trigger in front of the query input. This is shown (maybe a little hidden) in the gate concatenation section.
When I tested the concenated gates I found a delay of 5 ms in front of the query input to be sufficient.
Logged
When all else fails: read the instructions!
Pages: [1]   Go Up
 

Page created in 0.046 seconds with 25 queries.