菜单
  

    Figure 4-17. A physical-computing DC motor speed controller built on a solderless breadboard
    The motor speed control, as discussed earlier, takes place through the 10KΩ potentiometer. Adjusting it will allow the Arduino’s ATmega328 microcontroller to provide a smooth string of pulses that will bias the 2N2222 transistor to efficiently drive the small DC motor. To see the PWM signal, you must connect an oscilloscope at the base of the transistor driver and attach the other test lead to ground. Figure 4-18 illustrates how an oscilloscope is connected to the 2N2222 NPN transistor’s base lead. The actual measurement setup is shown in Figure 4-19. The duty cycle (discussed in Chapter 1) for the adjusted motor speed was measured at 38.81 percent. When the potentiometer’s shaft is rotated, the duty cycle value changes proportional to the amount of resistance. As the potentiometer’s resistance increases, the duty cycle value becomes larger. At full resistance (10KΩ), the duty cycle value is at 100 percent with the small DC motor running at full-rated speed.
     Figure 4-18. Circuit schematic diagram of the Arduino controlled DC motor with an oscilloscopes to observe the PWM  signals
     Figure 4-19. Circuit schematic diagram showing how to attach an oscilloscope to observe the PWM signals generated by the Arduino
    Figure 4-20 shows a close-up of the Arduino-produced PWM control signal in which you can see a series of clean, square-wave pulses.
     
    Figure 4-20. The Arduino-produced PWM control signal for motor speed control

    The 2N2222 Transistor Pinout
    An important item to note is that all NPN transistors are not created equal. The 2N3904 NPN transistor’s pinout (from the “Assembly of the Electronic Singing Bird Circuit on a Breadboard” section of Chapter 1) consists of the emitter being located to the left of the three-pin device. The base is the center lead, and the collector is located to the immediate right. For the 2N2222 transistor, the emitter is on the right side and collector is on the left side. Figure 4-21 shows the pinout for the 2N2222 transistor that will ensure proper operating function of this speed control circuit, as well as the simple motor control project.
     
    Figure 4-21. Pinout diagram for the 2N2222 NPN transistor (courtesy of ON Semiconductor datasheet)
    The Motor Speed Control Software
    With the electronics hardware in place, the sketch is needed to complete the project build. The sketch allows the Arduino to read the potentiometer’s analog position and generates a PWM signal that is proportional to the angular location of  the wiper arm. The sketch is well commented, so changes to the analog or digital port pins can easily be made. Listing 4-1 shows the motor speed control sketch.

    Listing 4-1. The Motor Speed Control Sketch
    int motorPin = 9; // motor connected to digital pin 9
    int analogPin = 0; // potentiometer connected to analog pin 0
    int val = 0; // variable to store the read value
    void setup()
    {
    pinMode(motorPin, OUTPUT); // sets the pin as output
    }
    void loop()
    {
    val = analogRead(analogPin); // read the input pin
    analogWrite(motorPin, val / 4); // analogRead values go from 0 to             
                                              1023, analogWrite values from 0 to 255
    }
           Here’s a final note regarding the operation of the physical computing–based controller: after uploading the motor speed control sketch to the Arduino, depending on the position of the 10KΩ potentiometer, the electromechanical device may start at low, medium, or high speed.
  1. 上一篇:拉丝机英文文献和中文翻译
  2. 下一篇:冲压模具英文参考文献和中文翻译
  1. 智能城市物流云计算模型英文文献和中文翻译

  2. 云计算服务英文文献和中文翻译

  3. 直流电机英文文献和中文翻译

  4. 电-气动驱动的垂直计算机...

  5. 金属板料冲压模具计算机...

  6. 计算机辅助工艺规划CAPP系...

  7. 零件识别的计算机辅助装...

  8. 浅析中国古代宗法制度

  9. 现代简约美式风格在室内家装中的运用

  10. 高警觉工作人群的元情绪...

  11. 江苏省某高中学生体质现状的调查研究

  12. g-C3N4光催化剂的制备和光催化性能研究

  13. 巴金《激流三部曲》高觉新的悲剧命运

  14. C++最短路径算法研究和程序设计

  15. 中国传统元素在游戏角色...

  16. NFC协议物理层的软件实现+文献综述

  17. 上市公司股权结构对经营绩效的影响研究

  

About

优尔论文网手机版...

主页:http://www.youerw.com

关闭返回