basic schematics buy chips & accessories faq

# Nutchip truth tables

#### learn how to build your own logic!

Nutchips do not use a programming language. To make a Nutchip work for you, just fill-in a truth table with the input and output combinations required by your application. You can do it on your PC: let's see how.

### Short introduction to truth tables

Every logic integrated circuit (I.C.), as for example AND, OR, NAND and NOR gates, as well as FLIP-FLOPs, works according to a well-defined truth table. A truth table lilsts all of the values taken by the outputs (written a zeroes and ones), binding them to the values at each input pin.

 "NAND" TRUTH TABLE IN1 IN2 OUT 0 0 1 0 1 1 1 0 1 1 1 0

As an example, the last row of the NAND truth table (highlighted in yellow) states what follows:

• if both of the inputs (IN1, IN2) are high (1, a voltage near to the power supply level, typically more than 4 Volts)
• then the output (OUT) will be low (0, a voltage very low, typically less than 0.5 Volts)

A truth talbe lists each and every condition that could happen at the inputs: both inputs at zero, both inputs at one, first input at one while the second is at zero et vice-versa.
For each condition  the table shows how the output will be, specifying if the output will be either high (1) or low (0).

### State table = truth table + states

With a few extensions, truth tables are well suited for describing the inner workings of most logic circuits. States are one of the most useful extension to truth tables, and are extensively used for describing flip-flops and all non-trivial logic circuits.

In fact, it is often the case that the same condition at the input gives different results (outputs) according to wich state the device is currently in. We can observe states in lots of everyday experiences, for example:

• the same input condition = toggling a switch
• gives two opposites results = light turns on or off
• according to the current state = light is currently off or on

In a state-based logic circuit, the outputs do not depend exclusively on the input conditions (as in the previous NAND example), but also on the current state of the device.
Therefore, to correctly describe a process like the toggling of a switch, we must specify the state while writing the truth table.
Here is how a truth table looks like after adding states:

 LIGHTS SWITCH TRUTH TABLE CURRENT STATE (and OUTPUT) INPUT (SWITCH ROCKER) NEXT STATE LIGHTS ARE OFF (OUTPUT= 0) TOGGLE LIGHTS ON UNCHANGED LIGHTS OFF LIGHTS ARE ON (OUTPUT=1) TOGGLE LIGHTS OFF UNCHANGED LIGHTS ON

Please note that the table shows the output in the same cell as current state. Most of practical logical circuits work well assuming that outputs will depend exclusively on the current state, therefore it is handy to group current state and current outpus together. Should it be necessary to change the outputs, then we will jump to a different state.

It is not required that all states have different output patterns: it is perfectly valid to have two or more different states with the very same output values.

States appear in the last column too.This column specifies which state our logic circuit will assume as soon as each input condition becomes true.

 Example: Digital counters are an example of logic circuits with states. In a counter, the same input condition (an electric pulse at the input) gives a different effect, according to the current count. If current count is zero, pulsing the input switches the ouputs to one. If the count is one, pulsing the input switches the output to two, and so on... For a counter, as it was for light switch circuit, it is the current state that ultimately decides which outputs shall be zeroed and which outputs shal be set on next input pulse.

For every state-based logic circuit, it is very important to know which state is active at power-on. For example, we expect a well-designed counter to start counting from zero, not from a random number!
Logic circuit manufacturers always specify power-up states; additionally, they supply a reset pin that brings the circuit to a predefined state. This state is often referred to as reset state: and in Nutchip jargoon it is called the state zero (st00).

### How Nutchip's truth tables work

Like most digital logic ICs, Nutchips output are determined by the current state. Nutchips are state-based ICs. Each Nutchip provides four output pins; these pins can change only if the state changes.

Here it is a typical Nutchip truth table:

 This table implements a pathway lights timer. Lights are connected to the first output. A pushbutton is connected to first input. The system provides also a two-key remote control. Pressing the button switches Lights on for 1 minute.Alternatively they can switched permanently on pressing the first key on a remote control (and turned off again with key 2).
Reading a Nutchip state table from left to right, we find the current state first, represented by the letters "st" followed by an incresing number 00, 01, etc. Each state is followed by the corresponding output combination: Nutchips provide four output pins (and you are free to set the output combination of zeroes and ones for every state).

The next columns list the conditions (input combinations) that could happen at the inputs, and what state to assume (next state) as soon one of these combinations becomes true. A state can have more than one condition (in our example, state st00 lists two input combinations).

Nutchips provide four digital inputs. A valid input condition could require that they are at '0', '1', or simply ignore it, written as '-'.
Digital inputs aside, a Nutchip provides a remote control input and a digital timer too. The truth table provides a special "remote" column for the remote control input: writing "key1" in it means "consider this condition only when the first key on the remote is depressed". You can use up to six remote control keys, key1, key2, key3, key4, key5, key6: alternatively select '---' to ignore it.

 Points to note on the table above: only input 1 was used. Inputs 2,3 and 4 are unused and always set to "don't care" (-). only output 1 changes: outputs 2,3,4 are unused and always set to zero the table lists three states: st00, st01, st02 at power up, the chip starts from st00

