Tag Archives: PWM

Seg 3: Experimental principle


Experimental principle: on the Arduino board, there only exist digital output ports. In these ports, digital signals can be output. Therefore, in our previous experiments, digital signals can be output in any digital port, and LED can be changed between the two cases: brightness and dark. That is, there exist only two values: high and low voltage level, or 0V and 5V. However, if the Arduino board is used to control the motor run, what can we do? Certainly, we cannot simply use the previous methods, because the voltage is only 0V or 5V. If we use it, the motor would run, and the next time, would stop for a while. But, if we can give the motor a stable continuous voltage signal, the motor can run continuously. Happily, the smart Arduino have rich interfaces. In some interfaces, Arduino can let them output the continuous signal. The ports are 3,5,6,9,10,11 for the Arduino UNO, which are marked by the label “~” on the board. The signals from these ports are used PWM technique. For example, in our such experiment, port 9 is digital, but it has PWM. So it can output a continuous signal. When the digital signal is added into port 9, the signal can be changed into a continuous signal by PWM. This signal can also be used to control the motor. Note that, this signal is discrete, but the internal is so small that we cannot feel it a discrete signal. We just think it is a continuous signal. This point is similar to film, which is discrete, and composed by many pictures (it is said as data frame from image processing). But the internals is very small between the pictures. So we cannot feel the fact.

Theoretically, we can get any concrete voltage value between 0~5V on the Arduino board by PWM technique, but not only 0V and 5V. The fact is realized by the Arduino sentence analogWrite(pin,value), which means that a anlog voltage signal can be output from port pin, where the parameter pin is denoted by the number of port; in such experiment, the port is 9. Another parameter is value, which is a digital signal. Its scope is 0~255. Different value denotes different duty cycle. For example, in Figure 4-3, analogWrite(9,255) means that a continuous 5V voltage signal is output from port 9. Next, how about analogWrite(9,64)? Its voltage value can be computed by U=64/255*5V=1.25V, where the first term 64/255 is denoted by duty cycle 25%. But, can we obtain any voltage value? For example, if we want to get a voltage value U=1.8V, the parameter “value” in Arduino sentence “analogWrite(pin,value)” is computed as value=U*255/5=51U. Therefore, by U=1.8 instituting into the formula, we can get value=91.8. In other words, by the sentence analogWrite(9,91.8), a 1.8V voltage signal is output at port 9.

In addition, the duty cycle is denoted by the ratio of busy and idle. As shown in Figure 4-3, busy means that there exist a voltage and its cure is high. While, idle means that there is no signal, and its curve is low. It is worth noting that, in the runtine “analogWrite(pin,value)”, the scope of value is 0~255, and the voltage is 5V/255 each unit; but the scope of value is 0~1024 in “analogRead(pin)”, and the voltage is 5V/1024 each unit.

Figrue 4-3 Duty cycle

Seg 2: Relevant Concepts

4.3 Experimental principle

Before presenting the experiment principle, some relevant concepts should be given out firstly.

Digital signal: its means that its amplitude is discrete, and limited into a range, like binary code used widely in computer science. The digital signal has a strong anti-interference ability, and can be easily processed by digital signal processing. Nowadays, there are many digital signals, such as mobile signal, information handling by computer, and so on.

Analog signal: its ware changes continuously. Theoretically, we can get any of the value from the analog signal. Since it is interfered easily by the other signals, it is difficult to handling. Thus, generally, the analog signal should firstly be transformed into the digital signal for the convenient signal processing. The difference could be shown in Figure 4-1.

Figure 4-1 Difference of digital and analog signals

PWM is the abbreviation of Pulse Width Modulation. It means that we can equivalently get the required signal wave on the basis of a series pulse width, as shown in Figure 4-2. We can achieve a sine signal wave by a series of pulse signal by the different width. In fact, this principle can be illustrated by the equivalent area from mathematical integral. For example, the area of the first pulse is equivalent to the area surrounded by sine signal wave. So, we can change the duty cycle to get the voltage signal wave. Please image it. If we want to get a direct current voltage wave, the width of each pulse should be equal. In addition, PWM technique has been widely applied to the motor speed control, valve control, and so on. For example, PWM has been used to electronic cars.

Figure 4-2 Sine wave by PWM