bs2-ic-m.jpgBefore we start throwing you guys into the deep we first talk a little about what microcontrollers are and where you can use them.

A microcontroller is an computerchip including a ‘little’ microprocessor. Microcontrollers are frequently used in automatically controlled products and devices, such as automobile engine control systems, remote controls, office machines, appliances, power tools, and toys. By reducing the size, cost, and power consumption compared to a design using a separate microprocessor, memory, and input/output devices, microcontrollers make it economical to electronically control many more processes.

What is the BASIC Stamp microcontroller?

The BASIC Stamp module is a microcontroller developed by Parallax, Inc. which is easily programmed using a form of the BASIC programming language called PBASIC. It is called a “Stamp” simply because it is close to the size of an average postage stamp. The basic stamp is one of the most used Microcontrollers for hobbyist and professionals.

Blinking the led!
i start interesting in microcontrollers when i read an article to use sensors interacting the computer with Adobe director. So a start thinking of what you can make.. Thats alot of fun projects!

After a long trip over the internet i found a book called: physical computing. This book contains al the basics (and advanced) to get started whit the microcontrollers. I would deffinately recommend buying this book! In one of the first chapters you get starting making your own led blinking. Thats what we gonna show you first, because we need this basics to get understanding our future projects!

To keep in mind this is not a replacement for the book physical computing! It only describs the set up for starting bigger projects. We also dont describe the dangers and basics about electronics. For example if you want to know how a ristor operates you have to buy the book!

Get started!
first like you expected, we started with the shopping list:

- Microcontroller Basic Stamp http://www.parallax.com
- Breadboard 6″ board
- DC power supply 5-9 V or regular 9V battery
- Led(s)
- 5V DC voltage regulator
- 220 Ohm resistors 1/4 watt
- red and black (stiff) wires
- 9-pin D-sub female
- USB-to-serial adaptor including mini gender changer (if you dont have a serial port)
- serial connection cable (not a null cable!)

* keep in mind that you are working with elecicity so keep you project clean and organized!

First look at the project, below we explain the parts and connection.

basic_stamp_testboard.jpg

The ease of using a testboard is u can simple stick the wires and components directly into the board. You dont have to go soldering..
normally the 2 rows in the middel (5 points each) are horizontally connected. The 2 bus rows at the outside are vertically connected. The outside rows are used for the electricity.
in the left upper corner we see the ree wire, this has for now no function. Only the left upper black wire is connected to the led. The next sheme will be more clear!

Below the sheme of the microcontroller basic stamp 2:

bstamp.jpg

Below we see the complete wire diagram, a quick sketch made in photoshop:

basicstamp_sheme.gif
make sure u can essially disconnect the power supply or battery (See image)! Also check of the resistor colors are in right setup!

Start programming!
Now before we can start programming we need to download the free basic program from parallax.
follow the link for win or mac installers: http://www.parallax.com/ProductInfo/Microcontrollers/BASICStampSoftware/tabid/441/Default.aspx

Once installed we can setup the program.
before we can go furter we need to connect the serial cable and must know on wich port it is connected. (for example: look at my computer -> preferences ->hardware config.)
we are connected to com port 14

Now connect the serial cable and power to the microcontroller and launch the program.

ui.gif

1) Choose the basic stamp 2 code setup
2) Add pBasic language to version 2.5

port.gif

3) change the port setting to your com port, in our example this is port 14.

Now we can add the code to blink the led!

‘ {$STAMP BS2}
‘ {$PBASIC 2.5}
‘ {$PORT COM13}

Main:
HIGH 7
PAUSE 500
LOW 7
PAUSE 1000
GOTO main

What this basically does, is it put voltage to pin 7 and then wait for 500 ms. Then it disconnect and waits another 1000 ms. Goto main tells it loops. That was easy right! :D your first program should now work and let the led blink!
For example, other microcontrollers like PIC are al little bit more advanced, because we need to add an (external) clock. The Basic stamp has an build in clock.
So thats the basics of programming microcontrollers. Next we take a look at how we use the microcontrollers to work together with an normal home pc. For example we can now use sensors and read the values, then the computer to react on different values.
one of the things we want to make is an easy home control system with an program language like lingo (adobe director) or visual basic. See also for more details the concept picture.

Thnx for reading this article!

Martijn

Share and Enjoy:
  • Digg
  • del.icio.us
  • Furl
  • Slashdot
  • Spurl
  • StumbleUpon
  • Technorati