Giter Site home page Giter Site logo

stm32-hal-pca9685's People

Contributors

henriheimann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

stm32-hal-pca9685's Issues

PWM gives 10 times too little power

Objective:

My objective was to use this library to control SG90-TowerPro servo motors using a PCA9685.

Problem:

When analysing the voltage on the pwm cable of the servo, I find fixed 0.033V where I should find a changing value orbiting around 0.3V.

Context:

Using a single SG90-TowerPro servo motor connected to the port 0 of the PCA9685. Using CubeMX and CubeIDE to code. No compiling error and everything seem to work according to the debugger. Coding on an STM32F303K8 nucleo board. Having the files correctly imported. Servo documentation: https://cdn.datasheetspdf.com/pdf-down/S/G/9/SG90-TowerPro.pdf

Relevant parts of the code:

Rewrote the hal importing part of pca9685.h in order to import the correct hal as follows:

Replaced

#if (defined STM32L011xx) || (defined STM32L021xx) || \
	(defined STM32L031xx) || (defined STM32L041xx) || \
	(defined STM32L051xx) || (defined STM32L052xx) || (defined STM32L053xx) || \
	(defined STM32L061xx) || (defined STM32L062xx) || (defined STM32L063xx) || \
	(defined STM32L071xx) || (defined STM32L072xx) || (defined STM32L073xx) || \
	(defined STM32L081xx) || (defined STM32L082xx) || (defined STM32L083xx)
#include "stm32l0xx_hal.h"
#elif defined (STM32L412xx) || defined (STM32L422xx) || \
	defined (STM32L431xx) || (defined STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx) || \
	defined (STM32L451xx) || defined (STM32L452xx) || defined (STM32L462xx) || \
	defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) || \
    defined (STM32L496xx) || defined (STM32L4A6xx) || \
    defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx)
#include "stm32l4xx_hal.h"
#else
#error Platform not implemented
#endif

with
#include "stm32f3xx_hal.h"

Main code:

Initialization:

#include "pca9685.h"
#define SERVO_COUNT	1
uint8_t ActiveServo;

pca9685_handle_t handle = {
      .i2c_handle = &hi2c1,
      .device_address = PCA9865_I2C_DEFAULT_DEVICE_ADDRESS,
      .inverted = false
  };
pca9685_init(&handle);
pca9685_set_pwm_frequency(&handle, 50.0f);

HAL_Delay(2000);

Loop

pca9685_set_channel_duty_cycle(&handle, 1, 0.09f, false);
HAL_Delay(1000);

pca9685_set_channel_duty_cycle(&handle, 1, 0.06f, false);
HAL_Delay(1000);

According to the documentation, it should be on between 1 and 2 ms on a 20 ms pwm period (wich is 5 to 10% equivalent to 0.05 to 0.1) working at 50 hertz.

Debugging tried:

Made it work with an arduino nano
Made it (kinda) work with another library (just some vibrations problems to fix)
Watched very carefully the sleeping status of the PCA (did not sleep at all)

All of this had led me to think maybe the problem was not on my part but I certainly can be wrong as you seem far more knowledgeable than me.

Hoping for this issue to be helping,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.