Basic Micro - Home
CART IS EMPTY
  » BasicATOM
  » BasicATOM Nano
  » BasicATOM Pro
  » PICmicro
  » Motor Drivers
  » Robotics
  » Power
  » GPS
  » R/C Lighting
  » Wiring Kits
  » Books
  » Accessories
  » Component Store
Visit Our Resellers

» LynxMotion Robot Kits

» RobotShop US Robots

» Advance Micro

Home > Tutorials > Basic Stamp 2 Workshop > Hardware

Hardware

Basic Stamp 2 Workshop - HARDWARE

Reprinted from original article by Vincent Leclerc

available here

 

MAIN Basic Stamp 2 Architecture Electronic Components Sensors

 

Basic Stamp 2 Architecture

POWER

The BS2 needs a stable 5V DC to function properly.
The Stamp Stack and the Board of Education have internal 5V regulators. That means that in theory you can power them with 4.8V to ~12V.
These internal regulators cannot serve as a regulated power supply for other electronic components of your circuits. You MUST use another regulator. 7805 is recommended in such situations and will give you around 1.5A of current at 5V.

PROGRAMMING INTERFACE

The BS2 communicates with the computer using serial communication. Usually people upload their code in the BS2 using a standard serial cable.

INPUT/OUTPUT

The BS2 has 16 pins that can be set to input or output.

Setting a pin to input will have it expect a signal (5V or nothing). For example, you could use a simple switch that sends 5V to the input pin of the BS2 when it is on and nothing when it is off. It is very important that you do not sent 5V directly into a pin of the BS2. That would cause a short circuit and could kill your BS2. To remedy to this problem, always use a resistor (10KOhm should be enough).

Setting a pin to output will allow you to send 5V or to ground whatever is connected to the pin. The current sent by a BS2 pin is around 20mA. It is sufficient to power most LEDs but not high enough to power a DC motor.

MEMORY

The BASIC Stamp has two kinds of memory; RAM (for variables used by your program) and EEPROM (for storing the program itself). EEPROM may also be used to store long-term data in much the same way that desktop computers use a hard drive to hold both programs and files. An important distinction between RAM and EEPROM is this:

    RAM loses its contents when the BASIC Stamp loses power; when
    power returns, all RAM locations are cleared to 0s.

     

    EEPROM retains the contents of memory, with or without power,
    until it is overwritten (such as during the program-downloading
    process or with a WRITE instruction.)

 

Electronic Components

 

V=RA

This is one of the most important formulæ in electronics. From it you can know what resistance to incorporate in a circuit of a specific voltage to get a precise current. V is the volatge (in Volts). R is the resistance (in Ohms). A is the current (in Amperes). You can move the variables around to suit your needs: R=V/A or A=V/R.
For example, if you want to know what resistance to put in a circuit where the BS2 turns a LED on and off you can do the following:

  • The BS2 outputs 5V.
  • A LED usually drops the voltage by 1.7V and requires 20mA of current to be at full brightness.
  • So the total voltage in this circuit is 5V - 1.7V = 3.3V
  • The needed current is 20mA = 0.02A
  • Plug those values in the formulae R = V/A = 3.3/0.02 = 165
  • Therefore you need a resistor of aproximately 165 Ohms in the circuit.

BATTERY

A battery is a source of power. It has a specific voltage and current.
schematic representation of a battery

RESISTOR

A resistor limits the amount of current in a circuit. It is electronic component you will probably use the most. Resistors come in all different shapes and sizes. They dissipate heat as a result of their opposing electricity, and are therefore rated both in terms of their resistance (how much they oppose the flow of electrons) and their power capacity (how much power they can dissipate before becoming damaged).
schematic representation of a resistor

The resistance is calculated with the color code on the resistor.

POTENTIOMETER

A potentiometer is a resistor with a variable resistance. They have various forms. You will often see them as knobs or sliders.
shematic representation of a potentiometer
They usually have 3 pins. The pin in the middle is the positive pin. The 2 other pins are ground (GND) pins.

Many things can serve as potentiometers. Your skin, liquid substances, metallic materials that can be deformed, etc. can all act like potentiometers.

CAPACITOR

You can imagine a capacitor as a tank that can be charged and discharged. A capacitor stores voltage as electrical energy. When a DC current is applied across a capacitor, positive charge builds on one plate (or set of plates) and negative charge builds on the other. The charge will remain until the capacitor is discharged.
Capacitors can be polar or not. Polar capacitors have a positive side and a negative side. Usually the longest pin of a polar capacitor is the positive side.
shematic representation of a polar capacitor
non-polar capacitor
The strength of a capacitor is called capacitance and is measured in farads (F).

DIODE

Diodes are one way components. They are polar. They allow you to make sure the current flows in one specific way of the circuit. Again, in general, the longest pin of a diode is the positive side.
schematic representation of a diode

