久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 12803|回復: 7
收起左側

PCA9685引腳圖與16路舵機Arduino驅動源程序pdf資料下載

  [復制鏈接]
ID:275946 發表于 2018-1-14 19:46 | 顯示全部樓層 |閱讀模式
0.jpg

PCA9685引腳圖:
0.png

PCA9685 16路舵機驅動原理圖:
0.png

PCA9685管腳功能定義:
0.png 0.png

0.jpg 0.jpg 0.png

Arduino源程序如下:
  1. /***************************************************
  2.   This is a library for our Adafruit 16-channel PWM & Servo driver
  3.   Pick one up today in the adafruit shop!
  4.   These displays use I2C to communicate, 2 pins are required to  
  5.   interface. For Arduino UNOs, thats SCL -> Analog 5, SDA -> Analog 4

  6.   Adafruit invests time and resources providing this open source code,
  7.   please support Adafruit and open-source hardware by purchasing
  8.   products from Adafruit!

  9.   Written by Limor Fried/Ladyada for Adafruit Industries.  
  10.   BSD license, all text above must be included in any redistribution
  11. ****************************************************/

  12. #include <Adafruit_PWMServoDriver.h>
  13. #include <Wire.h>
  14. #if defined(__AVR__)
  15. #define WIRE Wire
  16. #elif defined(CORE_TEENSY) // Teensy boards
  17. #define WIRE Wire
  18. #else // Arduino Due
  19. #define WIRE Wire1
  20. #endif

  21. // Set to true to print some debug messages, or false to disable them.
  22. #define ENABLE_DEBUG_OUTPUT false

  23. Adafruit_PWMServoDriver::Adafruit_PWMServoDriver(uint8_t addr) {
  24.   _i2caddr = addr;
  25. }

  26. void Adafruit_PWMServoDriver::begin(void) {
  27. WIRE.begin();
  28. reset();
  29. }


  30. void Adafruit_PWMServoDriver::reset(void) {
  31. write8(PCA9685_MODE1, 0x0);
  32. }

  33. void Adafruit_PWMServoDriver::setPWMFreq(float freq) {
  34.   //Serial.print("Attempting to set freq ");
  35.   //Serial.println(freq);
  36.   freq *= 0.9;  // Correct for overshoot in the frequency setting (see issue #11).
  37.   float prescaleval = 25000000;
  38.   prescaleval /= 4096;
  39.   prescaleval /= freq;
  40.   prescaleval -= 1;
  41.   if (ENABLE_DEBUG_OUTPUT) {
  42.     Serial.print("Estimated pre-scale: "); Serial.println(prescaleval);
  43.   }
  44.   uint8_t prescale = floor(prescaleval + 0.5);
  45.   if (ENABLE_DEBUG_OUTPUT) {
  46.     Serial.print("Final pre-scale: "); Serial.println(prescale);
  47.   }
  48.   
  49.   uint8_t oldmode = read8(PCA9685_MODE1);
  50.   uint8_t newmode = (oldmode&0x7F) | 0x10; // sleep
  51.   write8(PCA9685_MODE1, newmode); // go to sleep
  52.   write8(PCA9685_PRESCALE, prescale); // set the prescaler
  53.   write8(PCA9685_MODE1, oldmode);
  54.   delay(5);
  55.   write8(PCA9685_MODE1, oldmode | 0xa1);  //  This sets the MODE1 register to turn on auto increment.
  56.                                           // This is why the beginTransmission below was not working.
  57.   //  Serial.print("Mode now 0x"); Serial.println(read8(PCA9685_MODE1), HEX);
  58. }

  59. void Adafruit_PWMServoDriver::setPWM(uint8_t num, uint16_t on, uint16_t off) {
  60.   //Serial.print("Setting PWM "); Serial.print(num); Serial.print(": "); Serial.print(on); Serial.print("->"); Serial.println(off);

  61.   WIRE.beginTransmission(_i2caddr);
  62.   WIRE.write(LED0_ON_L+4*num);
  63.   WIRE.write(on);
  64.   WIRE.write(on>>8);
  65.   WIRE.write(off);
  66.   WIRE.write(off>>8);
  67.   WIRE.endTransmission();
  68. }

  69. // Sets pin without having to deal with on/off tick placement and properly handles
  70. // a zero value as completely off.  Optional invert parameter supports inverting
  71. // the pulse for sinking to ground.  Val should be a value from 0 to 4095 inclusive.
  72. void Adafruit_PWMServoDriver::setPin(uint8_t num, uint16_t val, bool invert)
  73. {
  74.   // Clamp value between 0 and 4095 inclusive.
  75.   val = min(val, 4095);
  76.   if (invert) {
  77.     if (val == 0) {
  78.       // Special value for signal fully on.
  79.       setPWM(num, 4096, 0);
  80.     }
  81.     else if (val == 4095) {
  82.       // Special value for signal fully off.
  83.       setPWM(num, 0, 4096);
  84.     }
  85.     else {
  86.       setPWM(num, 0, 4095-val);
  87.     }
  88.   }
  89.   else {
  90.     if (val == 4095) {
  91.       // Special value for signal fully on.
  92.       setPWM(num, 4096, 0);
  93.     }
  94.     else if (val == 0) {
  95.       // Special value for signal fully off.
  96.       setPWM(num, 0, 4096);
  97.     }
  98.     else {
  99.       setPWM(num, 0, val);
  100.     }
  101.   }
  102. }

  103. ……………………

  104. …………限于本文篇幅 余下代碼請從51黑下載附件…………
