No Frames. Direct to: Dontronics Shop What's New? or Dontronics Shop

Dontronics Home Page Basic Stamp Page.

The little "rAVeR!"
DT006 The Newbie Starting Point. Here is the simple cost effective method of getting started in Microcontrollers and programming in the Basic Language. Anyone familiar with QBasic will dive straight in to this one. Free programmer, free programmer software.

StAVeR-24M32 is a microcontroller module based on an Atmel ATmega32 in a small DIP24 package NEW Sep-2003

Stamp Stick1. Basic Stamps on a SimmStick Platform. From Wirz Electronics. Special Price until sold out!
http://www.dontronics.com/stampstick.html.

The Table of Contents.

What is a Basic Stamp?
Basic Stamp 1 Instruction Set.
Parallax Basic Stamp 1 Applications.
Don's Stamp Pager Program. L.O.S.A. #6
Don's Stamp Pager Documentation. For above.
Stamp FAQ.
Stamp I Cable.
Scott Edwards PIC Source Book/Disk Stamp Alternative. Scott shows you how to write Machine Language Stamp routines so you can Program your own PIC chips.
A/D with the pot command on a stamp1 for 10 cents by John Koblanski:
PicBasic Compiler. Compile it and burn it into a PIC chip.
Basic Stamp Divided by Four Free Interpreter.

 Back to The Table of Contents.

What is a Basic Stamp?

Parallax, the Parallax logo, BASIC Stamp, and PBASIC are trademarks of Parallax Inc. PIC is a registered trademark of MicroChip Technology Inc.

You don't know what a BASIC STAMP is?
Here is the PARALLAX write up on it:

It's a small single board computer that runs BASIC programs. At first glance the STAMP may seem fairly minimal and in fact, it is. But with software that fully utilizes all available hardware, the stamp gives you powerful features without the cost of hardware. It is low cost and simplicity make the stamp perfect for many prototyping and control applications.

 Hardware:
The hardware is comprised of two main components. The brain of the stamp is comprised of two main components. The brain of the stamp is an 18 pin BASIC interpreter chip. A 256 byte EEPROM holds a tokenized version of your program, which is read and executed by the interpreter. The remainder of the stamp's 1.5 by 2.5 inch circuit board is taken up by a 4 MHZ resonator, 5 volt regulator, and a 9 volt battery clip. Also included is a small prototype area, which provides space for additional components and connection points for the stamp's 8 I/O lines, 5 volt supply, unregulated supply, and ground.

 BASIC Language:
The stamp is programmed in our simple BASIC language. The language includes familiar instructions, such as GOTO, FOR...NEXT, and IF...THEN, as well as SBC instructions such as SERIN (serial input) PWM, and BUTTON. Each instruction takes 2-3 bytes of EEPROM space, resulting in a maximum program size of 80-100 instructions. Programs are executed at the rate of about 2000 instructions per second.

 Programming:
To write software for the stamp, you'll need the Programming package. The package contains our editor software, programming cable, manual, application notes, and access to free technical support. The cable connects the stamp to your PC parallel port for programming and debugging.

 Back to The Table of Contents.

Stamp Instruction Set:

                BASIC Stamp - Instruction List

                  (C) 1993 by Parallax, Inc.

When a program is first run, all variables are cleared to 0.  The variables
total to 16 bytes of RAM and are arranged as follows:

Data            Words   Bytes   Bits
------------------------------------------------------------------------------
0000 0000       PORT    PINS    PIN0 - PIN7  (PINS.0, PORT.0 - PINS.7, PORT.7)
0000 0000               DIRS    DIR0 - DIR7  (DIRS.0, PORT.8 - DIRS.7, PORT.15)

0000 0000       W0      B0      BIT0 - BIT7  (B0.0, W0.0 - B0.7, W0.7)
0000 0000               B1      BIT8 - BIT15 (B1.0, W0.8 - B1.7, W0.15)

0000 0000       W1      B2
0000 0000               B3

0000 0000       W2      B4
0000 0000               B5

0000 0000       W3      B6
0000 0000               B7

0000 0000       W4      B8
0000 0000               B9

0000 0000       W5      B10
0000 0000               B11

0000 0000       W6      B12
0000 0000               B13

PORT is the I/O port word:

        PINS and PIN0-PIN7 are the port (RB) pins (buffered to overcome the
        read-modify-write problem).  When these variables are read, RB is read
        directly.  When these variables are written to, the corresponding RAM
        is written to, which is then transferred to RB before each instruction.

        DIRS and DIR0-DIR7 are the port (RB) direction bits: 0=input, 1=output
        (buffered to overcome the write-only nature of the TRIS registers).
        This byte of data is transfered to !RB before each instruction.

W0-W6, B0-B13, and BIT0-BIT15 are for general-purpose use.

W6 (B12,B13) is used as a four-level stack if any GOSUB/RETURNs are executed.

-------------------------------------------------------------------------------
ANALOG                  8-bit resolution I/O via resistor-capacitor circuits
-------------------------------------------------------------------------------

PWM  pin,duty,cycles

        Output pwm then return pin to input.  This is used to output analog
        voltages (0-5V) via a pin connected to a resistor connected to a cap
        connected to ground; the resistor-cap junction being the analog output.
        PWM should be executed periodically to update/refresh the analog
        voltage.

        - Pin is a variable/constant (0-7) which specifies the i/o pin to use.
        - Duty is a variable/constant (0-255) which specifies analog level.
        - Cycles is a variable/constant (0-255) which specifies number of
          cycles.  Each cycle takes about 5ms.

