鱼香ROS社区
    • 版块
    • 最新
    • 未解决
    • 已解决
    • 群组
    • 注册
    • 登录
    紧急通知:禁止一切关于政治&VPN翻墙等话题,发现相关帖子会立马删除封号
    提问前必看的发帖注意事项: 社区问答规则(小鱼个人)更新 | 高质量帖子发布指南

    Fishbot 四驱版使用PCA9685扩展PWM接口数量

    已定时 已固定 已锁定 已移动
    FishBot二驱机器人
    fishbot 四驱板 pca9658
    1
    1
    454
    正在加载更多帖子
    • 从旧到新
    • 从新到旧
    • 最多赞同
    回复
    • 在新帖中回复
    登录后回复
    此主题已被删除。只有拥有主题管理权限的用户可以查看。
    • 小鱼小
      小鱼 技术大佬
      最后由 编辑

      板子本身舵机接口不够,可以使用PCA9685进行扩展,该版本价格10元左右,某宝均可购买。

      驱动例程如下,PIO工程

      platformio.ini

      ; PlatformIO Project Configuration File
      ;
      ;   Build options: build flags, source filter
      ;   Upload options: custom upload port, speed and extra flags
      ;   Library options: dependencies, extra library storages
      ;   Advanced options: extra scripting
      ;
      ; Please visit documentation for the other options and examples
      ; https://docs.platformio.org/page/projectconf.html
      
      [env:featheresp32]
      platform = espressif32
      board = featheresp32
      framework = arduino
      lib_deps = nachtravevl/PCA9685-Arduino@^1.2.15
      
      

      main.cpp

      
      #include "PCA9685.h"
      
      PCA9685 pwmController;                  // Library using default B000000 (A5-A0) i2c address, and default Wire @400kHz
      PCA9685_ServoEval pwmServo1;
      
      void setup() {
          Serial.begin(115200);               // Begin Serial and Wire interfaces
          Wire.begin(18,19);
          pwmController.resetDevices();       // Resets all PCA9685 devices on i2c line
          pwmController.init();               // Initializes module using default totem-pole driver mode, and default disabled phase balancer
          pwmController.setPWMFreqServo(); // Set PWM freq to 100Hz (default is 200Hz, supports 24Hz to 1526Hz)
          for(int i=0;i<16;i++)
          {
            pwmController.setChannelPWM(i, pwmServo1.pwmForAngle(0+i*10)); // Set PWM to 128/255, shifted into 4096-land
            Serial.println(pwmController.getChannelPWM(i)); // Should output 2048, which is 128 << 4
          }
      }
      
      void loop() {
        
      }
      

      新书配套视频:https://www.bilibili.com/video/BV1GW42197Ck/

      1 条回复 最后回复 回复 引用 0
      • 第一个帖子
        最后一个帖子
      皖ICP备16016415号-7
      Powered by NodeBB | 鱼香ROS