Anda di halaman 1dari 4

Terence Coughlan Paul Kelly

Automation 2 Assignment 1 (Basic Stamp 2)

Niall Bell 25/01/2012

Dimensional specifications of BS2 board

Description of the main elements of the microcontroller and their functions


A microcontroller is a basic computer and has several things in common with other computers whether theyre a large frame computer or a personal computer. Every computer has some way of communicating with the real world; this is done by using input/output devices. For example, on your personal computer, the monitor and speakers are output devices and a keyboard and mouse would be input devices. A hard disk is both an input and output device. All types of computer have some memory where it can store variables and files. This memory is called RAM (random access memory) All computers have a brain and this is known as a CPU (central processing unit). The CPU retrieves the program to be executed and then executes it. The CPU sends commands to the rest of the system and keeps the system running smoothly.

Terence Coughlan Paul Kelly

Automation 2 Assignment 1 (Basic Stamp 2)

Niall Bell 25/01/2012

Explanation of how the serial communications work

Pin 1 of the stamp (SOUT) connects to the serial port RX pin (DB9 pin 2 / DB25 pin 3) for programming. Pin 2 of the stamp (SIN) connects to the serial port TX pin (DB9 pin 3 / DB25 pin 2) for programming. Pin 3 of the stamp (ATN) connects to the serial port DTR pin (DB9 pin 4 / DB25 pin 20) for programming. Pin 4 of the stamp (VSS) connects to the serial port GND pin (DB9 pin 5 / DB25 pin 7) for programming. A program is written in the BASIC Stamp Editor The program is tokenized or converted into symbolic format The tokenized program is transmitted through the serial cable and stored in EEPROM memory The interpreter chip reads the program from EEPROM and executes the instructions

Description of how the software works, where its stored and how much can be stored
The BS2 software works as a simplified version of BASIC called PBASIC. PBASIC has a few instructions and is limited to positive integer arithmetic but adds unique instructions to manipulate the I/O pins. All positive instructions are on one line and these lines are executed at approximately 4000 lines/second. The BS2 has two types of memory: RAM (random access memory) and EEPROM (electrically erasable programmable read only memory). A very useful property of EEPROM is that it can retain the data stored in its memory when there is no power supply, unlike RAM which loses its data and resets to all zeros when there is no power supply. This means that the stamp can automatically run when reconnected to a power supply without having to download the same program. EEPROM is relatively slow to read and write data and has a limited number of read/write cycles.

Terence Coughlan Paul Kelly

Automation 2 Assignment 1 (Basic Stamp 2)

Niall Bell 25/01/2012

The RAM on a BS2 has 32 bytes for storing variables. The first six bytes are reserved for i/o pins and other system variables. This leaves 26 bytes of RAM for the user to program the stamp. These particular bytes are labelled b0 through to b25 with 8 bits in each byte. A word can contain 16 bits and thus are labelled w0 through to w12. By using the variable declaration methods, it is possible to overlap the byte size variable space without running into trouble.

Command syntax
To set the version of stamp being used you can click on the appropriate buttons in the tool bar of the editor as shown below.

To designate a pin as an input or an output you would type: Output with the pin number you wanted i.e. Output 4 to designate pin 4 as an output or Input 4 to designate pin 4 as an input. To turn an output to a logic 1 (5V) you would type the following code: Output 4 High 4 To designate a comment you would use an apostrophe at the beginning of the comment i.e.

The syntax to create and call a subroutine is as follows:

The GOSUB command will look for the label Hello: in the program code and when it finds it, it will execute that section of the program and then return to the main body of the program and continue executing the rest of the code.

Explanation of RCTIME
The RCTIME command measures the time it takes for the input pin to reach the state you have specified i.e. usually used to measure a variable resistance or capacitance. If you connect a capacitor between 5V and a stamp pin and a resistor from the stamp pin to ground, you can use the RCTIME command to measure the time it takes for the circuit to charge. The time will be proportional to the capacitance and resistance used. This is useful for measuring the position of a potentiometer, the resistance of a thermistor, strain gauges to measure force or (weight if measuring the force of gravity), hygristors to measure humidity or any other resistive/capacitive sensors. The RCTIME command can also be used as a fast, precise stop watch over very short periods.

Terence Coughlan Paul Kelly

Automation 2 Assignment 1 (Basic Stamp 2)

Niall Bell 25/01/2012

Driving a motor from an output pin


It depends on if you want to have control over the motor. If you want to have very limited control over the motor then a relay and diode could be used but if you want to have control over the motor then you would need something along the lines of a darlington transistor and a diode. The reason you need extra circuitry with the output pin of the stamp is because of the current that a motor requires to run. A BS2 can only handle 50mA (sink current) or 40mA (source current) over 8 pins, this gives a total of 100mA (sink) or 80mA (source) current and is much less than what a motor would require to run. You could also use an IC motor driver, ULN2803A for example. Another option would be to use a MOSFET switch. This type of switch can drive up to 20A with practically no current required at the gate. Parallax has various products available that will drive motors from an output pin on a stamp i.e. the L293D Quad Half-H Drive or the ULN2803A Darlington array.

Anda mungkin juga menyukai