POT  pin,scale,variable

        Digitize a 5-50K ohm pot with a .1uf cap and scale result.  This is a
        method of analog input via a pin.  The pin must connect to the center-
        tap of the pot, whose side tap connects to the cap which connects to
        ground.  Use the 'Alt-P' command to determine the scale, while the
        stamp is connected and the pot circuit is in place.

        - Pin is a variable/constant (0-7) which specifies the i/o pin to use.
        - Scale is a constant (0-255) which is used to scale the initial result
          by n/256 (result is then limited to 255).
        - Variable receives the result (0-255).

-------------------------------------------------------------------------------
SOUND                   Direct audio output using a cap and high-z speaker
-------------------------------------------------------------------------------

SOUND  pin,(note,duration,note,duration...)

        Play notes with durations.  The pin must connect to the plus side of a
        => 10uf cap whose minus side connects to a => 40 ohm (or peizo) speaker
        whose other terminal connects to ground.

        - Pin is a variable/constant (0-7) which specifies the i/o pin to use.
        - Note(s) are variables/constants (0-255) which specify type and
          frequency.  Note 0 is silent for the duration.  Notes 1-127 are
          ascending tones.  Notes 128-255 are ascending white noises.
        - Duration(s) are variables/constants (0-255) which specify duration.

-------------------------------------------------------------------------------
SERIAL                  Input and output, plus networking via open-drain/source
-------------------------------------------------------------------------------

