Tag Archives: pulldown resistor

Seg 3: hardware and software for removing jitters

The first method: remove jitter from hardware

Firstly, we should get a thorough understanding of the reasons of generating jitters. From Figure 3-5, 3-6, we know that, even if the analog port A0 is cut, there exists voltage to trigger LED light. This shows that there exists some interference around us. If the interference is expressed as voltage, its value may be bigger than 512. Therefore, according to Figure 3-3, a bias resistor can be paralleled between ports 1, 2 and 3, 4. In this way, if the button doesn’t be pressed down, and if there are some interference existing as a voltage level, the voltage will be consumed on the bias resistor. Thus, the LED does not light, if the button doesn’t be push down. By adding a bias resistor (i.e., pulldown resistor), the circuit is changed, as shown in Figure 3-8. Evidently, from this Figure, the extra voltage has been already consumed on the bias resistor. Equivently, the extra voltage is already masked. At this time, if the button doesn’t be pressed down, the LED light doesn’t light. When the circuit is prepared by Figure 3-9, the LED light would light after the code in Program 3 is burn into the Arduino board. Everything is the same as expected.

Figure 3-9 Circuit after adding a bias resistor

Appendix: pulldown resistor (bias resistor)

As shown in Figure 3-10, the bias resistor is connected to GND in the above, so its name is called as pulldown resistor, which means the voltage in location A is pulled down to a low voltage level (GND). Its main function is to make the circuit generate a stable voltage with other resistors and driven circuit.

Figure 3-10 Pulldown resistor

The second method: remove jitter from software

Principle: as the above-mentioned description, once the button is pressed down, there is a delay 5~10ms because of the jitter. So, we can let the trigger delay 5~10ms to make the jitter disappeared in this time. Then, we can make a decision by the voltage after this time. This way better fits for many buttons, since many pulldown resistors are very complex to be arranged. However, during our experiment, if the pulldown resistor doesn’t be connected to the circuit, the LED is still lighting for any long time. Generally, we can combine software and hardware to remove the jitters. In the following appendix is attached here.

Appendix: the code removed jitters by software

01 /*
02 Program 3.1: Remove the jitters by software and hardware
03  */
05 int Button=3; 
06 int LED=13; 
07 boolean onoff=LOW; 
08 void setup()
09 {
10   pinMode(Button,INPUT); 
11   pinMode(LED,OUTPUT); 
12 }
13 void loop(){
14   if(digitalRead(Button)==LOW
15   {
16     delay(10); 
17     if(digitalRead(Button)==HIGH
18     {
19       digitalWrite(LED,onoff);  
20       onoff=(!onoff); 
21       delay(10);  
22       while(digitalRead(Button)==HIGH
23       {
24         delay(1);
25       }
26     }
27   }
28 }

Seg 2: Schematics and Experiments

3.3 Schematics for experiment

When button is pressed down, a high voltage level can be obtained. Then it will trigger Arduino to control the blink of LED. Certainly, we can let the LED blink when the button is pressed down. Its schematic is shown in Figure 3-4, which can be viewed as extension from the first experiment by adding a button.

Figure 3-4 Experiment principle diagram

And its real circuit is shown in Figure 3-5.

Figure 3-5 Circuit block

After the circuit is prepared by Figure 3-5, Program 3 can be run, which is also presented as follows.

01 //Program 3: How to control the blink of LED by Arduino and button
03 int led8=8;// set pin 8 as the digital port for LED on the Arduino board
04 void setup()
05 {
06  pinMode(led8,OUTPUT);// set digital port 8 as OUTPUT
07 }
08 void loop()
09 {
10    int i;// define i as the received voltage
11    i=analogRead(0);//read analog port 0 to port i
12    if(i>512)// set the voltage threshold as i>512(i.e., 2.5V)
13      {digitalWrite(led8,HIGH);// then set port 8 as a high level, which can make led blink
14      delay(2000);}//make LED blink for 2s
15    else
16      digitalWrite(led8,LOW);// if i<512, let port 8 to be a low level, which make led extinguish 
18 }

OK, at this time, when you push down the button, LED can be lighted. But, unfortunately, if you unpress the button, an expected result happens. That is, the LED is still lighting, even if the button loosed. Furthermore, if you hold an end of dupont line by your hand, the LED is still light, as shown in Figure 3-6. But why?

Figure 3-6 Holding an end of dupont, LED is still light

It turns out that, there exists interference around one’s body or environment to some extent. Therefore, even if the button doesn’t be pressed, LED can light. Then, the interface will affect our such experiment by a voltage level, which can trigger the Arduino board to control the state of LED. Certainly, the interface would be different from difference of body and environment. So, when the button is pressed down, because of the flexibility of button, the button cannot trigger the Arduino board with a high voltage level quickly and steadily. There exist some jitters for some time. The length of time is different and determined by the mechanical features. In general, the time is 5~10ms. This is a very important parameter to design a control system. The phenomenon is shown in Figure 3-7. Before or after pressing the button, there exist some jitters. So, we must delete these jitters to avoid the error decision.

Figure 3-7 Jitters appearance

To avoid doing an error choice, we must remove the appearance. There are many ways to remove jitters from hardware and software. It is worth noting that, even if the voltage threshold is set as a value bigger than 512 (512 is a pwm value. In the next sections, we will introduce its principle) in Program 3, the jitter appears as well. What’s more, during the process of our experiment, when i=1000, the LED would light in case the button doesn’t push down. So, we must remove the jitter according to the principle.

Figure 3-8 schematic after adding a bias resistor