復制代碼
0.png
所有資料51hei提供下載:
16路舵機驅動.rar (692.97 KB, 下載次數: 111)
PCA9685.pdf (1.14 MB, 下載次數: 65)
PCA9685_20141121.pdf (37.53 KB, 下載次數: 57)



回復

使用道具 舉報

ID:281639 發表于 2018-6-26 10:38 | 顯示全部樓層
xiexie分享
回復

使用道具 舉報

ID:359446 發表于 2018-6-26 16:02 | 顯示全部樓層
謝謝分享。這玩意我滿世界找不到。
回復

使用道具 舉報

ID:468627 發表于 2019-1-15 16:25 | 顯示全部樓層
不錯,
回復

使用道具 舉報

ID:465522 發表于 2019-1-19 15:09 | 顯示全部樓層
不錯,下來看看
回復

使用道具 舉報

ID:507262 發表于 2019-4-8 19:23 來自手機 | 顯示全部樓層
謝謝分享
回復

使用道具 舉報

ID:527731 發表于 2019-5-6 14:34 | 顯示全部樓層
有原理圖源文件嗎
回復

使用道具 舉報

ID:1133976 發表于 2024-10-20 22:49 | 顯示全部樓層
原理圖中C2電容的符號是pol2,并不是注釋的pol1,而且2.2uf設置不合理,控制多個舵機應該濾低頻,采用更大容值的電容,平滑電源的低頻波動和瞬態電流,確保舵機工作時電源穩定。
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 久久com | 亚洲欧洲在线视频 | 一级特黄网站 | 色资源在线观看 | 一区二区三区中文字幕 | 国产精品一区二区久久久久 | 亚洲 中文 欧美 日韩 在线观看 | 成人国产一区二区三区精品麻豆 | 一区二区在线视频 | 欧美在线观看免费观看视频 | 久久精品综合 | 鲁大师一区影视 | 日本免费视频在线观看 | 久久精品视频免费观看 | 九九综合 | 免费精品久久久久久中文字幕 | 欧美天堂在线 | 日韩91| 蜜桃免费av | 久久成人一区 | 黄色一级电影在线观看 | 精品一区二区在线观看 | 欧美日批 | 日本高清在线一区 | 网站国产 | 欧美一级全黄 | 日日摸天天添天天添破 | 欧美成人精品激情在线观看 | 91资源在线 | 天天干天天插 | 欧美性a视频 | 久久69精品久久久久久久电影好 | 999免费观看视频 | 亚洲国产成人精品女人 | 国产精品视频免费观看 | 精久久久| 久草成人网 | h片在线观看网站 | 欧美专区日韩 | 精品无码久久久久久国产 | 国产午夜视频 |