LIGHT-EMITTING DIODE

A variant of the common diode is the light-emitting diode or LED.
schematic representation of a LED
There are many types of LEDs on the market. LEDs have various properties:

  • Voltage Drop (V): the voltage drawn by the LED.
  • Current (mA): the maximum current you can give it for optimal brightness.
  • Brightness (mCd): the brightness of a LED is measured in millicandellas. 1 candella (Cd) is equivalent to the brightness of 1 candle.
  • Color (nm): the color is measured as a wavelength in nanometers. In general, LEDs are also labeled with the corresponding color.

 

Sensors

 

Sensors are very interesting components to integrate with
a BS2. Most sensors come with a datasheet that explains how to interface them to µcontrollers. It is essential that you carefully go through their datasheet.

Sensors output information in many different ways. They often simply act as a switch, other times they will give you a range of data (variable resistivity or a variable voltage). Other interesting sensors send a form of digital signal that they 'pulse' over time. The width of the pulse on a timeline will correspond to a specefic sensed value. This type of I/O is called 'pulse width modulation', or PWM.

SWITCH SENSORS

Mercury switch
A mercury switch is a simple switch that opens or closes a circuit depending on its orientation in space.

Touch sensor
This is a more complicated sensor. It consists of an IC that sends a signal when someone touches a lightly charged surface. It can be used to monitor the contact of two conductive objects or the close presence of someone. It can also serve as a 'hard' switch to turn lights on and off for example. Quantum Research Group has a nice selection of cheap touch sensors.

PIR infrared motion sensor
This type of sensor will sense infrared motion and open or close a circuit accordingly. HVWTech sells a PIR mounted on a Fresnel lens that is very sensitive to human presence.

Digital compass
A digital compass is capable of detecting the earth's weak magnetic field. It can distinguish between the cardinal points and will close a part of the circuit formed by its 12 pins depending of the cardinal point it senses. Imagesco has one that can distinguish between the four cardinal points and also the intermediate directions (NE, NW, SE, SW).

Piezoelectric switch
A piezo film is a stripe that generates voltage when you bend it back and forth. It can be seen as a vibration sensor. The problem with those sensors is that it is hard to interface them to a BS2 due to the nature of the output. Someone came up with this addon to a piezo film that simply opens or closes a circuit when it senses vibration. Imagesco sells 2 types of piezo switches: the PZ-05 and the PZ-05-R. By tapping on the end cantilever of the PZ-05, a digital pulse is generated. The PZ-05-R has the reverse effect; a pulse is generated by a pulling force

 

VARIABLE RESISTANCE SENSORS

The sensors that generate a variable resistance are very easy to interface to a BS2. You can digitize the signal in a simple circuit consisting of a resistor and a capacitor. See 'Flashing LEDs with a Potentiometer' in the 'Examples' section of the workshop for a detailled diagram.

Flex sensor
A flex sensor is a kind of rehostat. It is a long stripe that you can bend. When you bend it, its resistivity changes lineraly. This is what Nintendo used in the Power Glove back in the days. Brand new, they are around 10$ a piece. You can get a Power Glove on eBay for the same price and it contains 5 flex sensors...


Photoresistor
A photoresistor is also a variable resistor. Its resistivity varies with the intensity of light it is exposed to.

Thermsistor
A thermistor changes resistivity depending on the ambient temperature.

Force sensor
A force sensor outputs a varying resistance that is proportional to the force applied to the button on the top of the device. The resistance can then used to estimate force (or weight). HVWTech sells the IESP-12 that can take up to 4 Kg of force.

Toxic gas sensor
A toxic gas sensor responds to a large number of airborne toxic compounds. Its most suitable application is for a gas leak alarm or automatic ventilator control. Its resistivity decreases with the amount of gas in its environment. Imagesco sells one that has a very low sensitivity to "noise gasses" which considerably reduces the problem of false alarming.


PULSE WIDTH MODULATION SENSORS

PWM sensors send a stream of information to the BS2 by pulsing the voltage over time. The BS2 reads it using the 'PULSIN' command.

Accelerometer
An accelerometer is an integrated chip that measures the acceleration in space. It can also serve as a level (to know the orientation of something in space). Many accelerometers do not use PWM so be careful when you buy them. HVWTech sells one that comes with a very complete datasheet and examples on how to easily interface it to the BS2. You can also order free samples from Analog Devices, but you will have to do some dirty soldering before you can use them.

Ultrasonic range finder
This sensor measures its distance form any object in front of it.

 

 

 

Phone (800) 535-9161
International (714) 442-8689
Support: support@basicmicro.com
Basic Micro.com, Inc.
Basic Micro Inc.
23811 Washington Ave.
Suite C110-283
Murrieta, CA. 92562