diff --git a/docs/courses/logic-lab.md b/docs/courses/logic-lab.md index 3d90ab0b..8e288a8f 100644 --- a/docs/courses/logic-lab.md +++ b/docs/courses/logic-lab.md @@ -2,7 +2,7 @@ ![Logic lab header image](/static/courses/logic-lab/logic-lab-header.jpg) -A basic aspect of knowledge and understanding is whether something is true or not. Considering conditions around you and making a conclusion about something being true or false means that you are using logic. Computers and, in fact, all of digital electronics rely on this idea of logic to process information and give results in terms of conditions being true or false. Logic is used almost everywhere in the programs you write in places where you want decide to do one task or another. +A basic aspect of knowledge and understanding is whether something is true or not. Considering conditions around you and making a conclusion about something being true or false means that you are using logic. Computers and, in fact, all of digital electronics rely on this idea of logic to process information and give results in terms of conditions being either true or false. Logic is used almost everywhere in the programs you write in the places where you want decide to do one task or another. ## Logic topics @@ -13,3 +13,9 @@ These topic sections teach you about applying logic to conditions and using Bool * [Logic Explorer](/courses/logic-lab/explorer) * [Logic Gates](/courses/logic-lab/logic-gates) * [Programmable Logic](/courses/logic-lab/programmable) + +## ~button /courses/logic-lab/expressions + +Let's get started! + +## ~ \ No newline at end of file diff --git a/docs/courses/logic-lab/elements.md b/docs/courses/logic-lab/elements.md index 9f7780d0..746d6d30 100644 --- a/docs/courses/logic-lab/elements.md +++ b/docs/courses/logic-lab/elements.md @@ -6,7 +6,7 @@ Whether creating equations in Boolean algebra or using them in your programs, yo Boolean (logical) equations are expressed in a way similar to mathmatical equations. Variables in Boolean expressions though, have only two possible values, ``true`` or ``false``. For an equation using a logical expression, the equivalant sides of the equal sign ,``=``, will be only ``true`` or ``false`` too. -The following list shows the basic notation elements for Boolean expressions. +The following list shows the basic notation elements for variables and operators in Boolean expressions: * ``~A``: the inverse (**NOT**) of ``A``, when ``A`` is ``true``, ``~A`` is ``false`` * ``A + B``: the value of ``A`` **OR** ``B`` @@ -205,3 +205,10 @@ F | F | F T | F | T F | T | T T | T | F +
+ +## ~button /courses/logic-lab/explorer + +NEXT: Logic Explorer + +## ~ diff --git a/docs/courses/logic-lab/explorer.md b/docs/courses/logic-lab/explorer.md index fad60650..6c59d792 100644 --- a/docs/courses/logic-lab/explorer.md +++ b/docs/courses/logic-lab/explorer.md @@ -4,7 +4,7 @@ As a way to see how the basic logical operators work, we'll make a program to te ## Inputs and output -Make an array called ``||variables:inputs||`` with two values, ``false`` and ``true``, as logical inputs. Add another variable ``||variables:Q||`` to receive the resulting value of a logical expression as output. +Make an ``||arrays:array||`` called ``||variables:inputs||`` with two values, ``false`` and ``true``, as logical inputs. Add another variable ``||variables:Q||`` to receive the resulting value of a logical expression as output. ```blocks let inputs = [false, true] @@ -17,7 +17,7 @@ To start with, we'll make a single input test for the variable ``||variables:A|| 1. Get a ``||loops:for element||`` loop and put it in the ``||loops:on start||``. Rename the ``||variables:index||`` variable to ``||variables:A||`` and switch the ``||variables:list||`` variable to ``||variables:inputs||``. 2. Pull a ``||variables:set Q to||`` block into the ``||loops:for element||`` loop and set the value to ``||logic:false||``. -3. Go find the ``||logic:if then else||`` and put in below the ``||variables:set Q to||``. Pick up a ``||variables:Q||`` in ``||variables:VARIABLE||`` and drop it onto the ``||logic:false||`` to replace it. +3. Go find the ``||logic:if then else||`` and put in below the ``||variables:set Q to||``. Pick up a ``||variables:Q||`` from the ``||variables:VARIABLES||`` Toolbox drawer and drop it onto the ``||logic:false||`` to replace it. 4. Move a ``||basic:show icon||`` inside the ``||logic:if then||`` section and change the image to a ``t-shirt``. This is our image for a ``true`` output. 5. Move a ``||basic:show icon||`` inside the ``||logic:else||`` section and change the image to a ``small diamond``. This is our image for a ``false`` output. 6. Just below the ``||logic:if then else||``, put in a ``||loops:pause||``, a ``||basic:clear screen||``, and another ``||basic:pause||`` block. Set the time for each ``||basic:pause||`` to ``500``. @@ -143,7 +143,7 @@ A | B | A · B ## XOR test -To test XOR, we'll use the XOR expression from [Boolean elements](/courses/logic-lab/elements#xor). Drag and place the ``||logic:LOGIC||`` blocks to make the ``||variables:Q||`` equation to look like this: +To test XOR, we'll use the XOR expression from [Boolean elements](/courses/logic-lab/elements#xor). Drag and place the ``||logic:LOGIC||`` blocks in to make the ``||variables:Q||`` equation to look like this: ```block let A = false @@ -159,4 +159,11 @@ A | B | A ⊕ B **false** | **false** | ``[basic.showIcon(IconNames.SmallDiamond)]`` **false** | **true** | ``[basic.showIcon(IconNames.TShirt)]`` **true** | **false** | ``[basic.showIcon(IconNames.TShirt)]`` -**true** | **true** | ``[basic.showIcon(IconNames.SmallDiamond)]`` \ No newline at end of file +**true** | **true** | ``[basic.showIcon(IconNames.SmallDiamond)]`` +
+ +## ~button /courses/logic-lab/logic-gates + +NEXT: Logic Gates + +## ~ \ No newline at end of file diff --git a/docs/courses/logic-lab/expressions.md b/docs/courses/logic-lab/expressions.md index c4d7ba8e..9f025d85 100644 --- a/docs/courses/logic-lab/expressions.md +++ b/docs/courses/logic-lab/expressions.md @@ -1,8 +1,8 @@ # Logic and expressions -The use and study of _logic_ involves finding a new fact by analyzing whether some other facts together can prove to be true. Some facts, or conditions, when looked at together may prove another fact to be true, or maybe false. +The use and study of _logic_ involves finding a new fact by analyzing whether some other facts, when brought together, can prove that fact to be true. Some facts, or conditions, when looked at together may prove another fact to be true, or maybe false. -If the temperature outside is below freezing and you don't have a coat, you will feel cold. If you're not sick, then you will feel well. If you can swim or ride in a boat in water, you will stay afloat. These are statements of fact that result from some condition being true. +If the temperature outside is below freezing and you don't have a coat, you will feel cold. If you're not sick, then you will feel well. If you can swim or ride in a boat on water, you will stay afloat. These are statements of fact that result from some condition being true. ## Truth statements @@ -12,7 +12,7 @@ By taking some facts and putting them into a logical form, we can make an arithm * **NOT** ``sick`` **=** ``I feel well`` * ``I can swim`` **OR** ``I'm in a boat`` **=** ``I'm floating`` -You see the AND, NOT, and OR in the example word equations? These are our logical _operators_. Every day we make decisions when we think about one or more facts together using these operators. Sometimes, it's necessary for all facts to be true in order for the conclusion to be true. This is the case when the AND operator is used. When analyzing facts with the OR operator, only on fact needs to be true for the conclusion to be true also. +You see the AND, NOT, and OR in the example word equations? These are our logical _operators_. Every day we make decisions when we think about one or more facts together using these operators. Sometimes, it's necessary for all facts to be true in order for the conclusion to be true. This is the case when the AND operator is used. When analyzing facts with the OR operator, only one fact needs to be true for the conclusion to be true also. Making a decision may require more than just one or two facts. When this happens, another operator is needed to combine the facts together to make a conclusion. In the last example word equation, you actually might not be floating if just those two condtions are true. To correctly prove that you're actually floating, you need to state that you're in water too. @@ -109,7 +109,7 @@ Because you feel cold only when both conditions are true, the statement becomes ``A · B`` = ``Q`` -A truth table for the variables in the expression have the same values as the table for the truth statement (``true`` and ``false`` are abbreviated to just ``T`` and ``F``). +A truth table for the Boolean variables in the expression have the same values as the table for the truth statement (``true`` and ``false`` are abbreviated to just ``T`` and ``F``). A | B | Q -|-|- @@ -140,3 +140,9 @@ T | F | F To write a Boolean equation for when you feel cold, we find the condtions in the table where ``Q`` is ``true``. Here we see that you will feel cold only in one row, when condition ``A`` is ``true`` and condtion ``B`` is ``false``. The Boolean equation for these conditions is this: ``A · ~B`` = ``Q`` + +## ~button /courses/logic-lab/elements + +NEXT: Boolean Elements + +## ~ \ No newline at end of file diff --git a/docs/courses/logic-lab/logic-gates.md b/docs/courses/logic-lab/logic-gates.md index fc37475d..f045bb61 100644 --- a/docs/courses/logic-lab/logic-gates.md +++ b/docs/courses/logic-lab/logic-gates.md @@ -2,7 +2,7 @@ ![OR gate symbol](/static/courses/logic-lab/logic-gates/full-adder.png) -In the real world digital devices aren't the abstract logical expressions of Boolean algebra, but they are implementations of these expressions in hardware. The logical expressions are translated into device structures called _logic gates_. A logic gate is both a symbolic representation of a logical operation and, when used in digital electronics, it can is an actual circuit in hardware. A single logic gate is usually made of several transistors an shares space with many others in an integrated circuit. +In the real world digital devices aren't the abstract logical expressions of Boolean algebra, but they are implementations of these expressions in hardware. The logical expressions are translated into device structures called _logic gates_. A logic gate is both a symbolic representation of a logical operation and, when used in digital electronics, it is an actual circuit in hardware. A single logic gate is usually made of several transistors an shares space with many others in an integrated circuit. Each of the basic operators we learned about in the [expressions](/courses/logic-lab/expressions) section have a gate symbol. The symbol takes the place of the operator and the variables are the inputs to the gate. The resulting value from the expression equation is the output of the gate. The output of a gate can be a final result or it can be connected as an input to yet another gate. @@ -85,3 +85,9 @@ When this equation is converted to logic gates, there's one fewer gate than in t ![Combinatorial XOR second version](/static/courses/logic-lab/logic-gates/combinatorial2-xor.png) This diagram has less complexity than the first one. Reduction in the number of gates to accomplish the same logical result is one of the primary goals for digital logic design. For electronic devices, this allows more gates to use the limited amount of space on an integrated circuit. + +## ~button /courses/logic-lab/programmable + +NEXT: Programmable Logic + +## ~ \ No newline at end of file diff --git a/docs/courses/logic-lab/programmable.md b/docs/courses/logic-lab/programmable.md index 32b357e0..1b614cab 100644 --- a/docs/courses/logic-lab/programmable.md +++ b/docs/courses/logic-lab/programmable.md @@ -135,9 +135,9 @@ if (pins.digitalReadPin(DigitalPin.P6) > 0) { You can test different input combinations by connecting the other ends of alligator clip leads on pins **P0** and **P1** to either **GND** or **3V**. The **GND** pin will make a ``false`` input value and **3V** will make a ``true`` input value. -If you have an expansion connector for your @boardname@, you can use the combined logic script and the logic observer code to check each ouptput. Move the other end alligator clip lead connected to the observer pin **P6** to each of the outputs **P2**, **P3**, and **P4** to see the result of the logic operation programmed for those pins. +If you have an expansion connector for your @boardname@, you can use the combined logic script and the logic observer code to check each ouptput. Move the other end of the alligator clip lead connected to the observer pin **P6** to each of the outputs **P2**, **P3**, and **P4** to see the result of the logic operation programmed for those pins. -If you just have the @boardname@ by itself, you can test each logic function using only the scripts for each logic gate. Just put the script inside a ``||loops:forever||`` and place a ``||basic:show string||`` block with the logic letter after each ``||pins:digital write pin||``. +If you just have the @boardname@ by itself, you can test each logic function using only the scripts for each logic gate. Just put the script inside a ``||loops:forever||`` loop and place a ``||basic:show string||`` block with the logic letter after each ``||pins:digital write pin||``. This is the code for the **NOT** gate: @@ -164,7 +164,7 @@ GND | 3V | ``[basic.showString("T")]`` 3V | GND | ``[basic.showString("F")]``
-Do test connections for the inputs and check the results for the **OR** and **AND** outputs. +Do test connections for the inputs, then check and record the results for the **OR** and **AND** outputs. #### OR truth table