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

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>