logo1.bmp (61374 byte)

home

nutchips

designs f.a.q.

provokations

crc guide who am I ? awards

 

A simple LED flasher


Nutchip outputs | Schematic | Assembling | Truth table | Programming | Simple experiments


Get to know Mr. Nutchip with a simple LED flasher.
An easy and fun experience to get in touch with all the details of design and experimenting with Nutchips.

Nutchip outputs

OUT1, OUT2, OUT3 and OUT4 are the four Nutchip outputs. Each output can be either at logic level zero or one.
Putting an output to zero (aka low level) means that its respective pin measures about zero volt. In this condition a Nutchip output can sink up to 10 mA.
Opposite to low level, an output at logic level one (aka high level) presents on the pin a voltage close to the power supply, about 5 volt for Nutchips. An output can source up to 10 mA.

With Nutchips, the output states are not fixed by the manufacturer: you decide wich combination of zero and ones are appropriate for the outputs. You write a truth table in which every outputs combination is bound to a specific combination of the inputs and internal state. The more states you add to the table, the more different combinations you can get for the outputs. We will get back on this topic later.


Circuit schematic

To make a LED flasher a single output will suffice.
We connect the LED to the output #4 (OUT4) of the Nutchip, connecting its other pin to the positive rail through a 390 ohm series resistor. LEDs must always have a resistor connected in series, in order to limit maximum current.
This type of "reverse" connection is recommended for most digital IC, nonetheless it adds a little magic to the circuit. As opposed to popular belief, the LED will be ON with the output at zero volts!

A three pin ceramic resonator provides the clock pace for the system to work. To complete the circuit, a 100 nF capacitor is required by the chip for smoothing noise on the power supply.

In order to keep the circuit simple, we will connect the reset pin to the positive, leaving other pins unconnected except for the RX and TX pins as they serve for downloading the truth table into the Nutchip. The pins required for chip programming are grouped in the "programming port": this is where the PC interface will plug.

A regulated 5Vdc power supply is required, with the positive to +5V and the negative to GND.

  WHY THE LED IS ON WHEN THE OUTPUT IS OFF?

A LED is a diode that emits light when it is traversed by a current ranging from 1 to 20 mA. A way to make a current flow through a device is to connect it between a positive and a negative poles. Here the positive pole is the positive supply rail, namely +5V, while the negative pole is connected to the ground, represented by a sort of arrow (see pin 10).
An output at logic level one measures +5V, the same as the positive pole. Connecting an LED between the positive and an output at the same voltage as the positive pole does not provide any current flow for the LED. The LED is OFF.
What if the output goes to logic level zero? Logic zero is zero volt, the same as the negative pole. Connecting an LED between the positive pole and an output at the same voltage as the negative pole provides the current flow to turn the LED ON.
Magic, isn't it?
As for the LED polarity, always remember that the arrow in its symbol must point in the direction of the current flow, that is from positive to negative.

PARTS LIST


  • DL1: LED diode
  • R1: 390 ohm resistor
  • OSC: 4MHz, three-pin ceramic resonator
  • C1: 100nF ceramic capacitor
  • IC1: Nutchip NUT01-AK or NUT01-DEA

    Other tools required: 5Vdc stabilized power supply, solderless breadboard, Nutchip programming interface, some thin insulated wire for connections, and a PC running Nutstation.

flasher_schematic.gif (7532 byte)
Schematic of the LED flasher

 

Assembling the circuit

The circuit is very simple, and can be built on a solderless breadboard.

Be careful not to reverse the Nutchip, its pin 1 must be correctly aligned: the picture shows it in the lower left corner relative to IC body, near to the ceramic resonator (OSC).

Nutchip pin 1 is also marked by a small slot or a dot on the IC case, and looking it afrom above,the other pins have increasing numbers running counterclockwise.

LEDs have a polarity too: the catode (K) is the pin with the bar in the schematic. This pin is usually shorter, and the case has a flat face near it. The anode (A) is the pin with the arrow symbol in the schematic.
Don't forget to put the resistor in series with the LED.

Refer to the photo for completing the circuit with all the connections; try to conform to the standard colors of red wire for the positive pole, and black for negative.
The picture shows also the space for the programming interface, within the red box under the "PC" label.

  HALLO.JPG (64457 byte)

Truth table

The hardware part is finished, but the board cannot work yet. In fact, the Nutchip we have put in the breadboard does not know how to move its output pins and what the inputs mean! We are going to write a truth table and to download it to the chip.
A truth table lists all of the valid input configurations and chip internal states, ruling the values shown by the outputs, and how internal states should succeed.

We can start from a blank truth table, then add the device internal states one after another. For each state, we add a series of input conditions: when an input condition is satisfied, the Nutchip changes its internal state. The new state is written in the table as well.
For each state, the table determines the output values (which output is zero and which is one). Changing the state is the Nutchip unique way to change the outputs.

Let's make a practical example with our flasher. What are a flasher states? Well, a simple flasher counts just two states:

Let's use pencil and paper to write schematically such a table. Likely you will end up with with a table like this one:

STATE NUMBER

OUTPUT

CONDITION AND NEXT STATE

ST. 0

PUT LED OFF

