barcode maker vb.net STAMP 2 INPUT/OUTPUT INTERFACING in Software

Creator ANSI/AIM Code 128 in Software STAMP 2 INPUT/OUTPUT INTERFACING

20 STAMP 2 INPUT/OUTPUT INTERFACING
Code 128 Code Set A Decoder In None
Using Barcode Control SDK for Software Control to generate, create, read, scan barcode image in Software applications.
Draw Code-128 In None
Using Barcode generator for Software Control to generate, create Code 128B image in Software applications.
STAMP 2 P0 BS 2
Scan Code 128 Code Set B In None
Using Barcode reader for Software Control to read, scan read, scan image in Software applications.
USS Code 128 Creator In C#.NET
Using Barcode drawer for VS .NET Control to generate, create Code-128 image in Visual Studio .NET applications.
N/C S1 Figure 2-3 Active high input normally closed input.
Generate Code 128B In .NET
Using Barcode maker for ASP.NET Control to generate, create Code 128 Code Set C image in ASP.NET applications.
Code128 Generator In Visual Studio .NET
Using Barcode drawer for Visual Studio .NET Control to generate, create Code 128A image in Visual Studio .NET applications.
When the normally closed switch is pressed, an open condition causes the input to go low, i.e., to ground. This configuration would also be good for alarm monitoring systems, where a supervisory condition exists. The code for this configuration is as follows:
Code 128 Creation In VB.NET
Using Barcode generator for .NET Control to generate, create Code128 image in .NET applications.
Drawing UCC - 12 In None
Using Barcode creator for Software Control to generate, create UPCA image in Software applications.
ACTIVE LOW normally closed input switch or sensor sense: if in0 =0 then activate goto sense activate: debug "switch depressed" goto sense
Bar Code Creator In None
Using Barcode creation for Software Control to generate, create bar code image in Software applications.
Create EAN 13 In None
Using Barcode creator for Software Control to generate, create European Article Number 13 image in Software applications.
In order to utilize the STAMP 2 to sense or control the outside world, you must change the direction of the I/O pins to tell the STAMP 2 that you would like to use a particular I/O pin as an output pin (see the manual on the CD-ROM). The STAMP 2 can control almost any type of device; however, it will supply only about 20 mA of current to an output device. The STAMP 2 will drive an LED or optocoupler with no problem, but almost any other output device would need to be driven by a transistor. The transistor acts a current switch that can control larger-current devices. In Fig. 2-5, the STAMP 2 turns on the LED when P0 goes low. The cathode of the LED is sunk to ground through the output pin. Figure 2-6 illustrates the STAMP 2 sourcing current to the LED. The microprocessor in this example is sourcing current from the positive supply voltage through the LED to ground. Some microcontrollers may not have enough sourcing current capacity, so a transistor may have to be used to drive an output. The diagram in Fig. 2-7 depicts an LED being driven by an npn transistor. When pin P0 goes high, a current is caused to flow to the base of the 2N2222 npn transistor, thus effectively connecting the cathode of the LED to ground; this is known as sinking current to ground. This example would be effective if you wished to turn on a high-current LED, or infrared LED, or other device that draws more current. Figure 2-8 shows a similar application but uses a pnp transistor to drive a current device. Note that the emitter of the transistor is connected to the plus supply voltage. The current in this example is being sourced by the transistor. Once again this application is for driving higher-current LEDs or other devices.
USS Code 128 Maker In None
Using Barcode encoder for Software Control to generate, create Code 128B image in Software applications.
Make Code39 In None
Using Barcode drawer for Software Control to generate, create Code 39 image in Software applications.
INTERFACES FOR THE MICROPROCESSOR 21
Creating UPC - 8 In None
Using Barcode encoder for Software Control to generate, create EAN8 image in Software applications.
UCC - 12 Creator In None
Using Barcode printer for Office Word Control to generate, create UPC Code image in Word applications.
+5V S1 N/C STAMP 2 P0 BS 2
Barcode Generation In None
Using Barcode generation for Online Control to generate, create bar code image in Online applications.
Scan Code 39 Extended In Java
Using Barcode decoder for Java Control to read, scan read, scan image in Java applications.
10K Figure 2-4 Active low input normally closed input.
Making EAN-13 Supplement 5 In None
Using Barcode printer for Online Control to generate, create UPC - 13 image in Online applications.
Barcode Generation In Java
Using Barcode creation for Android Control to generate, create barcode image in Android applications.
1K STAMP 2
EAN 128 Creation In Visual Studio .NET
Using Barcode encoder for .NET framework Control to generate, create UCC-128 image in VS .NET applications.
Printing UCC - 12 In None
Using Barcode creator for Font Control to generate, create UCC.EAN - 128 image in Font applications.
+5V 21
BS 2
Figure 2-5 STAMP 2 output sunk to ground.
LED is "sunk" to ground.
Interfaces for the Microprocessor
Sometimes it s necessary to interface a microprocessor to other ICs or microprocessors. The circuit in Fig. 2-9 depicts a bipolar transistor turned on by the STAMP 2 on pin P0. Transistors are ideal interfacing devices; they require a small current to turn on and can easily isolate the next circuit stage. This circuit can be thought of as an inverting buffer, since the signal output from the STAMP 2 is a positive pulse. The output after the transistor becomes a low, thus creating an inverted and buffered signal. Many circuits require
22 STAMP 2 INPUT/OUTPUT INTERFACING
STAMP 2
BS 2 +5V 21 1K
FIGURE 2-6 STAMP 2 output sourced to ground.
Microcontroller "sources" to ground +5V
STAMP 2 P0 BS 2 1K
2N2222 transistor npn
Figure 2-7 STAMP 2 transistor output current sunk to ground.
a negative- or low-going input in order to be activated, and this type of circuit is perfect in this type of application. The diagram in Fig. 2-10 shows an optoisolator inverting buffer. This type of inverting buffer is used when absolute isolation is needed between circuits. The STAMP 2 output at pin P0 is once again a positive-going pulse, and the output of the optoisolator becomes low. A PS2501 optoisolator is shown, but any general-purpose device could be substituted.
SERIAL PORT INTERFACING 23
STAMP 2 P0 BS 2 transistor pnp 1K 1K 2N3906
LED Current "sourced" to ground Figure 2-8 STAMP 2 transistor output current sourced to ground.
Often it is necessary to use a microprocessor to control a relay. In order to have the STAMP 2 control a relay, a transistor driver must be used. In the next example, shown in Fig. 2-11, pin P0 is used to drive a 2N2222 npn transistor, which in turn is used to control the relay. Although some mechanical relays may draw a low enough current to control a relay directly, this is not recommended. When the electromagnetic field of a relay collapses, a voltage spike is generated. This spike can damage MOS-type circuits found in microprocessors. In this circuit a high signal on P0 causes the transistor to conduct and sink the relay to ground. The magnetic field energizes, and relay contacts close. Upon deactivation, the relay coil generates a reverse voltage spike. This voltage spike is shorted out or snubbed by the diode across the relay coil. Also note that if you want to control very large currents, then a low-current relay could be used to drive a high-current relay. The STAMP 2 can be used to control a dc motor as shown in Fig. 2-12. In this circuit, a high at pin P0 drives the IRF511 MOSFET device, which in turn operates the dc motor. A diode is placed across the MOSFET when the motor field changes, thus protecting the MOSFET and the STAMP 2. Note that you will have to scale your motor and its current requirement with the MOSFET used in your particular application.
Copyright © OnBarcode.com . All rights reserved.