barcode reader asp.net web application PIC MICROCONTROLLER APPLICATION BASICS in Software

Make QR Code ISO/IEC18004 in Software PIC MICROCONTROLLER APPLICATION BASICS

PIC MICROCONTROLLER APPLICATION BASICS
QR Code Recognizer In None
Using Barcode Control SDK for Software Control to generate, create, read, scan barcode image in Software applications.
QR Code ISO/IEC18004 Creator In None
Using Barcode maker for Software Control to generate, create Quick Response Code image in Software applications.
debounce: BUTTON PRESS WITH DEBOUNCE
Decode Quick Response Code In None
Using Barcode recognizer for Software Control to read, scan read, scan image in Software applications.
Drawing QR Code In Visual C#.NET
Using Barcode drawer for Visual Studio .NET Control to generate, create QR Code image in VS .NET applications.
Depending on the quality of the momentary-on switch you used for power measurement experiment in the preceding section, you may have noticed that the LED ickered while you were pushing down on the switch. This is caused by intermittent contacts being made in the switch. This is one of the reasons why I suggest that you use switches that click when they are pressed and released; the clicking action ensures a good contact and also wipes the switch s contacts clean. Even with this capability built into the switch, if you were to observe the action of the switch, you probably would see some bouncing, as shown in Fig. 20.4. The jagged edges on the oscilloscope plot are the bounces that happen within the switch when it is pressed. For this experiment, I used the same circuit as in the ledon experiment (see Fig. 20.5) and the oscilloscope picture shown in Fig. 20.4 (this picture was taken at RA0). This circuit can be built on a breadboard, as shown in Fig. 20.6. To eliminate the ickering of the LED, which indicates the switch is bouncing, code must be written to wait for the bouncing to stop for a set amount of time. As I indicated elsewhere in this book, the normal interval of time to wait for the bouncing to stop is 20 ms. This is done by continually polling the switch until it has remained in the same state for 20 ms. This operation is shown in the following pseudocode:
Generating QR Code JIS X 0510 In .NET
Using Barcode printer for ASP.NET Control to generate, create Quick Response Code image in ASP.NET applications.
Generating QR Code JIS X 0510 In Visual Studio .NET
Using Barcode creator for .NET Control to generate, create QR image in VS .NET applications.
Switch Bouncing while Changing State
Generate QR-Code In VB.NET
Using Barcode printer for VS .NET Control to generate, create QR-Code image in .NET applications.
DataMatrix Printer In None
Using Barcode encoder for Software Control to generate, create Data Matrix image in Software applications.
1) Ch 1
Painting EAN 128 In None
Using Barcode generation for Software Control to generate, create GTIN - 128 image in Software applications.
UPCA Generation In None
Using Barcode creation for Software Control to generate, create UPC-A Supplement 5 image in Software applications.
5 Volt
Encoding Code 128 In None
Using Barcode drawer for Software Control to generate, create Code 128 Code Set B image in Software applications.
Bar Code Printer In None
Using Barcode maker for Software Control to generate, create barcode image in Software applications.
100 us
GS1 - 8 Creation In None
Using Barcode creation for Software Control to generate, create UPC - 8 image in Software applications.
Reading Bar Code In VB.NET
Using Barcode Control SDK for VS .NET Control to generate, create, read, scan barcode image in Visual Studio .NET applications.
Figure 20.4 to a low one.
Reading European Article Number 13 In Visual Basic .NET
Using Barcode decoder for Visual Studio .NET Control to read, scan read, scan image in Visual Studio .NET applications.
Code 128C Printer In Java
Using Barcode generation for Java Control to generate, create Code 128C image in Java applications.
Oscilloscope picture of a switch bouncing from a high logic level
Encoding Bar Code In .NET Framework
Using Barcode encoder for Visual Studio .NET Control to generate, create barcode image in Visual Studio .NET applications.
Bar Code Maker In Objective-C
Using Barcode generation for iPad Control to generate, create bar code image in iPad applications.
SOME BASIC FUNCTIONS
Code-128 Drawer In None
Using Barcode drawer for Office Excel Control to generate, create Code 128 Code Set C image in Office Excel applications.
Bar Code Reader In Java
Using Barcode scanner for Java Control to read, scan read, scan image in Java applications.
16F84
0.1 uF Tantalum Gnd
Vdd RA0
Oscilloscope Probe of Bouncing Connected Here
Momentary On 10 K Momentary 220 On
10 K
4 16
_MCLR Osc 1 Osc 2 Vss RB0
4 MHz
Figure 20.5 probe shown.
Debounce circuit with location of oscilloscope
Debounce_Down: // for 20 msec while (Switch == Up);
// //
Wait for the Switch to be held down Wait for the Switch to go down
for (Dlay = 0; (Switch == Down) && (Dlay < 20msec); Dlay++); // Poll the Switch while Incrementing // the Delay Timer if (Dlay < 20msec) goto Debounce_Down; // If 20 msecs has NOT passed, wait for // Switch Down and Repeat Process // When Execution reaches here, the switch is Down and Debounced
+5 +5 Volt Vo P/S P/S
10 K
Switch Button 220 220 220 220 220 220 220 220 220 220 10 K 10 K 0.1 uF 0.1 uF
Breadboard circuit layout for the debounce circuit.
PIC16F84 PIC16F84
4 MHz 4 MHz
Momentary On Switch
PIC MICROCONTROLLER APPLICATION BASICS
The actual PIC microcontroller assembly code for a PIC16F84 running at 4 MHz with the button at RA0 is
Debounce_Down: btfsc goto movlw movwf movlw movwf bcf PORTA, 0 Debounce_Down 0x0100 - 0x0C4 Dlay 0x0100 - 0x00A Dlay + 1 STATUS, Z
; ; ;
Wait for Button Down Initialize Dlay for a 20 msec Delay
Make Sure that Zero is Reset
Debounce_Down_Loop: incfsz Dlay, f goto $ + 2 incf Dlay + 1, f btfsc PORTA, 0 goto Debounce_Down btfss STATUS, Z goto Debounce_Down_Loop //
No - Loop Around Again Zero Flag Set (20 mSecs Past )
When Execution reaches here, the switch is Down and Debounced
One aspect of this code that may be confusing is how I came up with the values 0x100 0x0C4 and 0x100 0x00A for the initial values in Dlay and how the delay count works in the Debounce_Down_Loop. The code in Debounce_Down_Loop takes eight instruction cycles to execute for a 20-ms delay with a 4-MHz clock speed, that means it has to execute 2,500 times. In decimal, 2,500 is 0x9C4. Because the incf instruction is used for the upper byte, I added one cycle to it to make sure that it increments the lower byte 9 times 256 times through and once for 0xC4 (196 decimal) times. The three instructions for the delay count, i.e.,
incfsz Dlay, f goto $ + 2 incf Dlay + 1, f
always execute in the same number of cycles and only set the STATUS register s zero ag when the 2,500 loops through Debounce_Down_Loop have executed. This code could have been executed differently, speci cally using decrements, but I wanted to try something different, and the advantage of this code is that it allows the loop to take a total of eight cycles, which is evenly divisible by 20,000. This code is useful for checking for button-down, but the button-up also has to be checked. As can be seen in the debounce source code snippet below, both the switch
Copyright © OnBarcode.com . All rights reserved.