AFTER 0.5 SECONDS        CHANGE STATE TO ST. 1

ST. 1

PUT LED ON

AFTER 0.5 SECONDS        CHANGE STATE TO ST. 0

The first column is the state number. States are identified with increasing numbers, usually starting from zero. The state zero is also the state the Nutchip will enter at power on, and when it is forced to RESET with a special pin.
The following column determines the outputs for a each state: you see from the circuit diagram that our LED is connected to an output (OUT4). Filling this table cell you decide if the LED will be ON (OUT4=0, as explained previously) or OFF (OUT4=1)
The rightmost column lists the conditions for changing the internal state. Should a condition become true, the chip will change its state assuming the state specified by the condition itself.
Here the two states have a very similar condition. The condition is that some amount of time has elapsed: which is initially false (state does not change), and becomes true after half a second (state changes).

FOR SIMPLICITY'S SAKE, WE LIMITED THIS EXAMPLE TO TIMEOUTS...

...this is quite limitative, restricting application areas to simple sequencers. Nutchips allow you to build condition much more complex than this, allowing multiple conditions for each state, including checking for any combination of the values at the inputs, and even for the keypresses from the built-in remote control decoder.

 

Turning our paper-and-pencil truth table to a professional looking one, suitable for Nutchip downloading, is a smooth process.
You need a PC running Nutstation (more info about Nutstation setup and usage).
When finished, the table will look like this:

flasher_table.gif (10807 byte)

Nutstation's snapshot of the finished table of the flasher.

It's easy to spot a close resemblance with out prevoius paper-and pencil truth table:

STEP BY STEP PROCEDURE for creating the LED flasher truth table

Click on icon_new.gif (170 byte) to erase current table contents and to start froma blank screen
  1. Click on "Inserisci Timeout" to add a timeout. A new state row appears.
  2. The state row does not have its number yet. The state number placeholder shows "???" instead (leftmost column). Click on the placeholder to set it to "st00".
  3. Move the mouse to the right ( the column labelled "outputs 1..4"), and change all the values to "1" clicking on them.
  4. Now change the timeout, set by defualt to 1 minute. Clicking on the time opens a window that allows you to set the time. Select 500 mS (500 milliseconds = 0.5 seconds) and be sure not to check the box labelled "rimanente" (means "remaining").
  5. Set the state number that will be adopted at timeout (column labelled "next"). The placeholder currently shows "???", click on them until you get "st01".
  6. Click on the space under reserved to comments (rightmost column), and type "LED is off".
    The first row is now complete.
  7. Move the mouse down, to the empty space below the row just completed. The yellow highlight will move there.
  8. Add a new state row clicking on "Inserisci Timeout".
  9. Set the state number to "st01".
  10. Leave the outputs1..4 to all zeroes.
  11. Change the timeout to 500 mS, don't check the box marked as "rimanente".
  12. Set the next state to "st00"
  13. Type "LED is off" in the space reserved for comments.
  14. Finished! Check your work: the table should be similar to the one shown above.

Note: the table is istored in the file "led_flasher.nut" supplied with Nutstation.


Chip programming

Click on the "Prog. chip" tab to display this page:

The light gray area on the left is an automatically generated report. The percentage shown refers to the fraction of Nutchip memory used by the current truth table. If you don't see it, there is some kind of error on the truth table that needs to be fixed before downloading it to the chip.

If your table is incorrect, the programming button is disabled. Nutstation checks automatically the truth table as you enter it. Errors are spotted in real time and invalid cells are highlighted in red.

This is the best time to check for correct serial port selection. You need to configure it only once: click on icon_setup.gif (173 byte) to bring up the serial port selection window.

SPRING.JPG (4240 byte)

Assuming that everything is OK, fit the programming interface to the breadboard (picture on the left) as switch the 5 volt dc power on (be careful not to reverse the polarity!)

Cross your fingers and click on the programming button (shown on the right)
(...a few seconds to complete programming).

Congratulations, your LED flasher is complete!

icon_program.gif (1507 byte)

 

Simple experiments

With both timeouts set to 500mS, the LED flashes exactly once per second. Try to change the times: for example, LED switched on for 1 second as off for 5 seconds. Try also LED on for 0.1 seconds (100 mS) and off for 0.9 seconds (900 mS).

Try these times too: LED on for 5 mS and off for 20 mS: what happens? The LED appears continuously lit, even if its light is slightly dimmed... Try to look at the LED from the opposite corner of your room while shaking your heard quickly: the light breaks in segments!!!

Circuits as simple as this one are best suited as building block for more complex devices. A simple timer can be built connecting a relay (using an appropriate driver) in place of the LED. Replacing the LED with a buzzer makes a simple pulsed audible alarm. Take a look to the "schemi base" page from the original site to get some hints and tips.

You can read both these from www.nutchip.com : I hope this short introduction gives you the right background in order continue with automatic translation tools like those provided on-line by Altavista or Google.
In order to give you an idea of what can be done with a Nutchip, with a very simple truth table and few external components, the next translated project is a fantastic wireless alarm system complete with building plans.

 

home

nutchips

designs f.a.q.

provokations

crc guide who am I ? awards
home | nutchips | designs | f.a.q. | provokations | crc guide | who am I ? | awards