Remote control keys and inputs can be freely mixed in the same condition: as an example, the string "0  0  -  -  key1" means "first and second inputs low while depressing first key on remote control". Nutchips are compatible with both infrared an radio remote controls (more details about remote controls).

For each state you can add a timeout line to the table. Timeouts are useful for implementing all sorts of timers, flashing, delays, etc. Nutchip built-in timer supports intervals from a few milliseconds to 1000 hours - more than a month! (more details about timeouts)

### Truth tables quick reference

 A state table is made of rows (see figure on the right). One or more rows are grouped together for any given state, and separated by a thin horizontal line. The example counts three such states: st00, st01, st02. Each row specifies a different condition: st00 has two conditions, st01 and st02 just one. The chip power-up state is st00. Outputs are always set according to state. At any time, the chip scans the conditions pertaining to the current state, If any of the input conditions is verified, it changes its state. The new state is the state specified on the last column ("next"). Note that shall two or more condition become true at the same time, the next state will be decided by the condition that comes first in the table. First column is the state number, e.g. st00, st01, st02, st03, st04, etc. Increase the number by clicking on it (left-click to decrease). Always start from state zero (st00). These columns are the values of the four chip outputs: OUT1, OUT2, OUT3 and OUT4 respectively. Click on each output value to toggle it. Each and every state has only one output combination: add more states to get more additional output. These columns, joined to the next, provide the condition that must be satisfied in order to make a state change. Here you specify the values that must be detected on the inputs IN1, IN2, IN3 and IN4 respectively. Each input can be '0' (low voltage) '1' (positive rail voltage, about 5 Volts), or '-' (ignored, the input can have indifferently low or high level). Click on the desired input to change it. For each state you can add as many conditions as required by your application You can specify a maximum time for any state, clicking on the "timeout" button and selecting a time. When time expires, regardless of remote control and digital inputs, the timeout condition becomes true and the state changes to the one specified by the timeout row. This column specifies a remote control key. A Nutchip is compatible with both infrared and radio remotes and recognizes up to six different keys: key1, key2, key3, key4, key5, key6. The condition is satisfied when the built-in remote control decoder receives a signal that matches the key you specified You can mix digital inputs and remote control in the same condition, e.g. "-  -  -  -  key1" menas "input IN1=0, input IN3=1 while depressing key1 on remote control, all at the same time" Set all of the inputs IN1..IN4 to "don't care" to react unconditionally to a single key, e.g."-  -  -  -  key2" will change state when receiving key2, regardless of the inputs. The last column specifies the next state, that is the state to go when the condition becomes true. If all of the conditions pertaining to current state are not satisfied, the current state remains unchanged

Differently from standard logic ICs (whose function is fixed by the manufacturer), you download your favourite truth table into Nutchips. A Nutchip can do thousands of different jobs, according to the table you load. A table is retained inside the chip until you decide to replace it with a new one.

To write a truth table we supply a specialized software, Nutstation. Just fill the truth table cells which appears on-screen with a few mouse clicks. The integrated integrity checker examines your truth table and automatically points out the errors. Nutstation includes programming button to program instantly your Nutchip. You can change the table thousands and thousands of times without changing the chip, each time automatically replacing the previous table with the new one (Nutstation details).

Nutstation is free for home use and for teachers; other professional users and schools must buy a registration (more details)

 To allow you to test immediately a brand-new Nutchip, we supply it preloaded with a LED-flasher truth table. To make it work, just connect it an LED to make sure your prototype is working OK. Additionally, our factory-loaded table also checks infrared remote controls: just connect an infrared receiver to stop flashing each time you press a key on your remote control.

To download the truth table, place the Nutchip in its final circuit (for example, this flasher), and connect its RX and TX pins to the PC serial port through this simple interface:

This circuit is just a level translator from RS232 levels (+ and - 12V) to TTL levels ( 0 and 5V). This schematic gets its power from the Nutchip board, through pin 4 of CN2. Transistors are not critical, and any couple of small NPN + PNP transistors will do. This circuit is just cheaper and easier to build from junk parts that equivalent counterparts built from MAX232, etc (more examples on Nutchip's site).

Connect the interface to PC serial port using a standard extension cord, plug the interface to the board hosting the Nutchip, and switch 5 Volt power on.

 Programming takes place without leaving Nutstation: make sure you have selected the correct serial port, then click on "Programma nutchip" to trigger programming. Note: if current truth table contains errors, this button is automatically disabled. If programming fails due to wrong setup or other hardware errors, the error message is "Programmazione interrotta per errori"