SERIN  pin,baudmode,(qualifier,qualifier...)
SERIN  pin,baudmode,(qualifier,qualifier...),{#}variable,{#}variable...
SERIN  pin,baudmode,{#}variable,{#}variable...

        Serial input with optional qualifiers (8 data, no parity, 1 stop).

        - Pin is a variable/constant (0-7) which specifies the i/o pin to use.
        - Baudmode is a variable/constant (0-7) which specifies the mode:
                T2400           true input
                T1200           true input
                T600            true input
                T300            true input
                N2400           inverted input
                N1200           inverted input
                N600            inverted input
                N300            inverted input
        - Qualifiers are optional variables/constants (0-255) which must be
          received in exact order before subsequent bytes can be received and
          stored in variables.
        - Variable(s) receive the result(s) (0-255).  Optional #'s are for
          inputting ascii decimal numbers into variables, rather than raw
          characters.

SEROUT  pin,baudmode,({#}data,{#}data...)

        Serial output (8 data, no parity, 1 stop).

        - Pin is a variable/constant (0-7) which specifies the i/o pin to use.
        - Baudmode is a variable/constant (0-15) which specifies the mode:
                T2400           true output             always driven
                T1200           true output             always driven
                T600            true output             always drn
                T300            true output             always drn
                N2400           inverted output         always driven
                N1200           inverted output         always driven
                N600            inverted output         always driven
                N300            inverted output         always driven
                OT2400          true output             open-drain
                OT1200          true output             open-drain
                OT600           true output             open-drain
                OT300           true output             open-drain
                ON2400          inverted output         open-source
                ON1200          inverted output         open-source
                ON600           inverted output         open-source
                ON300           inverted output         open-source
        - Data are variables/constants (0-255) which provide the data to be
          output.  Optional #'s are for outputting ascii decimal numbers,
          rather than raw characters.

-------------------------------------------------------------------------------
DIGITAL OUTPUT
-------------------------------------------------------------------------------

OUTPUT  pin

        Make pin output.

        - Pin is a variable/constant (0-7) which specifies the i/o pin to use.

LOW  pin

        Make pin output low.

        - Pin is a variable/constant (0-7) which specifies the i/o pin to use.

HIGH  pin

        Make pin output high.

        - Pin is a variable/constant (0-7) which specifies the i/o pin to use.

TOGGLE  pin

        Make pin output and toggle state.

        - Pin is a variable/constant (0-7) which specifies the i/o pin to use.

REVERSE  pin

        Reverse the direction of a pin.

        - Pin is a variable/constant (0-7) which specifies the i/o pin to use.

PULSOUT  pin,time

        Output a timed pulse by inverting a pin for some time.

        - Pin is a variable/constant (0-7) which specifies the i/o pin to use.
        - Time is a variable/constant which specifies the period (0-65535) in
          10us units.

-------------------------------------------------------------------------------
DIGITAL INPUT
-------------------------------------------------------------------------------

INPUT  pin

        Make pin an input

        - Pin is a variable/constant (0-7) which specifies the i/o pin to use.

PULSIN  pin,state,variable

        Measure an input pulse.

        - Pin is a variable/constant (0-7) which specifies the i/o pin to use.
        - State is a variable/constant (0 or 1) which specifies which edge must
          occur before beginning the measurement in 10us units.
        - Variable receives the result (1-65536).  If timeout occurs (.65536s)
          the result will be 0.

BUTTON  pin,downstate,delay,rate,bytevariable,targetstate,address

        Debounce button, auto-repeat, and branch if button is in target state.

        - Pin is a variable/constant (0-7) which specifies the i/o pin to use.
        - Downstate is a variable/constant (0 or 1) which specifies what
          logical state is read when the button is pressed.
        - Delay is a variable/constant (0-255) which specifies down-time before
          auto-repeat in BUTTON cycles.
        - Rate is a variable/constant (0-255) which specifies the auto-repeat
          rate in BUTTON cycles.
        - Bytevariable is the workspace.  It must be cleared to 0 before being
          used by BUTTON for the first time.
        - Targetstate is a variable/constant (0 or 1) which specifies what
          state (0=not pressed, 1=pressed) the button should be in for a
          branch to occur.
        - Address is a label which specifies where to go if the button is in
          the target state.

-------------------------------------------------------------------------------
EEPROM                  Non-volatile data storage in unused program memory
-------------------------------------------------------------------------------

READ  location,variable

        Read eeprom location contents into variable.  location 255 holds
        highest location minus one that is available to user for data storage.

        - Location is a variable/constant specifying a byte-wise address
          (0-255).  Data storage begins at 0 and builds upward, while program
          space builds downward from 255.
        - Variable receives the data byte read.

WRITE  location,data

        Write data into eeprom.

        - Location is a variable/constant specifying a byte-wise address
          (0-255).  Data storage begins at 0 and builds upward, while program
          space builds downward from 255.
        - Data is a variable/constant which provides the data byte to be
          written.

-------------------------------------------------------------------------------
TIME                    Accurate-enough timer functions
-------------------------------------------------------------------------------

PAUSE  milliseconds

        Pause for some time.  The duration of the pause is as accurate as the
        resonator time-base, however extra time (perhaps 1ms) will be spent
        gathering and executing the adjacent instructions.  In other words,
        the higher the milliseconds, the relatively less-significant is the
        extra time.  Therefore, accurate-enough timer functions can be
        implemented by PAUSE'ing, say, 100 (ms), then incrementing a variable
        which counts 1/10 seconds, checking for the end-condition, and if not
        true, looping back to the PAUSE.  In the case of 100 (ms), the error
        might be +1%.  This could be remedied by reducing 100 to 99 (based on
        a trial test), or increasing 100 to, say, 250, and then counting 1/4
        seconds instead.

        - Milliseconds is a variable/constant (0-65535) which specifies how
          many milliseconds to pause.

-------------------------------------------------------------------------------
NUMERICS                Math, translation, pseudo-random generation
-------------------------------------------------------------------------------

{LET}  variable = {-}value ?? value ...

??:     +       ;add
        -       ;subtract
        *       ;multiply (returns low word of result)
        **      ;multiply (returns high word result)
        /       ;divide (returns quotient)
        //      ;divide (returns remainder)
        MAX     ;make less than or equal to
        MIN     ;make greater than or equal to
        &       ;and
        |       ;or
        ^       ;xor
        &/      ;and not
        |/      ;or not
        ^/      ;xor not

        Perform variable manipulation (wordsize-to-wordsize).  Math is
        performed strictly from left to right.

        - Variable will be operated on.
        - Value(s) are variables/constants which operate on Variable.

LOOKUP  offset,(data0,data1...dataN),variable

        Lookup data specified by offset and store in variable (if in range).

        - Variable receives the result (if any).
        - Offset is a variable/contant which specifies which data# (0-N) to
          place in Variable.
        - Data are variables/constants.

LOOKDOWN  target,(value0,value1...valueN),variable

        Get target's match number (0-N) into variable (if match found).

        - Variable receives the result (if any).
        - Target is a variable/constant which will be compared to Values.
        - Values are variables/constants.

RANDOM  wordvariable

        Generate next pseudo-random number in a word variable.

        - Wordvariable is both the workspace and the result.

-------------------------------------------------------------------------------
LOOPING
-------------------------------------------------------------------------------

FOR  variable = start TO end {STEP {-}increment}
NEXT {variable}

        Establish FOR-NEXT loop.

        - Variable will be used as a counter
        - Start is the initial value of Variable
        - End is the terminal value of Variable
        - Increment is an optional value which overrides the default counter
          delta of +1.  If Increment is preceeded by a '-', it will be assumed
          that End is greater than Start, and therefore, Increment will be
          subtracted each time through the loop rather than added

-------------------------------------------------------------------------------
BRANCHING
-------------------------------------------------------------------------------

IF variable ?? value {AND/OR variable ?? value ...} THEN address

        ?? can be =, gt=,lt=,gt,lt (symbols changes slightly 'html' conflict)
                                   (Don McKenzie.)
        Compare and conditionally branch.

        - Variable(s) will be compared to Value(s).
        - Value is a variable/constant.
        - Address is a label which specifies where to go if condition is true.


BRANCH  offset,(address0,address1...addressN)

        Branch to address specified by offset (if in range).

        - Offset is a variable/constant which specifies which Address# to use
          (0-N).
        - Addresses are labels which specify where to go.

GOTO  address

        Go to address.

        - Address is a label which specifies where to go.

GOSUB  address

        Go to subroutine at address.  Up to 16 GOSUBS are allowed and they
        can be nested up to 4 deep.

        - Address is a label which specifies where to go.

RETURN

        Return from subroutine.

-------------------------------------------------------------------------------
POWER CONTROL           Achieves maximum battery life
-------------------------------------------------------------------------------

NAP  period

        Nap for a short period.  Power consumption is reduced to an extent
        dependent upon the length of the period.

        - Period is a variable/constant which determines the duration of the
          reduced-power nap.  The duration will be 2^period * ~18ms.  Period
          can range from 0 to 7.

SLEEP  seconds

        Sleep for some seconds (resolution is ~2.3s, accuracy is ~99.9%).
        Power consumption is reduced to 1/100th normal (assuming no loads are
        being driven).

        - Seconds is a variable/constant which specifies the duration of sleep
          in seconds (0-65535).


END

        Sleep terminally until the power cycles (program re-runs) or the pc
        connects.  Power is reduced to an absolute minimum (assuming no loads
        are being driven).

-------------------------------------------------------------------------------
DEBUGGING               Used in program-development
-------------------------------------------------------------------------------

DEBUG  cls,"Text",cr,var,$var,%var,#var,#$var,#%var

        Display information in the debug window upon encounter during
        execution.

        - Text to be printed can be expressed in quotes; in addition, 'cls'
          (clear screen) and 'cr' (carriage return) can be used.

        - Variables can be printed with their current values by simply naming
          the variable.  Decimal is the default, but '$' can be used for hex
          and '%' can be used for binary.  If a '#' preceeds a variable (with
          optional '$' or '%' in front) the variable name will not be printed,
          instead only the value will be printed.

-------------------------------------------------------------------------------
EEPROM                  Preloads EEPROM data locations
-------------------------------------------------------------------------------

EEPROM  {location},(data,data...)

        Preload EEPROM data locations (those not used by the program).  This
        is not an instruction, but rather a means to preload otherwise cleared
        eeprom locations.

        - Location is an optional constant (0-255) which specifies where to
          begin storing the data in the eeprom.  If no location is specified,
          storage continues from where it last left off.  If no location was
          initially specified, storage begins at 0.  Data storage builds upward
          from 0 while program storage builds downward from 255.
        - Data are constants (0-255) which will be stored in the eeprom.

-------------------------------------------------------------------------------
SYMBOL                  Establishes alias names for variables and constants
-------------------------------------------------------------------------------

SYMBOL  symbolname = value

        Assign a value to a new symbolname.

        - Symbolname is a text string which must begin with an alpha-character
          or '_'.  After the first character, it can also contains number
          characters ('0'-'9').
        - Value is a variable or constant which is being given an alternate
          symbolname.
Back to The Table of Contents.

Parallax Basic Stamp 1 Applications:

Included with the Stamp Software Development package is a set of Application Notes. Most of these have software examples included on disk and all have hard copy.

 These Application Notes are as follows:

 Note #1 LCD User-Interface Terminal.
Note #2 Interfacing an A/D Converter.
Note #3 Hardware Solution for Keypads.
Note #4 Controlling and Testing Servos.
Note #5 Practical Pulse Measurements.
Note #6 A Serial Stepper Controller.
Note #7 Sensing Temperature with a Thermistor.
Note #8 Sending Messages in Morse Code.
Note #9 Constructing a Dice Game.
Note #10 Sensing Humidity and Temperature.
Note #11 Wireless Infrared Communication.
Note #12 Cheap Sonar Rangefinding with the Stamp.
Note #13 Using Serial EEPROMS with the Stamp.
Note #14 Networking Multiple Stamps.
Note #15 Using PWM for Analog Output.
Note #16 Keeping Stamp Source Private.
Note #17 The Solar-Powered Stamp.
Note #18 One pin, Many switches. How to sense 8 switches using only 1 pin.
Note #19 Using Button Effectively. Delay, auto, repeat.
Note #20 An Accurate Timebase. Uses 32,768hz Xtal.
Note #21 Fun with Trains. Controls the movement of 3 model trains.

 Back to The Table of Contents.

Stamp Pager Program:

L.O.S.A. Application #6 pager.bas by Don McKenzie.

This file is Number 6, and my contribution to a set a set of files known as "L.O.S.A." This is a List Of Stamp Applications compiled by Christer Johansson E-mail: cj@hth.com

 Do you have a Stamp application?
Do you want to have at look at the List?
L.O.S.A. List and Contibutions.

The Dontronics BasicMicro 1 is a Parallax Basic Stamp work-alike. It also uses my PIGMY board as a building block. I source the Basic Interpreter chip from Parallax.

 Check my Home Page and Promo disk for full details and Prices.


'Author:          dontronics@labyrinth.net.au
'File:            http://www.labyrinth.net.au/~donmck/stamp.html#pager
'Home Page:       http://www.labyrinth.net.au/~donmck

'PAGER.BAS by Don McKenzie             Updated 4-Jul-94
'P.O. Box 595 Tullamarine 3043 Australia. 
'This program for the Basic Stamp is used to monitor 4 hardware signals.
'If a change takes place, (after testing for a false trigger) then a cheap
'2400 baud MODEM is used to dial into a Telecom Alpha-Numeric pager.
'It leaves a message which consists of a 2 digit I.D. (01 to 99)
'followed by the 4 signal levels of pins 3 to 0.
'Status of the signal levels message: 0=Low, 1=High.
'EG:  "011110" means Unit "01" has pins 3, 2, and 1 high, and pin 0 is low.
'
'A "Ring-In" feature is also included. By ringing the MODEM for a short
'period, then hanging up, the Stamp will dial your Pager and report the
'current hardware status of these four signals.
'
'This program uses about half of the available memory, so if the user wishes
'to add enchancements such as "Multiple Ring-In's" say within a minute, for a
'command selection, there is plenty of program space left.
'
'Enjoy... Don.

EEPROM 0,("ATDT016nnnnnn;",13)          'STORE PAGER ATDT,Number,";",CR
                                        '*** NOTE "016" is tAustralian
                                        'Prefix for Pagers. nnnn" is the
                                        'six digit Pager num.

SYMBOL  LENGTH=14                       'LENGTH OF ABOVE (15)-1=14

SYMBOL  PAGER_DELAY=25                  '25 SECONDS FOR PAGER TIMING
SYMBOL  REPORT_DELAY=300                '5 MINS BETWEEN BAD REPORTS...
SYMBOL  DROP_OUT_DELAY=60               '60 SECS FOR MODEM HANGUP

SYMBOL  MASK=%00001111                  'Mask to bottom 4 bits
SYMBOL  VALUE=%00001111                 'Test Value. In this case, all
                                        '4 bits high = 0FHex

'MASK and VALUE can be user set to match your requirements.
'Set in "MASK", any pin you wish to monitor to a "1". Pin 4 is spare.
'Set in "Value", your normal high's or low's.
'The above example has all pins high.

'Pin 7 Data Out, the rest are Input     'Connects to pin 2 of the MODEM
'Pin 6 Ring In (Via a 22K resistor)     'Connects to pin 22 of the MODEM
'Pin 5 Data In (Via a 22K resistor)     'Connects to pin 3 (N/U this file)
'Pin 4 Spare                            'Not used

'Pins 3 to 0 sense hardware.            '

'B2 Stores Pin 0
'B3 Stores Pin 1
'B4 Stores Pin 2
'B5 Stores Pin 3
'B6 Stores LSB ID in ASCII
'B7 Stores MSB ID in ASCII
'B8 Stores Pins 0 to 3 masked to 4 bits.

LET B7="0"                              'MSB ID
LET B6="1"                              'LSB ID, so this ID="01"

LET DIRS=%10000000                      'Explained above

LOOP:

'My Australian MODEM asserts the RI signal for approx. 500ms every 2 secs.
'I'm sure most modern MODEMS use similar chip sets.

NAP 3                                   'Nap for about 144ms.
                                        'Short enough to det RI

IF PIN6=1 THEN RINGIN                   'A Ring In? Report back.
LET B8 = PINS & MASK                    'Save all pins and mask to 4 bits
IF B8<>VALUE THEN CHANGED               'Test against value
GOTO LOOP                               'No changes or reports to do.

CHANGED:
SLEEP 2                                 'WAIT 2 SECS THEN CHECK AGAIN
LET B8 = PINS & MASK                    'Save all pins and mask to 4 bits
IF B8<>VALUE THEN PAGER                 'Test against Value
GOTO LOOP                               'Dropped out, don't page

PAGER:
FOR B9=0 TO LENGTH                      'Set loop for length of pager numb.
READ B9,B10                             'Read EEPROM to B10
SEROUT 7,N2400,(B10)                    'Set 2400, Output Pager string
NEXT B9                                 'Next EEPROM address

LET B2=PIN0+48                          'Result to B2 converted to "0 or 1"
LET B3=PIN1+48                          'Pin 1 to B3 etc.
LET B4=PIN2+48                          '...
LET B5=PIN3+48                          '...

'The SLEEP lets the other end answer, and may need to be changed.
'Allow 25 Seconds for Australian Telecom Paging.
SLEEP PAGER_DELAY                       'SLEEP FOR xx SECONDS

'Send a Numeric message. The # terminates the pager message.
'Send 2 digit ID, then 4 digit "0/1" values of pins 3 to 0.
SEROUT 7,N2400,("ATDT",B7,B6,B5,B4,B3,B2,"#",13)
 
SLEEP 2                                 'Pause 2 Seconds
SEROUT 7,N2400,("ATH",13)               'Hang up the Modem.
SLEEP REPORT_DELAY                      'Wait before next H/W test
GOTO LOOP                               'Finito, do it all again...

RINGIN:
SLEEP DROP_OUT_DELAY                    'Wait for caller to hang up
GOTO PAGER                              'and Modem to go back to sleep.

'A test can be done at RINGIN to make sure the caller has hung up.
'I didn't need this code, but your phone system may.
'
'EG:  RINGIN:
'     NAP 3                                   'Sleep for about 14.
'     IF PIN6=1 THEN RINGIN                   'Still RINGIN?
'     NAP 3                                   'Short Snooze.
'     IF PIN6=1 THEN RINGIN                   'Double check....
'     SLEEP DROP_OUT_DELAY                    'Wait for caller to hang up
'     GOTO PAGER                              'and Modem to go back to sleep.
'
Back to The Table of Contents.

Stamp Pager Documentation:

Read the tail end of this article for full hardware and software instructions.
 
 
Hardware>Stamp>Modem>Phone>Pager                     ;Output Changed=Result
Phone>Modem>Stamp>Hardware>Stamp>Modem>Phone>Pager   ;Ring in=Result.
You can monitor up to four hardware conditions and when a change takes place, get a two chip circuit programmed by you in Basic to dial into an Australian Telecom Alpha-Numeric pager and leave a Numeric Message. This number can reflect a given unit ID and a set of conditions.

 I call this two chip circuit a Basic Stamp. This is programmed by you in Basic from the printer port of your PC.

 Possible Monitor Uses:

 UPS Monitor, Air-Conditioner, Burglar Alarm, Hospital Equipment, Comms Down, and many more.

 You can even "Ring In" from any phone at any time for an instant report. This project uses a cheap 2400 Baud Hayes Compatible Modem and a standard Telecom phone line. If you use an Austel approved Modem, then it can be used in any Commercial Application. Surely you "Cutting Edge Types" can think of a use for this one.

 All you need is the above, one of Don's Basic Stamps and Don's Special Stamp Development package. Read my Promo disk for full pricing on these items.

 First you assemble your Stamp as instructed in the PICEX assembly instructions file, solder one DB-25 connector to the board, add one jumper and one 22K resistor. You may need a Gender Bender.

 That's the full hardware changes to my Stamp for this project.

 Your monitored hardware signal(s) connect to J1 or J2 of the Stamp.
The Stamp is plugged into the rear of a Hayes compatible 2400 baud Modem.
The Modem connects to a Telecom phone line.
This setup signals your Alpha-Numeric Pager and leaves a Numeric message.
This can represent a unit I.D. and a set of hardware conditions.

 Ringing the Modem back, or at any time, can request another report that will be sent to your pager. This can be used to test for "System Alive" at any time. With a little programming effort, several rings within a minute could be set up to represent a remote command.

 Detailed hardware and software instructions on the Stamp>Modem>Pager are given with Don's Basic Stamp Short Form Kits...

 Hey, that's now....

 _______________________________________________________________ SOFTWARE

 The MODEM used for this software was a Maestro Executive 144FM.
The value of 25 seconds matches "my" Australian Telecom Pager.
"016nnnnnn" represents the Pager Number.
"aabb" represents the Numeric Coded Message.
"aa" is the units 2 digit I.D. (00 to 99, Really, any digit length).
"bb" represents the hardware status.
Basic Pin 7 (RB7 or E1/13) is used to transmit to the modems receive pin.
Basic Pin 6 (RB6 or E1/12) is used to receive the "Ring In".
Basic Pin 0 (RB0 or E1/6) is used to monitor hardware.

 I found a problem when hanging up the Modem. This was overcome by allowing at least 1.5 seconds delay before and after the "Hangup" command. The stamps integer value must then be set at 2 seconds. My mate "MICK" knew of this problem and put me straight.

 I will cover the "Ring In" software later, but first here's the straight monitor>page routine.
 
 

LOOP:

'Put anything here to monitor events, such as contact closures, or
'voltage inputs.

IF PIN0=0 THEN PAGER_ROUTINE    'Monitor a normally high input
SLEEP 60                        'Check it once per minute.
GOTO LOOP

PAGER_ROUTINE:

'Set Volume 3, DIAL "TONE" Number,CR            'I'm a bit deaf !!
SEROUT 7,N2400,("ATL3DT016nnnnnn;",13)          '016nnnnnn = Pager Number.

'The SLEEP lets the other end answer, and may need to be changed.
'Allow 25 Seconds for Australian Telecom Paging.
SLEEP 25

'Send a Numeric message. The # is usually used to signal
'the end of the pager message.
SEROUT 7,N2400,("ATDTaabb#",13)                 'aabb = Coded Message.
 
SLEEP 2                                         'Pause&sp; Seconds
SEROUT 7,N2400,("ATH",13)                       'Hang up the Modem.
SLEEP 2                                         'Pause&sp; Seconds
GOTO LOOP                                       'Continue

***************************************************************

'Let's simplify that code.....

LOOP:
IF PIN0=0 THEN PAGER_ROUTINE            'Monitor a normally high input
SLEEP 60                                'Check it once per minute.
GOTO LOOP                               'Do it all again.

PAGER_ROUTINE:
SEROUT 7,N2400,("ADT016nnnnnn;",13)     '016nnnnnn = Pager Number.
SLEEP 25                                '25 Seconds for Telecom Paging.
SEROUT 7,N2400,("ATDTaabb#",13)         'aabb = Coded Message.
SLEEP 2                                 'Pause 2 Seconds
SEROUT 7,N2400,("ATH",13)               'Hang up the Modem.
SLEEP 2                                 'Pause 2 Seconds
GOTO LOOP                               'Continue
HARDWARE

 Build a Basic Stamp as per my PIGMY assembly instructions.
Solder a DB-25 Female connector to the board at the appropriate spot.
Solder a jumper from pin 13 (RB7) of the Stamp to pin 2 of the DB-25 Female connector.

 Solder a 22K resistor from pin 12 (RB6) of the Stamp to pin 22 of the DB-25 Female connector. This resistor can be run on the component side of the board from pin 22 of the DB-25 to pin 8 of J11, the non-fitted 84 programming header. The resistor may need a couple of bends in it to get around the J1 header.

 You will need a Male to Male Gender Bender or short cable to connect your Stamp to the Modem. You are finished...

 Of course there can be a lot more to it than that, as many alternatives are available.

 To save a Gender Bender, you could solder a Male connector to the board and allow for the direction of the Modem to Stamp matching, that is, have them both facing up. This may require you to flip the connector over. In either case you will need to make the correct connections for ground (pin 7), TX (pin 2), and Ring In (pin 22).

 Insulation may be required on the resistor legs.

 Make sure that the two units will connect without physical interference. My Modem has a 9VDC power in connector that hits the Stamp board, so I opted for using a Female connector on the Stamp and a long Gender Bender. These come in long, (about 2"), and short, (about .5").

 I found that the pin 4 to 5 short and the 6 to 8 and 20 shorts made little difference to the operation of my Modem. They certainly changed the status of the LEDs at various stages of operation, but the above code worked fine with or without these connections.

 The code to be used for this type of connection is SEROUT 7,N2400.
This indicates serial out pin 7, not true signal at 2400 baud.
The "not true" means that no inversion takes place. A level converter such as a MAX-232 would give a true signal and the code would be SEROUT 7,T2400.

 If you had trouble running without the MAX-232 (which I doubt) or had to run the Stamp a reasonable distance from the Modem, then a MAX-232 would be required. Of course, provision is made on the board for a MAX-232. If you use it, you must isolate pins 10 and 12 of the MAX-232 from the Stamp circuit, and connect up pin 13 of the Stamp to pin 10 of the MAX-232. The output pin 7 must then connect to pin 2, not pin 3 of the DB-25 connector.

 The "Ring In" signal would also have to be re-routed via the Max-232, that is, if you use a MAX-232.

 Remember, the code to be used for this type of connection is SEROUT 7,T2400.
 
 

RINGING IN

When you ring a Modem that isn't set to Auto Answer, two things occur.

 (1) The word "RING" is sent to the comms port via an RS-232 signal.

 (2) The "RI" or pin 22 of the DB-25 connector goes high for a reasonably long duration during each ring. In fact, every time you get the word "RING", pin 22 goes high. You want a time? Oh, I suppose about 330ms time on for every second. Don't quote me, I'm guessing. You need a CRO or a Telecom Tech for a real answer. I didn't bother, needless to say it's on for long enough to easily detect and act upon.

 If you use a 22K resistor to connect pin 22 of the DB-25 to pin 12 of the stamp, then bit 6 will go high when the phone rings.

 You could use this to prompt the Stamp into reporting, or perhaps "ring in" 3 times before 1 minute is up, to control the Stamp.

 When I worked for Telecom, certain bits of privileged information became available to me. Things like, how to test the bell on a phone by sending remote ring tone from the exchange out on the line to me. It's not the sort of information that I could or would print for "All" to read.

 Over the years as technology changed, I learnt only about these juicy items from Techs that I came across, and I still treat this as privileged information.

 As I have now seen the "Ring Back" details in print, I can quote from this.

 Page 93 of my Maestro Modem Manual states:

 Modem is not detecting ring?
Dial "199" from a telephone on the same line, wait for the ring tone and replace the handset. Your line will ring.

 So there it is. You can now easily test a "ring in" circuit and software to suit.
 
 

LOOP:
IF PIN0=0 THEN PAGER_ROUTINE            'Monitor a normally high input
IF PIN6=1 THEN RING_ROUTINE             'Monitor a normally low input

SLEEP 60                                'Check it once per minute.
GOTO LOOP                               'Do it all again.

PAGER_ROUTINE:
SEROUT 7,N2400,("ADT016nnnnnn;",13)     '016nnnnnn = Pager Number.
SLEEP 25                                '25 Seconds for Telecom Paging.
SEROUT 7,N2400,("ATDTaabb#",13)         'aabb = Coded Message.
SLEEP 2                                 'Pause 2 Seconds
SEROUT 7,N2400,("ATH",13)               'Hang up the Modem.
SLEEP 2                                 'Pause 2 Seconds
GOTO LOOP                               'Continue

RING_ROUTINE:
SLEEP 60                                'Wait for hang up and settle MODEM
GOTO PAGER_ROUTINE
The previous file in L.O.S.A. is the full correct program for this project.

 The program in it's current form uses about half the memory available, and reads then codes up 4 hardware bits and a 2 digit ID for Numeric display. A single Ring-In will also trigger the Pager sequence.

 To assist with development, I connected the output of my stamp into my PC to a terminal program. To do this you must have a pin 2 to pin 3 swap cable.

 This enabled me to read the ASCII text output of the Stamp directly. The Command DEBUG also proved very useful.

 If you don't swap 2 and 3, then you will probably destroy your Stamp chip as you will have RS-232 connected directly to a Stamp pin without the 22K current limiting resistor.
 
 

GOING FURTHER..... READING THE MODEM DATA.....

HARDWARE:

Basic Pin 5 (RB5 or E1/11) is used to receive data in this example.

 By using pin 11 or bit 5 of the Stamp as an input, you can read the data sent from your Modem. If a MAX-232 isn't installed, connect a 22K resistor between pin 11 of the Stamp and pin 3 of the DB-25 connector. I won't bother to go through the MAX-232 connections. I'm sure you get the idea.
 
 

SOFTWARE:

'Set Volume 3, DIAL "TONE" Number,CR
SEROUT 7,N2400,("ATL3DT1111111;",13)

 SERIN 5,N2400,B2,B3,B4,B5,B6,B7
DEBUG B2,B3,B4,B5,B6,B7

 ETC...

 Or by simply using the SERIN section of code, you can read the word "RING" every time the phone rings into the MODEM.

 The SERIN code reads the characters in to variables B2 to B7
DEBUG will display these 6 variables on your PC screen.

 These are shown as decimal values so if all is "OK" you should get an "O" (79), and a "K" (75) somewhere in the variables.

 This should give you a basis to continue on with reading data from a Modem as well as writing to a Modem/Pager. I haven't done any more work on reading data than this, as I feel the "Ring In" function that is covered above, is all that is required for this project.

 I look forward to any feedback on this project.

 Back to The Table of Contents.

Stamp FAQ:

Frequently asked Questions:

 Parallax, the Parallax logo, BASIC Stamp, and PBASIC are trademarks of Parallax Inc. PIC is a registered trademark of MicroChip Technology Inc.

 Have you heard about my new range of Basic MicroControllers? They work like Basic Stamps and use the same core-chip that Stamps use, but they are not Basic Stamps, or Stamp-anythings. I have called them a BasicMicro-1.

 Stamp's Frequently Asked Questions:
 
 

(Q) Is there some smarts or I.C.'s in the Stamp Development Cable?

(A) NO. It's a simple 3 wire circuit from a DB-25 male to a 3 pin header.
    You get a schematic of this with my BasicMicro-1 kit. You also get a
    Parallax Stamp schematic, as well as my PIGMY schematic.

    In Fact this is it:

    3 pin Header:     DB-25 Male to Printer Port:

    Pin 1 Connects to Pin 25 (Ground)
    Pin 2 Connects to Pin 11 (Busy)
    Pin 3 Connects to Pin  2 (Data 0)

(Q) Can another EEPROM be fitted to the stamp to increase program size?

(A) Yes, but it requires a little additional circuitry and software magic to
    achieve this. A very clever circuit (drawn in ASCII text), and suitable
    software can be found on my Stamp disk, which is provided with my kit.

    You will need to add the following components:

    1 by 74LS74, 1 by 74LS157, 1 by BC548 (Any S.S. PNP), and a couple of
    resistors. What this circuit does, is bank select, or switch between
    EEPROMS. Not an ideal method, but it works.

    Note*** 1996 Ths is old stuff now. Get a BS-2, or FED Basic if you
    need more space. Even the PicBasic Compiler will give you more room.

(Q) Can the PIC (Stamp) pins drive ULN2003 (7bits), or ULN2803 (8 bits)
    directly, that is, without resistors?

(A) YES. A suitable circuit is provided in all of my Stamp work-alike kits.
    It's the circuit of my RELAY board kit.

(Q) Do I get some Stamp Basic programming examples to get me started?

(A) Yes. Most Stamp Applications have software driver examples. These
    examples are all included on my disk. Examples are also available on the
    Parallax BBS. Details of how to log onto this are given on this disk.

(Q) The Stamp may not give me the power and flexibility I need for my
    applications, and perhaps I need to move on. What options do I have?

(A) If you think you may have a little trouble with Machine Code for the PIC
    chips, the simple software solution may be found in Scott Edwards PIC
    Source Book/Disk or PicBasic Compiler using a PIC16C84.

    On the hardware side of things, the PIC16C84 is similar to the PIC16C56
    used in the Stamp and in fact, it fits my PIGMY board too. I released my
    programmer for this device on the 14-Feb-95. It will run from the
    parallel printer port of an MS-DOS PC and is VERY cost effective.
Back to The Table of Contents.

Stamp I Cable:

Simple 3 wire connection for Basic Stamp.

 The communication cable supplied with the development kit has a DB-25 Male connector one end for connection to a parallel port and a 3 pin female header socket on the other.

 On the 3 pin end, it has the text "PCV" near one pin. The Parallax Basic Stamp board has the same text written on the top side of the board. The idea is to "MATCH" this text up when installing the cable on the stamp.

 The cable has the following connections:
 
 

DB-25 Female   Signal name             Stamp PCB

Pin 25         Ground                  Pin 1           Ground
Pin 11         Busy           <        Pin 2           Data (RA3)
Pin 2          Data 0         >        Pin 3           Busy (RTCC)
Back to The Table of Contents.

10 Cent A/D using 'POT'

John Koblanski wrote:

> hi don its jk from uk , who admired your sweet site counter (done by
> webcounter) if i send you details of how to do 0v to 5v A/D with the
> pot command on a stamp1 for 10 cents rather then use an ad0831 or
> tlc549..... would you be interested in putting it on your webpage
> with my name on it ?.
> now that i've told you, you'll properly figure it out.
> cu jk
> smtp
> **********************************************************************
> #      john g koblanski. . . .    email john.koblanski@man.ac.uk     #
> #      the school of engineering  room                    it 108     #
> #      university of  manchester  tel         (44) 0161 275 5709     #
> #      manchester     england     fax         (44) 0161 275 4512     #
> **********************************************************************

G'day JK,
Manchester Uni, isn't that where D.T. lurks? :)
Be happy to put it there.
Cheers Don...

Subject: re: vin pot etc
Reply-to: john.koblanski@man.ac.uk
hi don

I've been thinking about this for some time and the first solution
that presented its self was the opto transistor.
the transistor replaces the resistor in the pot chain, the led goes
in the feedback loop of a 324 and it works, but the Vin range is
limited and the transistor does funny things.
so then the idea of a current mirror seemed to offer possiblities
two pnp devices and an op-amp but that didn't work at all.
then as usual keep it simple comes to mind and of course it's a fet.

i tried the mosfet first as i thought no junction to bias must be
good. but the best turned out to be a p-channel enhancement mode
or a 2N3820 jfet. buts its a uk $ ...if you haven't got a draw full
of them.

         to stamp pin1  --------
                               |
                               |
                         | |----s
                     g   | |      2N3820
         Vc 0-5v   ----->| |----d
                               |
                               |
                               |
                              /
                               \ 1K
                              /
                              \
                              |
                              |
                          ---------   100nF
                          ---------
                              |
                              |
               gnd    ---------

even with out the 100k linearizing resistors it seems fine,,,,
(see horiwitz)
obviously it suffers from temperature dependance and properly a
peculiar curve , it does seem as 'linear' as the pot but i haven't
done the measurements yet. but once set up with alt p it should
provide a cheap and repeatable vin a/d for the stamp.

i used pot 0,xx,b0
       display b0
       pwm 1,b0,10
       repeat
and hang op-amp and meter to pin 1 and pin 2
to check linearity .

checkit out
hope you like it


Download Parallax Basic Stamp I & II Manual. PDF format. 3.3Mb
Manual for BASIC Stamp I and II, version 1.9 (approx 450 pp.)
All other Parallax files can be found at:
http://www.parallaxinc.com/html_files/downloads/download.htm
 
Home Products Prices Site Map Order Contact What's New Books Free Files Links FAQ

Dontronics Home Page


Copyright © 1996-2005 Dontronics

 
 
Dontronics Catalog View Shopping Cart Contents