菜单
  

    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. 计算机辅助工艺规划CAPP系...

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

  5. 医院信息系统的云计算英文文献和中文翻译

  6. 计算机辅助工程设计重型...

  7. 板材矫直技术的计算机辅...

  8. 十二层带中心支撑钢结构...

  9. 当代大学生慈善意识研究+文献综述

  10. 乳业同业并购式全产业链...

  11. 河岸冲刷和泥沙淤积的监测国内外研究现状

  12. 大众媒体对公共政策制定的影响

  13. 电站锅炉暖风器设计任务书

  14. java+mysql车辆管理系统的设计+源代码

  15. 酸性水汽提装置总汽提塔设计+CAD图纸

  16. 中考体育项目与体育教学合理结合的研究

  17. 杂拟谷盗体内共生菌沃尔...

  

About

751论文网手机版...

主页:http://www.751com.cn

关闭返回